OS
Centos 5
Postgresql 9.1 compiled from source
The postgres user account exists on both machines and has a ssh passwordless key to connect to both machines.
我当前的设置:
主服务器配置:
postgresql.conf中:
listen_address = '*' wal_level = hot_standby max_wal_senders = 3 checkpoint_segments = 16 wal_keep_segments = 8 archive_mode = on archive_command = 'cp "%p" /opt/pgsql91/archive/"%f"'
pg_hba.conf的:
host replication all 10.0.66.1/32 trust host replication all 10.0.66.2/32 trust
备用服务器
postgresql.conf和pg_hba.conf与主服务器上配置的相同.
的recovery.conf:
standby_mode = 'on' primary_conninfo = 'host=10.0.66.1' trigger_file = '/opt/pgsql91/data/trigger.txt'
感谢hzRoot,我现在了解如何将服务器从待机切换到主服务器.
使用以下命令,我可以将新从服务器与新主服务器同步,然后进行复制备份和运行.
在新的主人(10.0.66.2)
> su – postgres
>触摸/ opt / pgsql91 / data /中的trigger.txt
> recovery.conf成为recovery.done
> psql -c“; SELECT pg_start_backup(‘backup’,true)”;
> rsync -a -v -e ssh / opt / pgsql91 / data / 10.0.66.1:/opt/pgsql91/data/ –exclude postmaster.pid
> psql -c“; SELECT pg_stop_backup()”;
在新奴隶上(10.0.66.1)
>创建recovery.conf:cp recovery.done到recovery.conf
> vi recovery.conf更改IP地址:primary_conninfo =’host = 10.0.66.2′
>启动postgresql
所以现在我的问题是:
>这是切换角色的正确方法吗?
>有没有人自动化这个过程,如果是这样,你做了什么?
>如果启用了同步复制,我注意到新的主服务器不会提交任何事务,因为它正在等待从服务器响应.然而,没有奴隶,因为另一台服务器,旧主机已关闭.这是正确的还是我需要在新的从服务器关闭时暂时禁用同步复制?
repmgr is a set of open source tools that helps DBAs and System
administrators manage a cluster of Postgresql databases..By taking advantage of the Hot Standby capability introduced in
Postgresql 9,repmgr greatly simplifies the process of setting up and
managing database with high availability and scalability requirements.repmgr simplifies administration and daily management,enhances
productivity and reduces the overall costs of a Postgresql cluster by:
- monitoring the replication process; allowing DBAs to issue high
- availability operations such as switch-overs and fail-overs.
它做了两件事:
> repmgr:在群集上执行任务然后退出的命令程序
> repmgrd:监视集群的管理和监视守护程序,可以自动执行远程操作.
对于自动故障转移,repmgrd可以解决这个问题,而不是网络中的SPOF,比如pgPool.但是,监控所有守护程序并在故障后恢复它们仍然很重要.
2.0版即将发布,包括RPM.