Skip to content

Commit c6f62e2

Browse files
committed
reinit
1 parent 04e3530 commit c6f62e2

File tree

1 file changed

+73
-19
lines changed

1 file changed

+73
-19
lines changed

reinit.sh

Lines changed: 73 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,96 @@ reinit_master() {
1919
echo "max_worker_processes = 10" >> ./install/data/postgresql.conf
2020
echo "shared_preload_libraries = 'pglogical'" >> ./install/data/postgresql.conf
2121
echo "track_commit_timestamp = on" >> ./install/data/postgresql.conf
22+
# echo "client_min_messages = debug3" >> ./install/data/postgresql.conf
23+
# echo "log_min_messages = debug3" >> ./install/data/postgresql.conf
2224

2325
echo '' > ./install/data/logfile
2426

2527
echo 'local replication stas trust' >> ./install/data/pg_hba.conf
2628

2729
./install/bin/pg_ctl -sw -D ./install/data -l ./install/data/logfile start
2830
./install/bin/createdb stas
29-
./install/bin/psql -c "create table t(id int);"
30-
./install/bin/psql -c "SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'pglogical_output');"
31-
./install/bin/psql <<SQL
32-
begin;
33-
insert into t values (42);
34-
prepare transaction 'x';
35-
commit prepared 'x';
36-
SQL
31+
./install/bin/psql -c "create table t(id int primary key, v int);"
32+
# ./install/bin/psql -c "SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'pglogical_output');"
33+
# ./install/bin/psql <<SQL
34+
# begin;
35+
# insert into t values (42);
36+
# prepare transaction 'x';
37+
# commit prepared 'x';
38+
# SQL
3739
}
3840

39-
reinit_slave() {
40-
rm -rf install/data_slave
41-
42-
./install/bin/pg_basebackup -D ./install/data_slave/ -R
43-
44-
echo "port = 5433" >> ./install/data_slave/postgresql.conf
45-
echo "hot_standby = on" >> ./install/data_slave/postgresql.conf
46-
47-
echo '' > ./install/data_slave/logfile
48-
49-
./install/bin/pg_ctl -sw -D ./install/data_slave -l ./install/data_slave/logfile start
41+
reinit_master2() {
42+
rm -rf install/data2
43+
44+
./install/bin/initdb -A trust -D ./install/data2
45+
46+
echo "port = 5433" >> ./install/data2/postgresql.conf
47+
48+
echo "max_prepared_transactions = 100" >> ./install/data2/postgresql.conf
49+
echo "shared_buffers = 512MB" >> ./install/data2/postgresql.conf
50+
echo "fsync = off" >> ./install/data2/postgresql.conf
51+
echo "log_checkpoints = on" >> ./install/data2/postgresql.conf
52+
echo "max_wal_size = 48MB" >> ./install/data2/postgresql.conf
53+
echo "min_wal_size = 32MB" >> ./install/data2/postgresql.conf
54+
echo "wal_level = logical" >> ./install/data2/postgresql.conf
55+
echo "wal_keep_segments = 64" >> ./install/data2/postgresql.conf
56+
echo "max_wal_senders = 10" >> ./install/data2/postgresql.conf
57+
echo "max_replication_slots = 10" >> ./install/data2/postgresql.conf
58+
59+
echo "max_worker_processes = 10" >> ./install/data2/postgresql.conf
60+
echo "shared_preload_libraries = 'pglogical'" >> ./install/data2/postgresql.conf
61+
echo "track_commit_timestamp = on" >> ./install/data2/postgresql.conf
62+
63+
# echo "client_min_messages = debug3" >> ./install/data2/postgresql.conf
64+
# echo "log_min_messages = debug3" >> ./install/data2/postgresql.conf
65+
66+
echo '' > ./install/data2/logfile
67+
68+
echo 'local replication stas trust' >> ./install/data2/pg_hba.conf
69+
70+
./install/bin/pg_ctl -sw -D ./install/data2 -l ./install/data2/logfile start
71+
./install/bin/createdb stas -p5433
72+
# ./install/bin/psql -c "create table t(id int primary key, v int);" -p5433
73+
# ./install/bin/psql -c "SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'pglogical_output');"
74+
# ./install/bin/psql <<SQL
75+
# begin;
76+
# insert into t values (42);
77+
# prepare transaction 'x';
78+
# commit prepared 'x';
79+
# SQL
5080
}
5181

5282
make install > /dev/null
5383

84+
cd contrib/pglogical
85+
make clean && make install
86+
cd ../..
5487

5588
pkill -9 postgres
5689
reinit_master
90+
reinit_master2
91+
92+
./install/bin/psql <<SQL
93+
CREATE EXTENSION pglogical;
94+
SELECT pglogical.create_node(
95+
node_name := 'provider1',
96+
dsn := 'port=5432 dbname=stas'
97+
);
98+
SELECT pglogical.replication_set_add_all_tables('default', ARRAY['public']);
99+
SQL
57100

101+
./install/bin/psql -p 5433 <<SQL
102+
CREATE EXTENSION pglogical;
103+
SELECT pglogical.create_node(
104+
node_name := 'subscriber1',
105+
dsn := 'port=5433 dbname=stas'
106+
);
107+
SELECT pglogical.create_subscription(
108+
subscription_name := 'subscription1',
109+
provider_dsn := 'port=5432 dbname=stas'
110+
);
111+
SQL
58112

59113

60114
# SELECT * FROM pg_logical_slot_peek_changes('regression_slot',

0 commit comments

Comments
 (0)