postgresql通过skytools实现主从复制

系统环境:centos5.4 64bit
postgresql版本:8.4
psycopg2版本:2.4.1
skytools版本:2.1.12

1.安装postgresql
安装包==>postgresql-8.4.5-1-linux-x64.bin
在主从服务器上各自安装postgresql
修改*/PostgreSQL/8.4/data/pg_hba.conf文件,将主从服务器ip都设为trust
重新启动postgresql
2.更新python-devel
升级包==>python-2.4.3-44.el5.x86_64.rpm、python-libs-2.4.3-44.el5.x86_64.rpm、python-devel-2.4.3-44.el5.i386.rpm、python-devel-2.4.3-44.el5.x86_64.rpm
#rpm -U python-2.4.3-44.el5.x86_64.rpm -i python-libs-2.4.3-44.el5.x86_64.rpm -i python-devel-2.4.3-44.el5.i386.rpm -i python-devel-2.4.3-44.el5.x86_64.rpm
3.更新postgresql-devel至8.4
升级包==>postgresql-libs-8.4.8-1PGDG.rhel5.x86_64.rpm、postgresql-8.4.8-1PGDG.rhel5.x86_64.rpm、postgresql-devel-8.4.8-1PGDG.rhel5.x86_64.rpm
#rpm -i postgresql-libs-8.4.8-1PGDG.rhel5.x86_64.rpm -i postgresql-8.4.8-1PGDG.rhel5.x86_64.rpm -i postgresql-devel-8.4.8-1PGDG.rhel5.x86_64.rpm
4.安装psycopg2
安装包==>psycopg2-2.4.1.tar.gz
#tar -zxvf psycopg2-2.4.1.tar.gz
#cd psycopg2-2.4.1
#vi setup.cfg ==>找到# pg_config= 改为 pg_config=数据库路径/PostgreSQL/8.4/bin/pg_config
#python setup.py build_ext
#python setup.py install
5.安装skytools
安装包==>skytools-2.1.12.tar.gz
#vi ~/.bash_profile
在PATH=$PATH:$HOME/bin行下添加
PATH=$PATH:数据库路径/PostgreSQL/8.4/bin
保存后运行source ~/.bash_profile

#tar -zxvf skytools-2.1.12.tar.gz
#cd skytools-2.1.12
#./configure --with-pgconfig=数据库路径/PostgreSQL/8.4/bin/pg_config
#make
#make install
#python setup.py install
配置主从:
主服务器配置
进入主数据库服务器的../skytools-2.1.7/tests/londiste/conf目录,添加文件ticker_test.ini,文件内容:
 [pgqadm]

 job_name = ticker_test

 db = dbname=数据库名称 host=数据库ip地址 port=数据库端口 user=postgres

 # how often to run maintenance [minutes]
 maint_delay_min = 60

 # how often to check for activity [secs]
 loop_delay = 0.5

 logfile = /usr/local/pgsqllog/log.%(job_name)s
 pidfile = /usr/local/pgsqllog/pid.%(job_name)s

 use_skylog = 0

 connection_lifetime = 21

 queue_refresh_period = 10
安装ticker
#pgqadm.py ticker_service.ini install
#pgqadm.py ticker_service.ini ticker -d

从服务器配置
进入从数据库服务器的../skytools-2.1.7/tests/londiste/conf目录,添加文件replic_test_1.ini,文件内容:
 [londiste]
 job_name = replic_test_1

 provider_db = dbname=数据库名称 host=主数据库ip地址 port=数据库端口 user=postgres password=数据库密码
 subscriber_db = dbname=数据库名称 host=从数据库ip地址 port=数据库端口 user=postgres password=数据库密码

 # it will be used as sql ident so no dots/spaces
 pgq_queue_name = londiste_1_replic

 logfile = /usr/local/pgsqllog/log.%(job_name)s
 pidfile = /usr/local/pgsqllog/pid.%(job_name)s

 loop_delay = 0.5

 connection_lifetime = 30
安装londiste
#londiste.py replic_test_1.ini provider install
#londiste.py replic_test_1.ini subscriber install
启用replay
#londiste.py replic_test_1.ini replay -d
添加要复制的表
#londiste.py replic_test_1.ini provider add 需要主从复制的表名(可用*号例如:xw*)
#londiste.py replic_test_1.ini subscriber add 需要主从复制的表名(可用*号例如:xw*)

你可能感兴趣的:(PostgreSQL,主从,skytools,psycopg2)