hillpig的个人博客分享 http://blog.sciencenet.cn/u/hillpig 畅想ing,思考ing,前行ing Email:bluevaley@gmail.com

博文

PostgreSQL9.1 Warm-Standby ---之基于同步复制的方法

已有 11988 次阅读 2012-2-24 14:38 |个人分类:postgresql|系统分类:科研笔记| Warm-Standby, 之基于流复制的方法

本教程是PostgreSQL Cluster系列教程的一部分,该系列包括:

  1. PostgreSQL9.1 PITR示例  (该教程主要阐述DBA如何基于WAL日志做备份恢复)

  2. PostgreSQL9.1 Warm-Standby ---之基于拷贝WAL文件的方法        (file-based log shipping)

  3. PostgreSQL9.1 Warm-Standby ---之基于流复制的方法 (streaming        replication)

  4. PostgreSQL9.1 Warm-Standby ---之基于同步复制的方法 (Synchronous Replication)

  5. PostgreSQL9.1 Hot-Standby ---之基于拷贝WAL文件的方法

  6. PostgreSQL9.1 Hot-Standby ---之基于流复制的方法

  7. PostgreSQL9.1 Hot-Standby ---之基于同步复制的方法

  8. PG9.1+pgpool-II3.1--之HA (Hot-Standby+Streaming Replication)

  9. PG9.1+pgpool-II3.1--之Load Balancing (when meeting large amounts of requests)

  10. PG9.1+pgpool-II3.1--之Parallel Query (when meeting large amounts of data)

  11. PostgreSQL9.1 HA --- 之Slony

好了,有了第3个PostgreSQL9.1 Warm-Standby ---之基于流复制的方法 (streaming        replication)教程,我们配置同步复制就非常简单了。
根据25.2.6.1. Basic Configuration,我们只需要配置  synchronous_standby_names参数就可以了。

只需要修改两个地方:
A.即在“2. 配置Master,并做一次base backup“中:
编辑 postgresql.conf 以支持 WAL archiving:
wal_level = archive
archive_mode = on
archive_command = 'cp %p /home/postgres/archive/%f'
max_wal_senders = 1

里增加配置:
synchronous_standby_names = 'mydb_standby1'

以及B. 在“3.配置Warm-standby,并启动”中:
然后编辑recovery.conf里修改primary_conninfo 配置为:
standby_mode = on
restore_command = 'cp /home/postgres/archive/%f %p'

primary_conninfo = 'host=127.0.0.1 port=5432 user=repluser password=pwd_repluser application_name=mydb_standby1'
trigger_file = '/home/postgres/trigger/pgsql.trigger.6432'

就可以了。
关于synchronous_standby_names参数,根据http://www.postgresql.org/docs/9.1/interactive/runtime-config-replication.html#GUC-SYNCHRONOUS-STANDBY-NAMES 里的一段话:
At any one time there will be at most one          active synchronous standby; transactions waiting for          commit will be allowed to proceed after this standby          server confirms receipt of their data. The synchronous          standby will be the first standby named in this list that          is both currently connected and streaming data in          real-time (as shown by a state of streaming in the  pg_stat_replication view).
知道只有一个standby可以作为同步复制的对象。

至此完毕。
参考:
[1] Postgres 9.1: Setup a synchronous stand-by server in 5 minutes
[2] PostgreSQL9.1新特性之五:同步复制 ( Synchronous replication )
[3] 这个一定要看:Virtual IP Addresses and Their Discontents for Database Availability
[4] PITR, Warm Standby, Hot Standby, and Streaming Replication
[5] How To Set Up A Postgresql 9.0 Hot Standby Streaming Replication Server With Repmgr On OpenSUSE 11.4
[6] Definitions of PostgreSQL's Warm Standby, Hot Standby, WAL shipping and Streaming Replication
[7] PostgreSQL9.0 HA 双机热备配置


加我私人微信,交流技术。




https://blog.sciencenet.cn/blog-419883-540919.html

上一篇:PostgreSQL9.1 Warm-Standby ---之基于流复制的方法
下一篇:如何查询所有表的所占空间的大小
收藏 IP: 223.72.72.*| 热度|

1 金小伟

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-6 22:21

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部