1. Creation user for Patroni on pgsql-db01
psql> create user replicator with replication encrypted password 'reppassword';
2. Add ACL on pgsql-db02 ($PGDATA/pg_hba.conf) and reload
host postgres postgres 192.168.1.82/32 trust
host replication postgres 192.168.1.82/32 trust
host replication postgres 192.168.1.81/32 trust
host replication replicator 192.168.1.82/32 trust
host replication replicator 192.168.1.81/32 trust
[postgres]$ pg_ctl reload
3. Installation Patroni 2
# [root]
yum -y install python3 python3-devel python3-pip gcc libpq-devel
yum -y install https://forensics.cert.org/centos/cert/8/x86_64/python3-certifi-2022.9.24-1.el8.noarch.rpm
python3 -m pip uninstall urllib3
python3 -m pip uninstall requests
python3 -m pip uninstall chardet
yum remove python-requests
yum remove python-urllib3
python3 -m pip install --upgrade --force-reinstall 'requests==2.6.0' urllib3
yum -y install https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-8.8-x86_64/patroni-etcd-2.1.7-1.rhel8.x86_64.rpm
4. Configuration patroni
[root]# mkdir /etc/patroni/
[root]# mkdir /etc/patroni/
[root]# vi /etc/patroni/patroni.yml
scope: postgres
namespace: /pg_cluster/
name: pgsql-db02
restapi:
listen: 192.168.1.82:8008
connect_address: 192.168.1.82:8008
etcd:
host: 192.168.1.85:2379
bootstrap:
dcs:
ttl: 30
loop_wait: 10
retry_timeout: 10
maximum_lag_on_failover: 1048576
postgresql:
use_pg_rewind: true
use_slots: true
parameters:
initdb:
- encoding: UTF8
- data-checksums
pg_hba:
- host replication replicator 127.0.0.1/32 md5
- host replication replicator 192.168.1.81/0 md5
- host replication replicator 192.168.1.82/0 md5
- host all all 0.0.0.0/0 md5
users:
admin:
password: admin
options:
- createrole
- createdb
postgresql:
listen: 192.168.1.82:5432
connect_address: 192.168.1.82:5432
data_dir: /srv/postgres/data/14
bin_dir: /usr/pgsql-14/bin
pgpass: /tmp/pgpass
authentication:
replication:
username: replicator
password: reppassword
superuser:
username: postgres
password: postgrespassword
tags:
nofailover: false
noloadbalance: false
clonefrom: false
nosync: false
No comments:
Post a Comment