[pgsql]pgq主从同步实例

1、从crm复制到test_crm
数据库
crm – master
test_crm – slave

vim crm.ini
[londiste3]
job_name = l3_crm
db = host=192.168.232.234 port=5432 user=dev password=dev dbname=crm
queue_name = replika
logfile = /usr/local/skytools/londiste3/log/l3_crm.log
pidfile = /usr/local/skytools/londiste3/pid/l3_crm.pid

vim crm-gp.ini
[londiste3]
job_name = l3_gp
db = host=192.168.232.234 port=5432 user=dev password=dev dbname=test_crm
queue_name = replika
logfile = /usr/local/skytools/londiste3/log/l3_gp.log
pidfile = /usr/local/skytools/londiste3/pid/l3_gp.pid

vim pgqd-crm.ini
[pgqd]
database_list = crm,trade,test_crm
logfile = /usr/local/skytools/londiste3/log/pgqd.log
pidfile = /usr/local/skytools/londiste3/pid/pgqd.pid
#master
#创建provider进程配置文件
/usr/local/skytools/bin/londiste3 crm.ini create-root node1 ‘host=192.168.1.121 port=5432 user=dev password=dev dbname=crm’

#启动worker
/usr/local/skytools/bin/londiste3 -d /usr/local/skytools/londiste3/crm.ini worker

#启动ticker daemon
/usr/local/skytools/bin/pgqd -d /usr/local/skytools/londiste3/pgqd-crm.ini

#slave
/usr/local/skytools/bin/londiste3 crm-gp.ini create-leaf node2 ‘host=192.168.1.121 port=5432 user=dev password=dev dbname=test_crm’ –provider=’host=192.168.1.121 port=5432 user=dev password=dev dbname=crm’

#启动worker
/usr/local/skytools/bin/londiste3 -d /usr/local/skytools/londiste3/crm-gp.ini worker
/usr/local/skytools/bin/londiste3 crm-gp.ini status
/usr/local/skytools/bin/londiste3 crm-gp.ini members
/usr/local/skytools/bin/londiste3 crm.ini add-table public.active
/usr/local/skytools/bin/londiste3 crm.ini add-table public.active_blacklist
/usr/local/skytools/bin/londiste3 crm.ini add-table public.active_status
/usr/local/skytools/bin/londiste3 crm.ini tables

/usr/local/skytools/bin/londiste3 crm-gp.ini add-table public.active
/usr/local/skytools/bin/londiste3 crm-gp.ini add-table public.active_blacklist
/usr/local/skytools/bin/londiste3 crm-gp.ini add-table public.active_status
/usr/local/skytools/bin/londiste3 crm-gp.ini tables

新加入表时,查看表
public.active_status in-copy
新加入表时,查看进程
/usr/local/python27/bin/python2 /usr/local/skytools/bin/londiste3 crm-gp.ini copy public.active_status -d
2、从trade复制到test_crm
数据库
trade – master
test_crm – slave

vim trade.ini
[londiste3]
job_name = l3_trade
db = host=192.168.1.121 port=5432 user=dev password=dev dbname=trade
queue_name = replika-trade
logfile = /usr/local/skytools/londiste3/log/l3_trade.log
pidfile = /usr/local/skytools/londiste3/pid/l3_trade.pid

vim trade-gp.ini
[londiste3]
job_name = l3_gp_trade
db = host=192.168.1.121 port=5432 user=dev password=dev dbname=test_crm
queue_name = replika-trade
logfile = /usr/local/skytools/londiste3/log/l3_gp_trade.log
pidfile = /usr/local/skytools/londiste3/pid/l3_gp_trade.pid

vim pgqd-trade.ini
[pgqd]
database_list = trade,test_crm
logfile = /usr/local/skytools/londiste3/log/pgqd-trade.log
pidfile = /usr/local/skytools/londiste3/pid/pgqd-trade.pid
#master
#创建provider进程配置文件
/usr/local/skytools/bin/londiste3 trade.ini create-root node3 ‘host=192.168.1.121 port=5432 user=dev password=dev dbname=trade’

删除节点
/usr/local/skytools/bin/londiste3 trade.ini drop-node node3

#启动worker
/usr/local/skytools/bin/londiste3 -d trade.ini worker
#启动ticker daemon
/usr/local/skytools/bin/pgqd -d pgqd-trade.ini

#slave
/usr/local/skytools/bin/londiste3 trade-gp.ini create-leaf node4 ‘host=192.168.1.121 port=5432 user=dev password=dev dbname=test_crm’ –provider=’host=192.168.1.121 port=5432 user=dev password=dev dbname=trade’

#启动worker
/usr/local/skytools/bin/londiste3 -d trade-gp.ini worker
/usr/local/skytools/bin/londiste3 trade-gp.ini status
/usr/local/skytools/bin/londiste3 trade-gp.ini members
/usr/local/skytools/bin/londiste3 trade.ini add-table trade.area
/usr/local/skytools/bin/londiste3 trade.ini add-table trade.blacklist
/usr/local/skytools/bin/londiste3 trade.ini tables

/usr/local/skytools/bin/londiste3 trade-gp.ini add-table trade.area
/usr/local/skytools/bin/londiste3 trade-gp.ini add-table trade.blacklist
/usr/local/skytools/bin/londiste3 trade-gp.ini tables

新加入表时
/usr/local/python27/bin/python2 /usr/local/skytools/bin/londiste3 trade-gp.ini copy trade.blacklist -d

发表评论

电子邮件地址不会被公开。 必填项已用*标注