postgresql手动搭建主从环境
1.配置yum源(主从节点)
cat /etc/yum.repos.d/pg.repo
[pgdg10]
name=pgdg10 - $basearch
baseurl=http://xxx/pgdg10/
enabled=1
gpgcheck=0
2.yum安装postgresql(主从节点)
yum search postgresql
yum install postgresql10-server
3.修改服务配置文件(主从节点)
cp /usr/lib/systemd/system/postgresql-10.service /etc/systemd/system/
编辑/etc/systemd/system/postgresql-10.service
修改数据目录
Environment=PGDATA=/opt/database/postgres
4.初始化数据库(主节点)
/usr/pgsql-10/bin/postgresql-10-setup initdb
5.配置postgresql相关文件(主节点)
编辑/opt/database/postgres/pg_hba.conf
添加访问白名单和从节点复制信任,最后几行
以下是白名单访问配置:
host all all 172.20.56.0/21 md5
host all all 192.168.7.0/24 md5
host all all 172.16.5.0/24 md5
以下是节点访问配置:
host replication all 172.20.59.216/32 trust
编辑/opt/database/postgres/postgresql.conf
listen_addresses = ‘*’
max_connections = 1000
wal_level = hot_standby
wal_log_hints = on
max_wal_senders = 10
wal_keep_segm