repmgr安装及常用运维指令

简介

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' 链接测试

image.png

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值