技术开发 频道

postgreSQL通过skytools主从复制实现

  配置主从:

  主服务器配置

  进入主数据库服务器的../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*)

0
相关文章