Skip to content

keenser/bdr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'
```

About

bdr pg 11

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published