主从同步配置
- 主服务器:172.25.6.80
- 从服务器:172.25.6.81
1、先查看数据库版本是否一致
[appadmin@HGCAppP01 ~]$ psql -U postgres -h localhost -p 10001
Password for user postgres:
psql (14.8) <-------这里会输出具体版本号
Type "help" for help.
postgres=#
2、允许远程配置
pg_hba.conf和postgresql.conf修改这两个配置文件,配置成允许远程访问
修改pg_hba.conf配置文件
IPv4 local connections:在这行下面加入,表示允许所有ip访问且需要MD5加密的密码
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# 添加这一行
host all all 0.0.0.0/0 md5
postgresql.conf把下面这行配置成,表示允许访问
listen_addresses = ‘*’ # what IP address(es) to listen on;
3、主库配置
-
创建同步账号
psql -U postgres -h localhost -p 10001 CREATE ROLE repl l