Skip to content

Commit bea7ac9

Browse files
committed
Add reinit-pathman.sh
1 parent 160b606 commit bea7ac9

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
n_shards=3
2+
export PATH=~/postgres_cluster/dist/bin/:$PATH
3+
ulimit -c unlimited
4+
pkill -9 postgres
5+
sleep 2
6+
rm -fr master shard? *.log pg_worker_list.conf
7+
for ((i=1;i<=n_shards;i++))
8+
do
9+
port=$((5432+i))
10+
echo "localhost $port" >> pg_worker_list.conf
11+
initdb shard$i
12+
done
13+
initdb master
14+
cp pg_worker_list.conf master
15+
16+
echo Start shards
17+
18+
for ((i=1;i<=n_shards;i++))
19+
do
20+
port=$((5432+i))
21+
sed "s/5432/$port/g" < postgresql.conf.fdw > shard$i/postgresql.conf
22+
echo "shared_preload_libraries = 'pg_tsdtm'" >> shard$i/postgresql.conf
23+
pg_ctl -D shard$i -l shard$i.log start
24+
done
25+
26+
echo Start master
27+
cp postgresql.conf.fdw master/postgresql.conf
28+
echo "shared_preload_libraries = 'pg_pathman'" >> master/postgresql.conf
29+
pg_ctl -D master -l master.log start
30+
31+
sleep 5
32+
33+
user=`whoami`
34+
psql postgres -c "CREATE EXTENSION postgres_fdw"
35+
psql postgres -c "CREATE EXTENSION pg_pathman"
36+
psql postgres -c "CREATE TABLE t(u integer primary key, v integer)"
37+
38+
for ((i=1;i<=n_shards;i++))
39+
do
40+
port=$((5432+i))
41+
psql -p $port postgres -c "CREATE EXTENSION pg_tsdtm"
42+
psql -p $port postgres -c "CREATE TABLE t(u integer primary key, v integer)"
43+
44+
psql postgres -c "CREATE SERVER shard$i TYPE 'shardman' FOREIGN DATA WRAPPER postgres_fdw options(dbname 'postgres', host 'localhost', port '$port')"
45+
psql postgres -c "CREATE USER MAPPING for $user SERVER shard$i options (user '$user')"
46+
done
47+
48+
psql postgres -c "select create_shards('t', 'u', 10, 'shardman')"

0 commit comments

Comments
 (0)