【AntDB Installation and Deployment Documentation】ETCD+patroni for High Availability (3)
Start patroni
Executed by the root user to start patroni as a service
After configuration, you must reload, if you change the configuration in the middle, you must also reload, otherwise it will not be recognized.
systemctl daemon-reload
Execute as root user
systemctl start patroni
Check the startup status
systemctl status patroni –l
The following display means the startup is successful.
[shan2@host227 ~]$ systemctl status patroni –l
● patroni.service - Runners to orchestrate a high-availability AntDB5.0
Loaded: loaded (/usr/lib/systemd/system/patroni.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2022-08-05 17:40:21 CST; 2 days ago
Main PID: 179523 (patroni)
Tasks: 12
Memory: 54.9M
CGroup: /system.slice/patroni.service
├─179523 /usr/local/bin/python3.7 /usr/local/bin/patroni /etc/patroni.yml
├─179905 /data/shan2/pgsql_adb/bin/postgres -D /data/shan2/pgdata --config-file=/data/shan2/pgdata/p...
├─179908 postgres: antdb-cluster: startup recovering 000000040000000000000005
├─179910 postgres: antdb-cluster: checkpointer
├─179911 postgres: antdb-cluster: background writer
├─179912 postgres: antdb-cluster: stats collector
├─179917 postgres: antdb-cluster: shan2 postgres 10.20.16.227(56482) idle
└─179927 postgres: antdb-cluster: walreceiver streaming 0/50010D0
Unit \xe2\x80\x93l.service could not be found.
If the startup fails, you can manually execute the ExecStart configuration in the service configuration file above to manually start the service to see the error report.
/usr/local/bin/patroni /etc/patroni.yml
Or
The patroni log is in the system log, if there is a problem, you can go through the log error reporting to investigate
tail -f /var/log/messages
After successful installation, check the status of the cluster.
[root@host228 shan2]# patronictl -c /etc/patroni.yml list
+------------+--------------------+--------------+---------+----+-----------+-----------------+
| Member | Host | Role | State | TL | Lag in MB | Pending restart |
Cluster: antdb-cluster (7127106860783255508) --+---------+----+-----------+-----------------+
| adbnode_01 | 10.20.16.227:40571 | Sync Standby | running | 4 | 0 | * |
| adbnode_02 | 10.20.16.228:40571 | Replica | running | 4 | 0 | * |
| adbnode_03 | 10.20.16.214:40571 | Leader | running | 4 | | * |
+------------+--------------------+--------------+---------+----+-----------+-----------------+
Some common operations of patroni
patronictl to view cluster information
patronictl -c /etc/patroni.yml list
Restart the cluster, postgres-cluster is the cluster name
patronictl -c /etc/patroni.yml restart postgres-cluster
Restart the nodes
patronictl -c /etc/patroni.yml restart postgres-cluster pgnode02
Reinitialize the nodes
patronictl -c /etc/patroni.yml reinit postgres-cluster pgnode02
Send a SQL command
patronictl -c /etc/patroni.yml query postgres-cluster --command 'select version() ' -d postgres
version
PostgreSQL 13.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
Get the master node dsn information
patronictl -c /etc/patroni.yml dsn postgres-cluster
host=10.19.32.118 port=55551
Manually switchover a node
patronictl -c /etc/patroni.yml switchover
Manually failover a node
patronictl -c /etc/patroni.yml failover
Delete cluster information in DCS
patronictl -c /etc/patroni.yml remove postgres-cluster
• Add patroni and database nodes
• Install antdb, patroni on the new node
• Provide authentication of the new node on the corresponding existing node (pg_hba.conf)
• Copy the yml file to the new node
• Modify the yml file of the new node
name: antdb120
tags:
replicatefrom: antdb119 ###Select the cascade slave node, the default is to synchronize to the master node
restapi:
listen: 10.21.20.120:8008
connect_address: 10.21.20.120:8008
postgresql:
listen: 0.0.0.0:6432
connect_address: 10.21.20.120:6432
data_dir: /home/antdb/datafile
• Start patroni
sudo systemctl status patroni -l
sudo journalctl -f -u patroni
The patroni log is in the system log, if there is a problem, you can go through the log error reporting to investigate
tail -f /var/log/messages
Build high availability under ipv6
The steps to build high availability under Ipv6 are the same as the overall steps above, except that the ip address part needs to be changed, as described below.