1.问题现象:
patroni无法启动完成。
2.报错信息:
CRITICAL: system ID mismatch, node pgsql_node1 belongs to a different cluster: 7052280560147471869 != 7052284163040661464
3.原因:
新的 Postgres 实例数据库系统标识符 (7052280560147471869) 与旧 Postgres 实例结构中的数据库系统标识符的 ETCD 值不匹配
4.解决方法:
1.用以下命令获得数据库系统标识符:
pg_controldata -D | grep “Database system identifier”
2.运行以下命令以获取数据库系统标识符的 ETCD 值。
ETCD 将在 Patroni 第一次启动时从 Postgres 实例中提取并存储数据库系统标识符。
export ETCDCTL_API=2
etcdctl get /service/<scope from yaml file>/initialize
<scope from yaml file>=patroni 配置文件中参数scope的值。
3.清除 ETCD 存储值
patronictl -c
<yaml file directory>=patroni 配置文件
<yaml scope attribute value>=patroni 配置文件中参数scope的值
4.启动patroni
systemctl start patroni
patronictl -c
5.示例:
[root@pg01 ~]# pg_controldata -D /pgdata/12/data | grep “Database system identifier”
Database system identifier: 7052284163040661464
[root@pg01 ~]# etcdctl get /service/pgsql/initialize
7052284163040661464
[root@pg01 ~]# patronictl -c /etc/postgres.yml remove pgsql
±-------±-----±-----±------±—±----------+
| Member | Host | Role | State | TL | Lag in MB |
- Cluster: pgsql (7052280560147471869) ---------+
±-------±-----±-----±------±—±----------+
Please confirm the cluster name to remove: pgsql
You are about to remove all information in DCS for pgsql, please type: “Yes I am aware”: Yes I am aware
[root@pg01 ~]# systemctl start patroni
[root@pg01 ~]# systemctl status patroni
● patroni.service - Runners to orchestrate a high-availability PostgreSQL - patroni
Loaded: loaded (/usr/lib/systemd/system/patroni.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2022-01-12 20:09:58 CST; 2s ago
Main PID: 8454 (patroni)
CGroup: /system.slice/patroni.service
└─8454 /usr/local/python3.6.11/bin/python3.6 /usr/local/python3.6…
Jan 12 20:09:58 pg01 systemd[1]: Started Runners to orchestrate a high-avai…i.
Hint: Some lines were ellipsized, use -l to show in full.
2022-01-12 20:10:10,566 INFO: no action. I am (pgsql_node1) the leader with the lock
2022-01-12 20:10:10,578 INFO: no action. I am (pgsql_node1) the leader with the lock
2022-01-12 20:10:20,576 INFO: no action. I am (pgsql_node1) the leader with the lock
评论

