10.0.3.21
node2
10.0.3.22
Öncelikle varsa eski kurulumu kaldırıyoruz.
yum remove postgresql94\*
rm -rf /var/lib/pgsql/
BDR reposunu ekleyelim
yum install http://packages.2ndquadrant.com/postgresql-bdr94-2ndquadrant/yum-repo-rpms/postgresql-bdr94-2ndquadrant-redhat-1.0-2.noarch.rpmKurulum
yum install postgresql-bdr94-bdrpg_hba.conf dosyasına eklenmesi gerekenler
su - postgres
PGDATA=/var/lib/pgsql/9.4-bdr/data PGENGINE=/usr/pgsql-9.4/bin /usr/pgsql-9.4/bin/postgresql94-setup initdb
host all all 127.0.0.1/32 trustpostgresql.conf dosyasına eklenmesi gerekenler
host all all 10.0.3.0/24 trust
local replication postgres trust
host replication postgres 127.0.0.1/32 trust
host replication postgres 10.0.3.0/24 trust
host replication postgres ::1/128 trust
listen_addresses = '*'
shared_preload_libraries = 'bdr'
wal_level = 'logical'
track_commit_timestamp = on
max_connections = 100
max_wal_senders = 10
max_replication_slots = 10
max_worker_processes = 10
# /etc/init.d/postgresql-9.4 restart
db yi oluşturup BDR ayarlarını yapalım
Node 1
createdb -U postgres testdb
psql -U postgres testdb
testdb=# CREATE EXTENSION btree_gist;
testdb=# CREATE EXTENSION bdr;
testdb=# SELECT bdr.bdr_group_create(
local_node_name := 'node1',
node_external_dsn := 'host=10.0.3.21 port=5432 dbname=testdb'
);
testdb=# SELECT bdr.bdr_node_join_wait_for_ready();
Node 2
createdb -U postgres testdb
psql -U postgres testdb
testdb=# CREATE EXTENSION btree_gist;
testdb=# CREATE EXTENSION bdr;
testdb=# SELECT bdr.bdr_group_join(
local_node_name := 'node2',
node_external_dsn := 'host=10.0.3.22 port=5432 dbname=testdb',
join_using_dsn := 'host=10.0.3.21 port=5432 dbname=testdb'
);
testdb=# SELECT bdr.bdr_node_join_wait_for_ready();
TEST
Node 1
CREATE TABLE t1bdr (c1 INT, PRIMARY KEY (c1));
INSERT INTO t1bdr VALUES (1);
INSERT INTO t1bdr VALUES (2);
SELECT * FROM t1bdr;
Node 1
SELECT * FROM t1bdr;