简介
repmgr 由 EDB 与其他个人和组织的贡献一起开发,安装部署相对较为简单
安装
repmgr官网上传对应的安装到服务器上
安装前/etc/hosts IP映射、始终同步、免密通信本文忽略
repmgr的安装相对较为简单,目前repmgr-5仅仅支持到postgresql-15
postgresql必要参数配置
shared_preload_libraries = 'repmgr'
wal_log_hints = on
synchronous_standby_names = '*'
archive_mode = on
archive_command = 'test ! -f /home/postgres/archivedir/%f && cp %p /home/postgres/archivedir/%f'
安装必要依赖
yum install -y flex libselinux-devel libxml2-devel libxslt-devel openssl-devel pam-devel readline-devel
# 或使用以下指令
sudo yum check-update -y
sudo yum groupinstall "Development Tools" -y
sudo yum install yum-utils openjade docbook-dtds docbook-style-dsssl docbook-style-xsl -y
sudo yum-builddep postgresql96 -y
# 安装repmgr
tar -zxvf repmgr-5.4.1.tar.gz
cd repmgr-5.4.1/
./configure && make install
# 数据库创建repmgr数据库
createuser -s repmgr
createdb repmgr -O repmgr
# 修改repmgr用户的seach_path
ALTER USER repmgr SET search_path TO repmgr, "$user", public;
# 配置repmgr配置项目
node_id=134
node_name='vm134'
conninfo='host=vm134 user=repmgr dbname=repmgr'
data_directory='/home/postgres/pg/data'
replication_user='repmgr'
use_replication_slots=true
pg_bindir='/home/postgres/pg/bin'
ssh_options='-q -o ConnectTimeout=10'
## 测试链接参数是否正常 使用
psql 'host=vm134 user=repmgr dbname=repmgr connect_timeout=2' 链接测试

postgresql白名单配置
repmgr需要设置trust 登录
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host repmgr repmgr 10.0.0.136/32 trust
host repmgr repmgr 10.0.0.135/32 trust
host repmgr repmgr 10.0.0.134/32 trust
host all all 0.0.0.0/0 scram-sha-256
# IPv6 local connections:
host all all ::1/128 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication repmgr 10.0.0.136/32 trust
host replication repmgr 10.0.0.135/32 trust
host replication repmgr 10.0.0.134/32 trust
host replication all 0.0.0.0/0 scram-sha-256
host replication repmgr ::1/128 scram-sha-256
创建postgresql守护进程
## sudo vim /etc/systemd/system/postgresql.service
[Unit]
Description=PostgreSQL database server
After=network.target
[Service]
Type=forking
User=postgres
Group=postgres
# 设置环境变量(可选,根据需要修改)
Environment=PGDATA=/home/postgres/pg/data
ExecStart=/home/postgres/pg/bin/pg_ctl start

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



