repmgr基本配置
官方網站:
https://repmgr.org
WHAT IS REPMGR?
repmgr is an open-source tool suite for managing replication and failover in a cluster of PostgreSQL servers. It enhances PostgreSQL's built-in hot-standby capabilities with tools to set up standby servers, monitor replication, and perform administrative tasks such as failover or manual switchover operations.
repmgr has provided advanced support for PostgreSQL's built-in replication mechanisms since they were introduced in 9.0. The current repmgr series, repmgr 5, supports the latest developments in replication functionality introduced from PostgreSQL 9.3 such as cascading replication, timeline switching and base backups via the replication protocol.
OPEN SOURCE FROM 2NDQUADRANT
repmgr is developed by 2ndQuadrant, the global experts in PostgreSQL support, training, development, migration and consultancy.
repmgr is free and open-source software licensed under the GNU Public License (GPL) v3. This means you are free to use and modify repmgr as you see fit, however any modifications you make may only be distributed under the same terms.
repmgr compatibility matrix
repmgr version Supported? Latest release Supported PostgreSQL versions
repmgr 5.x YES 5.0.0 (2019-10-15) 9.3, 9.4, 9.5, 9.6, 10, 11, 12
repmgr 4.x NO 4.4 (2019-06-27) 9.3, 9.4, 9.5, 9.6, 10, 11
repmgr 3.x NO 3.3.2 (2017-05-30) 9.3, 9.4, 9.5, 9.6
repmgr 2.x NO 2.0.3 (2015-04-16) 9.0, 9.1, 9.2, 9.3, 9.4
我們使用 postgresql 12.4 版本,所有使用repmgr 5.x 版本
使用文件為:
https://repmgr.org/docs/5.0/index.html
環境描述:
repmgr1: 192.168.112.66 centos 7.0 postgresql 12.4
repmgr2: 192.168.112.67 centos 7.0 postgresql 12.4
1.安裝
2.1. Requirements for installing repmgr
A dedicated system user for repmgr is not required; as many repmgr and repmgrd actions require direct access to the PostgreSQL data directory, these commands should be executed by the postgres user.
我們使用 postgres 使用者進行安裝.
Important
yum install flex libselinux-devel libxml2-devel libxslt-devel openssl-devel pam-devel readline-devel
2.3. Installing repmgr from source
獲取原始碼
https://github.com/2ndQuadrant/repmgr
2.3.3. Installation of repmgr from source
./configure
make
make install
3.1. Prerequisites for setting up a basic replication cluster with repmgr
If you want repmgr to copy configuration files which are located outside the PostgreSQL data directory, and/or to test switchover functionality, you will also need passwordless SSH connections between both servers, and rsync should be installed.
兩臺機器配置一下postgres 使用者的 ssh 互信
3.2. PostgreSQL configuration
On the primary server, a PostgreSQL instance must be initialised and running. The following replication settings may need to be adjusted:
max_wal_senders = 10
max_replication_slots = 10
wal_level = 'hot_standby'
hot_standby = on
archive_mode = on
archive_command = '/bin/true'
Tip
Rather than editing these settings in the default postgresql.conf file, create a separate file such as postgresql.replication.conf and
include it from the end of the main configuration file with: include 'postgresql.replication.conf'.
我們在主庫 repmgr1 建立 postgresql.replication.conf 檔案,將如上6個引數寫入檔案中.
編輯 postgresql.conf 檔案,在最後一行加入 include 'postgresql.replication.conf'
重啟主庫進行驗證:
postgres=# show max_wal_senders;
max_wal_senders
-----------------
10
(1 row)
3.3. Create the repmgr user and database
createuser -s repmgr
createdb repmgr -O repmgr
3.4. Configuring authentication in pg_hba.conf
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all 192.168.112.66/24 trust
host replication all 192.168.112.67/24 trust
local repmgr all trust
host repmgr all 127.0.0.1/32 trust
host repmgr all 192.168.112.66/24 trust
host repmgr all 192.168.112.67/24 trust
3.6. repmgr configuration file
Create a repmgr.conf file on the primary server. The file must contain at least the following parameters:
node_id=1
node_name='repmgr1'
conninfo='host=repmgr1 user=repmgr dbname=repmgr connect_timeout=2'
data_directory='/pgsoft/data'
3.7. Register the primary server
[postgres@repmgr1 data]$ repmgr -f /pgsoft/data/repmgr.conf primary register
INFO: connecting to primary database...
NOTICE: attempting to install extension "repmgr"
NOTICE: "repmgr" extension successfully installed
NOTICE: primary node record (ID: 1) registered
3.8. Clone the standby server
Create a repmgr.conf file on the standby server.
node_id=2
node_name='repmgr2'
conninfo='host=repmgr2 user=repmgr dbname=repmgr connect_timeout=2'
data_directory='/pgsoft/data'
Use the --dry-run option to check the standby can be cloned:
[postgres@repmgr2 pgsoft]$ repmgr -h repmgr1 -U repmgr -d repmgr -f /pgsoft/repmgr.conf standby clone --dry-run
NOTICE: destination directory "/pgsoft/data" provided
INFO: connecting to source node
DETAIL: connection string is: host=repmgr1 user=repmgr dbname=repmgr
DETAIL: current installation size is 31 MB
INFO: "repmgr" extension is installed in database "repmgr"
INFO: parameter "max_wal_senders" set to 10
NOTICE: checking for available walsenders on the source node (2 required)
INFO: sufficient walsenders available on the source node
DETAIL: 2 required, 10 available
NOTICE: checking replication connections can be made to the source server (2 required)
INFO: required number of replication connections could be made to the source server
DETAIL: 2 replication connections required
NOTICE: standby will attach to upstream node 1
HINT: consider using the -c/--fast-checkpoint option
INFO: all prerequisites for "standby clone" are met
If no problems are reported, the standby can then be cloned with:
[postgres@repmgr2 pgsoft]$ repmgr -h repmgr1 -U repmgr -d repmgr -f /pgsoft/repmgr.conf standby clone
NOTICE: destination directory "/pgsoft/data" provided
INFO: connecting to source node
DETAIL: connection string is: host=repmgr1 user=repmgr dbname=repmgr
DETAIL: current installation size is 31 MB
NOTICE: checking for available walsenders on the source node (2 required)
NOTICE: checking replication connections can be made to the source server (2 required)
INFO: creating directory "/pgsoft/data"...
NOTICE: starting backup (using pg_basebackup)...
HINT: this may take some time; consider using the -c/--fast-checkpoint option
INFO: executing:
pg_basebackup -l "repmgr base backup" -D /pgsoft/data -h repmgr1 -p 5432 -U repmgr -X stream
NOTICE: standby clone (using pg_basebackup) complete
NOTICE: you can now start your PostgreSQL server
HINT: for example: pg_ctl -D /pgsoft/data start
HINT: after starting the server, you need to register this standby with "repmgr standby register"
3.10. Register the standby
Register the standby server with:
[postgres@repmgr2 pgsoft]$ repmgr -f /pgsoft/repmgr.conf standby register
INFO: connecting to local node "repmgr2" (ID: 2)
INFO: connecting to primary database
WARNING: --upstream-node-id not supplied, assuming upstream node is primary (node ID 1)
INFO: standby registration complete
NOTICE: standby node "repmgr2" (ID: 2) successfully registered
驗證:
[postgres@repmgr1 data]$ repmgr -f /pgsoft/data/repmgr.conf cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+----------------------------------------------------------
1 | repmgr1 | primary | * running | | default | 100 | 1 | host=repmgr1 user=repmgr dbname=repmgr connect_timeout=2
2 | repmgr2 | standby | running | repmgr1 | default | 100 | 1 | host=repmgr2 user=repmgr dbname=repmgr connect_timeout=2
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7569309/viewspace-2758740/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- vscode 基本配置VSCode
- NGINX基本配置Nginx
- RIP的基本配置
- TeamCity : Build 基本配置UI
- nginx基本配置使用Nginx
- vue基本指令與腳手架基本配置Vue
- ensp概念和基本配置
- MFC 程式基本介面配置
- vim配置及基本用法
- GoldenGate的基本配置流程Go
- centos7基本配置CentOS
- PostgreSQL repmgr高可用叢集+keepalived高可用SQL
- repmgr 叢集雙主問題處理
- H3C基本配置
- NGINX的配置和基本使用Nginx
- git 部署與基本配置使用Git
- Quill基本使用和配置 - DevUIUIdev
- webpack2-3基本配置Web
- vim基本配置與使用技巧
- OSPF多區域基本配置
- PostgreSQL DBA(121) - pgAdmin(HA:PAF vs repmgr vs Patroni)SQL
- PG12.9-Repmgr5.1.0-vip-3節點部署
- “微信公眾號-設定-基本配置”的配置
- 思科路由器基本配置命令路由器
- OSPF的基本配置實驗(四)
- Centos6防火牆基本配置CentOS防火牆
- samba 基本配置及自定義控制Samba
- Mac 基本開發環境配置Mac開發環境
- 阿里雲伺服器基本配置阿里伺服器
- c++基本配置屬性頁C++
- PostgreSQL叢集管理工具repmgr相關命令SQL
- 使用 bitnami/postgresql-repmgr 映象快速設定 PostgreSQL HASQL
- 02 eclipse中配置Web專案(含eclipse基本配置和Tomcat的配置)EclipseWebTomcat
- PostgreSQL高可用之Repmgr和Patroni部分場景對比SQL
- docker 基本安裝配置操作(複習)Docker
- ISIS 協議常用基本配置總結協議
- pycharm下載安裝與基本配置PyCharm
- linux安裝配置與基本命令Linux