forked from keenser/bdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.bdr
63 lines (46 loc) · 2.21 KB
/
README.bdr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
See http://2ndquadrant.com/BDR and http://bdr-project.org/docs/ for
documentation on the installation and use of BDR.
BDR2 with postgresql 11 patches
See INSTALL.src for compile from source.
Install pkg:
Add https://github.com/keenser/repo repo:
```
sudo apt-key adv --fetch-keys https://raw.githubusercontent.com/keenser/repo/master/PUBLIC.KEY
echo 'deb http://keenser.github.io/repo stretch main' | sudo tee -a /etc/apt/sources.list.d/keenser.list
sudo apt update
sudo apt install postgresql-11 postgresql-11-bdr-pluglin
```
Sample usage:
```
#backup database before cluster drop if exists:
/usr/lib/postgresql/11/bin/bdr_dump -p 5434 -N bdr radius > backup.sql
pg_dropcluster 11 node1 --stop
pg_dropcluster 11 node2 --stop
rm -r /etc/postgresql/11/node1/conf.d/
rm -r /etc/postgresql/11/node2/conf.d/
pg_createcluster 11 node1
pg_createcluster 11 node2
pg_ctlcluster 11 node1 start
pg_ctlcluster 11 node2 start
psql -p 5434 -c 'create database radius'
psql -p 5435 -c 'create database radius'
cat <<EOF | tee /etc/postgresql/11/node1/conf.d/bdr.conf /etc/postgresql/11/node2/conf.d/bdr.conf
shared_preload_libraries = 'bdr'
bdr.trace_replay = on
wal_level = 'logical'
track_commit_timestamp = on
max_replication_slots = 20
max_wal_senders = 10
EOF
pg_ctlcluster 11 node1 restart
pg_ctlcluster 11 node2 restart
psql -p 5434 radius -c 'create extension bdr cascade' -c "SELECT bdr.bdr_group_create(local_node_name := 'node1', node_external_dsn := 'dbname=radius port=5434')" -c 'select bdr.bdr_node_join_wait_for_ready()'
psql -p 5435 radius -c 'create extension bdr cascade' -c "SELECT bdr.bdr_group_join(local_node_name := 'node2', node_external_dsn := 'dbname=radius port=5435', join_using_dsn := 'dbname=radius port=5434')" -c 'select bdr.bdr_node_join_wait_for_ready()'
#restore if any backup
psql -p 5434 radius -1 -f backup.sql
psql -p 5434 radius -c "CREATE TABLE IF NOT EXISTS test (id bigserial, name text)" -c "ALTER TABLE test ALTER COLUMN id SET DEFAULT bdr.global_seq_nextval('test_id_seq'::regclass)"
psql -p 5434 radius -c "insert into test(name) values('foo')"
psql -p 5435 radius -c "insert into test(name) values('bar')"
psql -p 5434 radius -c 'select count(*) from test'
psql -p 5435 radius -c 'select count(*) from test'
```