{"id":41615,"date":"2023-07-22T16:43:39","date_gmt":"2022-11-20T04:02:13","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/"},"modified":"2024-04-30T14:51:53","modified_gmt":"2024-04-30T06:51:53","slug":"%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/","title":{"rendered":"\u901a\u8fc7repmgr\u5b9e\u73b0PostgreSQL\u7684\u96c6\u7fa4\u5316"},"content":{"rendered":"<p>\u56e0\u70ba\u6c92\u6709\u592a\u591a\u4eba\u4ecb\u7d39\uff0c\u6211\u5f88\u60f3\u8a66\u8a66\u770b\u5b83\u662f\u600e\u9ebc\u6a23\u7684\uff0c\u6240\u4ee5\u6211\u81ea\u5df1\u5617\u8a66\u64cd\u4f5c\u4e86\u4e00\u4e0b\u3002<\/p>\n<h1>repmgr\u6982\u89c8<\/h1>\n<p>repmgr\u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u4e8e\u6267\u884c\u4ee5\u4e0b\u7ba1\u7406\u4efb\u52a1\uff0c\u5e76\u7528\u4f5c\u5c06PostgreSQL\u7528\u4f5c\u9ad8\u53ef\u7528\u6027\u96c6\u7fa4\u7684\u5de5\u5177\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30b9\u30bf\u30f3\u30d0\u30a4\u30b5\u30fc\u30d0\u306e\u8a2d\u5b9a<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30b9\u30bf\u30f3\u30d0\u30a4\u30b5\u30fc\u30d0\u306e\u6607\u683c<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30b9\u30a4\u30c3\u30c1\u30aa\u30fc\u30d0<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30af\u30e9\u30b9\u30bf\u306e\u30b5\u30fc\u30d0\u30b9\u30c6\u30fc\u30bf\u30b9<\/ul>\n<p>repmgr\u662f\u75312ndQuadrant\u516c\u53f8\u5f00\u53d1\u7684\uff0c\u5e76\u5728GitHub\u4e0a\u53d1\u5e03\u3002<\/p>\n<h1>\u4f7f\u7528repmgr\u8fdb\u884cPostgreSQL\u96c6\u7fa4\u6784\u5efa\u7684\u6b65\u9aa4\u3002<\/h1>\n<h2>\u524d\u63d0\u6761\u4ef6\u548c\u73af\u5883\u5efa\u8bbe<\/h2>\n<p>\u672c\u6b21\u5c06\u5728VirtualBox\u4e0aCentOS7\u548cPostgreSQL 9.5.2\u7684\u73af\u5883\u4e0b\u8fdb\u884c\u64cd\u4f5c\u3002<br \/>\n\u8bf7\u5148\u51c6\u5907\u597d\u5b89\u88c5\u4e86PostgreSQL\uff08\u6e90\u4ee3\u7801\u7f16\u8bd1\u7248\uff09\u7684\u4e24\u53f0\u865a\u62df\u673a\u3002<br \/>\n\u203b\u672c\u4e66\u5c06\u7701\u7565\u5bf9\u4e8ePostgreSQL\u5b89\u88c5\u65b9\u6cd5\u548cSSH\u8bbe\u7f6e\u7b49\u7684\u8bf4\u660e\u3002<br \/>\n\u5728\u540e\u534a\u90e8\u5206\uff0c\u5bf9\u4e8ePostgreSQL\u7684\u8bf4\u660e\u90e8\u5206\u4e5f\u4f1a\u7565\u8fc7\u8bb8\u591a\u5185\u5bb9\u3002<\/p>\n<p>\u5176\u4ed6\u689d\u4ef6<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">localhost\u3068\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u7d44\u3080\u5bfe\u8c61\u306e\u30ce\u30fc\u30c9\u9593\u3067\u306fssh\u304c\u30d1\u30b9\u7121\u3057\u3067\u901a\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u304a\u304f\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30de\u30b9\u30bf\u3001\u30b9\u30ec\u30fc\u30d6\u5074\u306e\u30ce\u30fc\u30c9\u3067\u306fPostgreSQL\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30de\u30b9\u30bf\u5074\u3067\u306finitdb\u3092\u5b9f\u884c\u6e08\u307f\u3002<\/ul>\n<p>\u987a\u4fbf\u63d0\u4e00\u4e0b\uff0c\u672c\u6b21\u8282\u70b9\u4e2d\u7684\/etc\/hosts\u5df2\u914d\u7f6e\u5982\u4e0b\u3002<\/p>\n<pre class=\"post-pre\"><code>192.168.1.1 neko\r\n192.168.1.2 inu\r\n<\/code><\/pre>\n<p>\u732b\uff1a\u6211\u4eec\u5c06\u7ee7\u7eed\u5efa\u8bbe\u4e3a\u4e3b\u8282\u70b9\uff0c\u72d7\uff1a\u4f5c\u4e3a\u5907\u7528\u8282\u70b9\u3002<\/p>\n<h2>2. \u4e0b\u8f7drepmgr\u6e90\u4ee3\u7801\u3002\uff08\u5728\u4e3b\u670d\u52a1\u5668\u548c\u5907\u670d\u52a1\u5668\u4e0a\u6267\u884c\uff09<\/h2>\n<p>\u5c3d\u7ba1PostgreSQL\u793e\u533a\u63d0\u4f9b\u4e86RPM\u5305\u7684\u4e0b\u8f7d\uff0c\u4f46\u6211\u4eec\u8fd8\u662f\u9009\u62e9\u6545\u610f\u4f7f\u7528\u6e90\u4ee3\u7801\u8fdb\u884c\u6784\u5efa\u3002<\/p>\n<p>\u53ef\u4ee5\u4ecerepmgr\u7684\u5b98\u65b9\u7f51\u7ad9\u6216GitHub\u4e0a\u4e0b\u8f7d\u6e90\u4ee3\u7801\u3002<\/p>\n<h2>3. \u6784\u5efa\u5df2\u4e0b\u8f7d\u7684repmgr\uff08\u5728\u4e3b\u8282\u70b9\u548c\u5907\u8282\u70b9\u4e0a\u6267\u884c\uff09\u3002<\/h2>\n<p>\u5c06\u901a\u8fc7tar.gz\u4e0b\u8f7d\u7684\u6587\u4ef6\u653e\u7f6e\u5728contrib\u76ee\u5f55\u4e0b\u5e76\u8fdb\u884c\u6784\u5efa\u3002<\/p>\n<pre class=\"post-pre\"><code>$ tar -xvf repmgr-3.1.2.tar.gz\r\n$ mv ~\/repmgr-3.1.2 ~\/postgresql-9.5.2\/contrib\/\r\n$ cd ~\/postgresql-9.5.2\/contrib\/repmgr-3.1.2\r\n$ make\r\n$ make install\r\n<\/code><\/pre>\n<h2>4. \u8fdb\u884crepmgr\u7684\u8bbe\u7f6e\uff08\u4ec5\u5728\u4e3b\u8282\u70b9\u6267\u884c\uff09<\/h2>\n<h3>\u521b\u5efarepmgr\u7684\u914d\u7f6e\u6587\u4ef6.<\/h3>\n<pre class=\"post-pre\"><code>$ vi ~\/local\/pg952\/pgsql\/etc\/repmgr.conf\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>cluster=test\r\nnode=1\r\nnode_name=neko\r\nconninfo='host=neko user=repmgr dbname=repmgr'\r\n<\/code><\/pre>\n<div>\n<div class=\"post-table\">\u9805\u76ee\u540d\u8aac\u660ecluster\u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\u30bf\u306e\u4efb\u610f\u306e\u540d\u524d\u3002\u203b\u3059\u3079\u3066\u306e\u30ce\u30fc\u30c9\u3067\u540c\u4e00\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059node\u8b58\u5225\u7528\u306e\u500b\u5225\u306e\u6574\u6570node_name\u30ce\u30fc\u30c9\u3092\u8b58\u5225\u3059\u308b\u6587\u5b57\u5217conninfo\u81ea\u8eab\u306erepmgrDB\u306b\u63a5\u7d9a\u53ef\u80fd\u306a\u63a5\u7d9a\u60c5\u5831<\/div>\n<\/div>\n<h3>\u542f\u52a8PostgreSQL<\/h3>\n<p>\u8bf7\u6309\u7167\u4ee5\u4e0b\u8bbe\u7f6e\u8fdb\u884c\u6700\u4f4e\u5fc5\u8981\u7684\u914d\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code>wal_level = 'hot_standby'\r\nmax_wal_senders = 10\r\nwal_keep_segments = 5000\r\nhot_standby = on\r\narchive_mode = on\r\narchive_command = '\/bin\/true'\r\n<\/code><\/pre>\n<p>\u6839\u636e\u6211\u7684\u5c1d\u8bd5\uff0c\u5f53wal_keep_segments\u7684\u503c\u8f83\u5c0f\u65f6\uff0crepmgr\u4f1a\u5bf9\u5176\u53d1\u51fa\u8d85\u8fc75000\u7684\u8b66\u544a\u3002<\/p>\n<pre class=\"post-pre\"><code>[2016-05-23 21:51:04] [NOTICE] destination directory '\/home\/ikki\/local\/pg952\/data' provided\r\n[2016-05-23 21:51:04] [ERROR] parameter 'wal_keep_segments' must be be set to 5000 or greater (see the '-w' option or edit the postgresql.conf of the upstream server.)\r\n[2016-05-23 21:51:04] [HINT] in PostgreSQL 9.4 and later, replication slots can be used, which do not require 'wal_keep_segments' to be set to a high value (set parameter 'use_replication_slots' in the configuration file to enable)\r\n<\/code><\/pre>\n<p>repmgr\u662f\u8d1f\u8d23\u7ba1\u7406WAL\u6587\u4ef6\u7684\u5417\uff1f\u7531\u4e8e\u672c\u6b21\u4e0d\u4f1a\u8fdb\u884c\u8be6\u7ec6\u8c03\u67e5\uff0c\u6240\u4ee5\u8fd9\u4e2a\u95ee\u9898\u4f1a\u8df3\u8fc7\uff0c\u4f46\u4e4b\u540e\u60f3\u8981\u4e86\u89e3\u5b83\u7684\u5de5\u4f5c\u673a\u5236\u3002<\/p>\n<h3>4-3. repmgr\u4e3a\u4e86\u7ba1\u7406\u96c6\u7fa4\u800c\u521b\u5efa\u7528\u6237\u548c\u6570\u636e\u5e93\u3002<\/h3>\n<pre class=\"post-pre\"><code>$createuser -s repmgr\r\n$createdb repmgr -O repmgr\r\n<\/code><\/pre>\n<h3>\u8fdb\u884cPostgreSQL\u8ba4\u8bc1\u8bbe\u7f6e\u3002<\/h3>\n<p>\u5728pg_hba.conf\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\u3002<\/p>\n<pre class=\"post-pre\"><code>local   replication   repmgr                              trust\r\nhost    replication   repmgr      127.0.0.1\/32            trust\r\nhost    replication   repmgr      192.168.1.0\/24          trust\r\n\r\nlocal   repmgr        repmgr                              trust\r\nhost    repmgr        repmgr      127.0.0.1\/32            trust\r\nhost    repmgr        repmgr      192.168.1.0\/24          trust\r\n<\/code><\/pre>\n<h3>\u8bbe\u7f6erepmgr\u7528\u6237\u7684\u641c\u7d22\u8def\u5f84\u3002<\/h3>\n<pre class=\"post-pre\"><code>$ psql repmgr -c 'ALTER ROLE repmgr SET search_path TO repmgr_test, \"$user\", public' -U repmgr\r\n<\/code><\/pre>\n<h3>4-6. \u91cd\u65b0\u542f\u52a8 PostgreSQL<\/h3>\n<p>\u4f7f\u7f16\u8f91\u8fc7\u7684pg_hba.conf\u6587\u4ef6\u751f\u6548<\/p>\n<pre class=\"post-pre\"><code>$ pg_ctl -D ~\/local\/pg952\/data restart\r\n<\/code><\/pre>\n<h2>5. \u5c06\u4e3b\u8282\u70b9\u6ce8\u518c\u5230repmgr\uff08\u4ec5\u5728\u4e3b\u8282\u70b9\u4e0a\u6267\u884c\uff09<\/h2>\n<p>\u5728\u4e3b\u8282\u70b9\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u8282\u70b9\u6ce8\u518c\u5230repmgr\u4e2d\u3002<\/p>\n<pre class=\"post-pre\"><code>$ repmgr -f ~\/local\/pg952\/pgsql\/etc\/repmgr.conf master register\r\n[2016-05-23 21:34:18] [NOTICE] master node correctly registered for cluster test with id 1 (conninfo: host=neko user=repmgr dbname=repmgr)\r\n<\/code><\/pre>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u786e\u8ba4\u5df2\u6ce8\u518c\u7684\u4fe1\u606f\u3002<\/p>\n<pre class=\"post-pre\"><code>$ psql repmgr -c 'SELECT * FROM repmgr_test.repl_nodes' -U repmgr -x\r\n-[ RECORD 1 ]----+------------------------------------\r\nid               | 1\r\ntype             | master\r\nupstream_node_id | \r\ncluster          | test\r\nname             | neko\r\nconninfo         | host=neko user=repmgr dbname=repmgr\r\nslot_name        | \r\npriority         | 100\r\nactive           | t\r\n<\/code><\/pre>\n<h2>\u521b\u5efa\u4e00\u4e2a\u5f85\u673a\u6570\u636e\u5e93\uff08\u4ec5\u652f\u6301\u5f85\u673a\u64cd\u4f5c\uff09\u3002<\/h2>\n<pre class=\"post-pre\"><code>$ repmgr -h neko -U repmgr -d repmgr -D ~\/local\/pg952\/data -f ~\/local\/pg952\/pgsql\/etc\/repmgr.conf standby clone\r\n[2016-05-23 21:52:55] [NOTICE] destination directory '\/home\/ikki\/local\/pg952\/data' provided\r\n[2016-05-23 21:52:55] [NOTICE] starting backup (using pg_basebackup)...\r\n[2016-05-23 21:52:55] [HINT] this may take some time; consider using the -c\/--fast-checkpoint option\r\nNOTICE:  pg_stop_backup complete, all required WAL segments have been archived\r\n[2016-05-23 21:53:07] [NOTICE] standby clone (using pg_basebackup) complete\r\n[2016-05-23 21:53:07] [NOTICE] you can now start your PostgreSQL server\r\n[2016-05-23 21:53:07] [HINT] for example : pg_ctl -D \/home\/ikki\/local\/pg952\/data start\r\n[2016-05-23 21:53:07] [HINT] After starting the server, you need to register this standby with \"repmgr standby register\"\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u9636\u6bb5\uff0c\u5c06\u521b\u5efa\u4ee5\u4e0b\u7684recover.conf\u6587\u4ef6\u7528\u4e8e\u5907\u7528\u8282\u70b9\u3002<\/p>\n<pre class=\"post-pre\"><code>standby_mode = 'on'\r\nprimary_conninfo = 'port=5432 host=neko user=repmgr application_name=inu'\r\nrecovery_target_timeline = 'latest'\r\n<\/code><\/pre>\n<h2>7. \u542f\u52a8PostgreSQL\uff08\u4ec5\u5728\u5907\u7528\u6a21\u5f0f\u4e0b\u6267\u884c\uff09<\/h2>\n<pre class=\"post-pre\"><code>$ pg_ctl -D ~\/local\/pg952\/data start\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>$ ps -ef |grep postgres\r\nikki      7790     1  0 19:04 pts\/0    00:00:00 \/home\/ikki\/local\/pg952\/pgsql\/bin\/postgres -D \/home\/ikki\/local\/pg952\/data\r\nikki      7794  7790  0 19:04 ?        00:00:00 postgres: logger process   \r\nikki      7795  7790  0 19:04 ?        00:00:00 postgres: startup process   recovering 00000001000000000000002D\r\nikki      7796  7790  2 19:04 ?        00:00:00 postgres: wal receiver process   streaming 0\/2D0001A0\r\nikki      7797  7790  0 19:04 ?        00:00:00 postgres: checkpointer process   \r\nikki      7798  7790  0 19:04 ?        00:00:00 postgres: writer process   \r\nikki      7799  7790  0 19:04 ?        00:00:00 postgres: stats collector process   \r\nikki      7812  2623  0 19:04 pts\/0    00:00:00 grep --color=auto postgres\r\n<\/code><\/pre>\n<p>\u67e5\u770b\u4e3b\u63a7\u7edf\u8ba1\u4fe1\u606f\u89c6\u56fe\u3002<\/p>\n<pre class=\"post-pre\"><code>$ psql -h neko repmgr -c 'SELECT * FROM pg_stat_replication' -U repmgr -x\r\n-[ RECORD 1 ]----+------------------------------\r\npid              | 8732\r\nusesysid         | 20997\r\nusename          | repmgr\r\napplication_name | inu\r\nclient_addr      | 192.168.1.2\r\nclient_hostname  | \r\nclient_port      | 49837\r\nbackend_start    | 2016-05-24 19:04:10.347144+09\r\nbackend_xmin     | \r\nstate            | streaming\r\nsent_location    | 0\/2D0001A0\r\nwrite_location   | 0\/2D0001A0\r\nflush_location   | 0\/2D0001A0\r\nreplay_location  | 0\/2D0001A0\r\nsync_priority    | 0\r\nsync_state       | async\r\n<\/code><\/pre>\n<h2>\u5c06\u542f\u52a8\u7684\u5f85\u673a\u72b6\u6001\u6ce8\u518c\u5230repmgr\u3002<\/h2>\n<p>\u5728\u5907\u7528\u670d\u52a1\u5668\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002<\/p>\n<pre class=\"post-pre\"><code>$ repmgr -f ~\/local\/pg952\/pgsql\/etc\/repmgr.conf standby register\r\n[2016-05-24 19:08:40] [NOTICE] standby node correctly registered for cluster test with id 2 (conninfo: host=inu user=repmgr dbname=repmgr)\r\n<\/code><\/pre>\n<p>\u4e3b\u4eba\uff0c\u60a8\u53ef\u4ee5\u5728\u5907\u7528\u670d\u52a1\u5668\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u786e\u8ba4\u662f\u5426\u5df2\u5b8c\u6210\u6ce8\u518c\u3002<br \/>\n\u8fd9\u5c06\u4f7f\u7528repmgr\u521b\u5efa\u4e00\u4e2a\u96c6\u7fa4\u3002<\/p>\n<pre class=\"post-pre\"><code>$ psql repmgr -c 'SELECT * FROM repmgr_test.repl_nodes' -U repmgr\r\n id |  type   | upstream_node_id | cluster | name |              conninfo       \r\n        | slot_name | priority | active \r\n----+---------+------------------+---------+------+-------------------------------------+-----------+----------+--------\r\n  1 | master  |                  | test    | neko | host=neko user=repmgr dbname=repmgr |           |      100 | t\r\n  2 | standby |                1 | test    | inu  | host=inu user=repmgr dbname=repmgr  |           |      100 | t\r\n(2 rows)\r\n<\/code><\/pre>\n<h2>9. \u5f85\u547d\u63a8\u5e7f<\/h2>\n<p>\u9996\u5148\uff0c\u8bf7\u786e\u8ba4\u51c6\u5907\u5c31\u7eea\u3002<\/p>\n<pre class=\"post-pre\"><code>$ psql postgres -c \"SELECT pg_is_in_recovery()\"\r\n pg_is_in_recovery \r\n-------------------\r\n t\r\n(1 row)\r\n<\/code><\/pre>\n<p>\u8ba9\u4e3b\u4eba\u4e0b\u6765\u3002<\/p>\n<pre class=\"post-pre\"><code>$ pg_ctl -D ~\/local\/pg952\/data stop\r\nwaiting for server to shut down..... done\r\nserver stopped\r\n<\/code><\/pre>\n<p>\u4f7f\u7528repmgr\u5c06\u5907\u7528\u8282\u70b9\u63d0\u5347\u4e3a\u4e3b\u8282\u70b9\u3002<\/p>\n<pre class=\"post-pre\"><code>$ repmgr -f ~\/local\/pg952\/pgsql\/etc\/repmgr.conf standby promote\r\n[2016-05-25 00:34:14] [ERROR] connection to database failed: could not connect to server: Connection refused\r\n    Is the server running on host \"neko\" (192.168.1.1) and accepting\r\n    TCP\/IP connections on port 5432?\r\n\r\n[2016-05-25 00:34:14] [NOTICE] promoting standby\r\n[2016-05-25 00:34:14] [NOTICE] promoting server using 'pg_ctl -D \/home\/ikki\/local\/pg952\/data promote'\r\nserver promoting\r\n[2016-05-25 00:34:16] [NOTICE] STANDBY PROMOTE successful\r\n<\/code><\/pre>\n<p>\u786e\u8ba4\u5f85\u673a\u5df2\u664b\u5347\u4e3a\u4e3b\u673a\u3002<\/p>\n<pre class=\"post-pre\"><code>$ psql -h inu postgres -c \"SELECT pg_is_in_recovery()\"\r\n pg_is_in_recovery \r\n-------------------\r\n f\r\n(1 row)\r\n<\/code><\/pre>\n<p>\u6210\u529f\u4e86\uff01\u6210\u529f\u5730\u5c06\u5176\u664b\u5347\uff0c\u6ca1\u6709\u51fa\u4efb\u4f55\u95ee\u9898\u3002<\/p>\n<h2>\u987a\u4fbf\u8bf4\u4e00\u53e5&#8230; shu\u014d y\u012b j\u00f9&#8230;)<\/h2>\n<p>\u5728\u505c\u6b62\u4e3b\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u8bd5\u56fe\u63d0\u5347\u5b83\u4f1a\u5bfc\u81f4\u9519\u8bef\u3002<br \/>\n\u5b83\u88ab\u6b63\u786e\u5730\u4f5c\u4e3a\u4e00\u4e2a\u96c6\u7fa4\u8fdb\u884c\u7ba1\u7406\u3002<\/p>\n<pre class=\"post-pre\"><code>$ repmgr -f ~\/local\/pg952\/pgsql\/etc\/repmgr.conf standby promote\r\n[2016-05-25 00:29:48] [ERROR] this cluster already has an active master server\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u662f\u6211\u5199\u7684\u6240\u6709\u5185\u5bb9\u3002<br \/>\n\u867d\u7136\u5199\u4e86\u5f88\u591a\uff0c\u4f46\u4eca\u5929\u5c31\u5230\u8fd9\u91cc\u5427\u3002<\/p>\n<p>\u6ce8\u610f\uff1a\u53ea\u6709repmgr\u672c\u8eab\u65e0\u6cd5\u5b9e\u73b0\u81ea\u52a8\u6545\u969c\u8f6c\u79fb\u3002<br \/>\n\u8981\u5b9e\u73b0\u81ea\u52a8\u6545\u969c\u8f6c\u79fb\uff0c\u9700\u8981\u542f\u52a8\u4e00\u4e2a\u540d\u4e3arepmgrd\u7684\u5b88\u62a4\u8fdb\u7a0b\u3002<br \/>\n\u63a5\u4e0b\u6765\u4f1a\u4ecb\u7ecdrepmgrd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u56e0\u70ba\u6c92\u6709\u592a\u591a\u4eba\u4ecb\u7d39\uff0c\u6211\u5f88\u60f3\u8a66\u8a66\u770b\u5b83\u662f\u600e\u9ebc\u6a23\u7684\uff0c\u6240\u4ee5\u6211\u81ea\u5df1\u5617\u8a66\u64cd\u4f5c\u4e86\u4e00\u4e0b\u3002 repmgr\u6982\u89c8 repmgr\u662f\u4e00\u4e2a [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-41615","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u901a\u8fc7repmgr\u5b9e\u73b0PostgreSQL\u7684\u96c6\u7fa4\u5316 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u901a\u8fc7repmgr\u5b9e\u73b0postgresql\u7684\u96c6\u7fa4\u5316\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u901a\u8fc7repmgr\u5b9e\u73b0PostgreSQL\u7684\u96c6\u7fa4\u5316\" \/>\n<meta property=\"og:description\" content=\"\u56e0\u70ba\u6c92\u6709\u592a\u591a\u4eba\u4ecb\u7d39\uff0c\u6211\u5f88\u60f3\u8a66\u8a66\u770b\u5b83\u662f\u600e\u9ebc\u6a23\u7684\uff0c\u6240\u4ee5\u6211\u81ea\u5df1\u5617\u8a66\u64cd\u4f5c\u4e86\u4e00\u4e0b\u3002 repmgr\u6982\u89c8 repmgr\u662f\u4e00\u4e2a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u901a\u8fc7repmgr\u5b9e\u73b0postgresql\u7684\u96c6\u7fa4\u5316\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-20T04:02:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-30T06:51:53+00:00\" \/>\n<meta name=\"author\" content=\"\u79d1, \u9896\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79d1, \u9896\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/\",\"name\":\"\u901a\u8fc7repmgr\u5b9e\u73b0PostgreSQL\u7684\u96c6\u7fa4\u5316 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2022-11-20T04:02:13+00:00\",\"dateModified\":\"2024-04-30T06:51:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u901a\u8fc7repmgr\u5b9e\u73b0PostgreSQL\u7684\u96c6\u7fa4\u5316\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e\",\"name\":\"\u79d1, \u9896\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g\",\"caption\":\"\u79d1, \u9896\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keying\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u901a\u8fc7repmgr\u5b9e\u73b0PostgreSQL\u7684\u96c6\u7fa4\u5316 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u901a\u8fc7repmgr\u5b9e\u73b0postgresql\u7684\u96c6\u7fa4\u5316\/","og_locale":"zh_CN","og_type":"article","og_title":"\u901a\u8fc7repmgr\u5b9e\u73b0PostgreSQL\u7684\u96c6\u7fa4\u5316","og_description":"\u56e0\u70ba\u6c92\u6709\u592a\u591a\u4eba\u4ecb\u7d39\uff0c\u6211\u5f88\u60f3\u8a66\u8a66\u770b\u5b83\u662f\u600e\u9ebc\u6a23\u7684\uff0c\u6240\u4ee5\u6211\u81ea\u5df1\u5617\u8a66\u64cd\u4f5c\u4e86\u4e00\u4e0b\u3002 repmgr\u6982\u89c8 repmgr\u662f\u4e00\u4e2a [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u901a\u8fc7repmgr\u5b9e\u73b0postgresql\u7684\u96c6\u7fa4\u5316\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2022-11-20T04:02:13+00:00","article_modified_time":"2024-04-30T06:51:53+00:00","author":"\u79d1, \u9896","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79d1, \u9896","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/","name":"\u901a\u8fc7repmgr\u5b9e\u73b0PostgreSQL\u7684\u96c6\u7fa4\u5316 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2022-11-20T04:02:13+00:00","dateModified":"2024-04-30T06:51:53+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u901a\u8fc7repmgr\u5b9e\u73b0PostgreSQL\u7684\u96c6\u7fa4\u5316"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e","name":"\u79d1, \u9896","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g","caption":"\u79d1, \u9896"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keying\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87repmgr%e5%ae%9e%e7%8e%b0postgresql%e7%9a%84%e9%9b%86%e7%be%a4%e5%8c%96\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/41615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=41615"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/41615\/revisions"}],"predecessor-version":[{"id":92567,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/41615\/revisions\/92567"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=41615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=41615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=41615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}