01.05. Installation Patroni on pgsql-db01 and Startup Patroni

                <<< Back   Next >>>

1. Add ACL on  pgsql-db01 ($PGDATA/pg_hba.conf) and reload
host    postgres        postgres        192.168.1.81/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

2. Installation Patroni 2.1.7 on pgsql-db01
[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

3. Configuration patroni on pgsql-db01
[root]# mkdir /etc/patroni/
[root]# vi /etc/patroni/patroni.yml
scope: postgres
namespace: /pg_cluster/
name: pgsql-db01
restapi:
    listen: 192.168.1.81:8008
    connect_address: 192.168.1.81: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.81:5432
  connect_address: 192.168.1.81: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


4. Startup and check status patroni on pgsql-db01
[root]# 
systemctl enable patroni
systemctl start patroni
systemctl status patroni



5. Startup and check status patroni on pgsql-db02
[root]# 
systemctl enable patroni
systemctl start patroni
systemctl status patroni

                <<< Back   Next >>>

No comments:

Post a Comment