用Bacurdo 搭pgsql的双主(多主)

一、前言

本PostgreSQL数据库双活部署实例使用Bucardo开源工具实现,Bucardo开源工具是一个perl语言编写的程序,其依赖PG数据库的plperl语言组件,进而严格依赖perl的版本(数据库服务器安装的perl大版本号必须和官方说明的perl版本严格一致,小版本号不限制)

二、安装bucardo

1.安装DBI

wget http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.630.tar.gz
tar zxvf DBI-1.634.tar.gz
cd DBI-1.634
perl Makefile.PL
make && make install

2.安装DBD

wget https://www.cpan.org/authors/id/T/TU/TURNSTEP/DBD-Pg-3.8.0.tar.gz
tar -zxvf DBD-Pg-3.8.0.tar.gz
cd DBD-Pg-3.8.0
perl Makefile.PL
make && make install

3.安装DBIx-Safe

wget http://bucardo.org/downloads/dbix_safe.tar.gz  
tar -zxvf dbix_safe.tar.gz
cd DBIx_safe.tar.gz
perl Makefile.PL
make && make install

4.安装bucardo

wget http://bucardo.org/downloads/Bucardo-5.4.1.tar.gz
tar -zxcv Bucardo-5.4.1.tar.gz
cd Bucardo-5.4.1
perl Makefile.PL
make && make install

5.初始化bucardo

cd Bucardo-5.4.1
./bucardo install -h 127.0.0.1 -p 5432 -U postgres -d postgres

#会出现
Current connection settings:
1. Host:           127.0.0.1
2. Port:           5432
3. User:           postgres
4. Database:       postgres
5. PID directory:  /home/postgres/run
Enter a number to change it, P to proceed, or Q to quit: P
#输入P 
Postgres version is: 9.5
Attempting to create and populate the bucardo database and schema
Database creation is complete

Updated configuration setting "piddir"
Installation is now complete.
If you see errors or need help, please email bucardo-general@bucardo.org

You may want to check over the configuration variables next, by running:
bucardo show all
Change any setting by using: bucardo set foo=bar
#出现以上的内容则是成功
#这一步可能会出一些问题 大部分都是没有安装好相应的依赖包导致的

6.配置

#这是bucardo5.0以上的安装过程  同步了两个数据库 postgres towall_1,可继续添加
#p1,p2 是别名 可自定义
#dbname是两台数据库的数据库名 可继续添加第三个第四个。。。
#port是两台机子pgsql端口号
#host是两台机子的ip
#后面-h -p -U是本机pgsql 的ip,端口,用户名  可先不加 出错则需要加上
./bucardo add dbs p1,p2 dbname=postgres,postgres port=5432,5432 host=127.0.0.1,172.16.70.76  -h 127.0.0.1 -p 5432 -U vdcsuper
./bucardo add dbs t1,t2 dbname=towall_1,towall_1 port=5543,5543 host=127.0.0.1,172.16.70.76   -h 127.0.0.1 -p 5432 -U vdcsuper
  #添加同步
  #sync_postgres 同步的名字 自定义
  #dbs要对应上面的
  #table可指定某几张表,这里选择的是全部
./bucardo add sync sync_postgres dbs=p1:source,p2:source tables=all -h 127.0.0.1 -p 5432 -U vdcsuper
./bucardo add sync sync_towall_1 dbs=t1:source,t2:source tables=all -h 127.0.0.1 -p 5432 -U vdcsuper

7启动

#启动
./bucardo start -h 127.0.0.1 -p 5432 -U vdcsuper
#查看状态
./bucardo status -h 127.0.0.1 -p 5432 -U vdcsuper
#重启
./bucardo restart -h 127.0.0.1 -p 5432 -U vdcsuper
#暂停
./bucardo stop -h 127.0.0.1 -p 5432 -U vdcsuper
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值