Manager Handbook for Centralized AntDB-T - P2–2
Parameter description
Send a SQL command
patronictl can send query command to the cluster to execute the corresponding SQL text.
#In the following command, "postgres-cluster" is the cluster name, and "-d postgres" refers to the database name.[adbpuq@host-10-19-28-129 ~]$ 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 can get the dsn information of the master node with the dsn command. The dsn is followed by the cluster name.
[adbpuq@host-10-19-28-129 ~]$ patronictl -c /etc/patroni.yml dsn postgres-cluster
host=10.19.36.207 port=55551
Delete cluster information in DCS
The patronictl followed by the remove command removes the cluster, as shown below, removing the batman5 cluster information.
patronictl -c /etc/patroni/patroni.yml remove batman5
+---------+--------+------+------+-------+-----------+
| Cluster | Member | Host | Role | State | Lag in MB |
| batman5 | antdb117 | 10.21.20.117:6432 | Leader | running | 22 |0.0 |
| batman5 | antdb118 | 10.21.20.118:6432 | | running | 22 |0.0 |
| batman5 | antdb119 | 10.21.20.119:6432 | | running | 22 |0.0 |
Please confirm the cluster name to remove: batman5
You are about to remove all information in DCS for batman5, please type: "Yes I am aware": Yes I am aware
Reboot the cluster
patronictl’s restart directly followed by the cluster name can restart the cluster. — force can force a cluster restart.
[adbpuq@host-10-19-28-129 ~]$ patronictl -c /etc/patroni.yml restart postgres-cluster
+----------+--------------------+--------------+---------+-----+-----------+
| Member | Host | Role | State | TL | Lag in MB |
+ Cluster: postgres-cluster (7171609184693121315) -------+-----+-----------+
| pgnode01 | 10.19.28.129:55551 | Replica | running | 467 | 0 |
| pgnode02 | 10.19.36.206:55551 | Sync Standby | running | 467 | 0 |
| pgnode03 | 10.19.36.207:55551 | Leader | running | 467 | |
+----------+--------------------+--------------+---------+-----+-----------+
When should the restart take place (e.g. 2022-12-27T16:11) [now]:
Are you sure you want to restart members pgnode03, pgnode01, pgnode02? [y/N]: y
Restart if the PostgreSQL version is less than provided (e.g. 9.5.2) []:
Success: restart on member pgnode03
Success: restart on member pgnode01
Success: restart on member pgnode02
#--Force restart
[adbpuq@host-10-19-28-129 ~]$ patronictl -c /etc/patroni.yml restart postgres-cluster --force
+----------+--------------------+--------------+---------+-----+-----------+
| Member | Host | Role | State | TL | Lag in MB |
+ Cluster: postgres-cluster (7171609184693121315) -------+-----+-----------+
| pgnode01 | 10.19.28.129:55551 | Sync Standby | running | 467 | 0 |
| pgnode02 | 10.19.36.206:55551 | Replica | running | 467 | 0 |
| pgnode03 | 10.19.36.207:55551 | Leader | running | 467 | |
+----------+--------------------+--------------+---------+-----+-----------+
Success: restart on member pgnode03
Success: restart on member pgnode01
Success: restart on member pgnode02
Restart the nodes
patronictl’s restart directly followed by the cluster name and the node name can restart the node in the cluster. — force can force a cluster restart.
[adbpuq@host-10-19-28-129 ~]$ patronictl -c /etc/patroni.yml restart postgres-cluster pgnode01
+----------+--------------------+--------------+---------+-----+-----------+
| Member | Host | Role | State | TL | Lag in MB |
+ Cluster: postgres-cluster (7171609184693121315) -------+-----+-----------+
| pgnode01 | 10.19.28.129:55551 | Sync Standby | running | 467 | 0 |
| pgnode02 | 10.19.36.206:55551 | Replica | running | 467 | 0 |
| pgnode03 | 10.19.36.207:55551 | Leader | running | 467 | |
+----------+--------------------+--------------+---------+-----+-----------+
When should the restart take place (e.g. 2022-12-27T16:19) [now]:
Are you sure you want to restart members pgnode01? [y/N]: y
Restart if the PostgreSQL version is less than provided (e.g. 9.5.2) []:
Success: restart on member pgnode01
#--Force restart
[adbpuq@host-10-19-28-129 ~]$ patronictl -c /etc/patroni.yml restart postgres-cluster pgnode01 --force
+----------+--------------------+--------------+---------+-----+-----------+
| Member | Host | Role | State | TL | Lag in MB |
+ Cluster: postgres-cluster (7171609184693121315) -------+-----+-----------+
| pgnode01 | 10.19.28.129:55551 | Replica | running | 467 | 0 |
| pgnode02 | 10.19.36.206:55551 | Sync Standby | running | 467 | 0 |
| pgnode03 | 10.19.36.207:55551 | Leader | running | 467 | |
+----------+--------------------+--------------+---------+-----+-----------+
Success: restart on member pgnode01
Reinitialize the nodes
The reinit of patronictl followed by the cluster name and selecting the corresponding node can reinitialize a node of the cluster. — force can force a re-initializetion.
# You can choose the node(s) to be restarted in the interactive options.
[adbpuq@host-10-19-28-129 ~]$ patronictl -c /etc/patroni.yml reinit postgres-cluster
+----------+--------------------+--------------+---------+-----+-----------+
| Member | Host | Role | State | TL | Lag in MB |
+ Cluster: postgres-cluster (7171609184693121315) -------+-----+-----------+
| pgnode01 | 10.19.28.129:55551 | Replica | running | 467 | 0 |
| pgnode02 | 10.19.36.206:55551 | Sync Standby | running | 467 | 0 |
| pgnode03 | 10.19.36.207:55551 | Leader | running | 467 | |
+----------+--------------------+--------------+---------+-----+-----------+
Which member do you want to reinitialize [pgnode02, pgnode03, pgnode01]? []: pgnode01
Are you sure you want to reinitialize members pgnode01? [y/N]: y
Success: reinitialize for member pgnode01
# You can also directly input the node(s) that need to be re-initialized in the command line. The option "--force" can be used to force re-initialization.
[adbpuq@host-10-19-28-129 ~]$ patronictl -c /etc/patroni.yml reinit postgres-cluster pgnode01 --force
Success: reinitialize for member pgnode01
Parameter modification
The parameters are obtained with a certain priority: patroni’s memory (patronictl -c /etc/patroni.yaml edit-config) > patroni’s local configuration (/etc/patroni.yaml) > postgresql.auto.conf > postgresql. conf > postgresql.base.conf.
Among them, the edit-config command of patronictl has the highest priority for editing parameters, and you need to restart the cluster after editing.
patronictl -c /etc/patroni.yml edit-config
patronictl -c /etc/patroni.yml restart postgres-cluster --force
Top comments (0)