我有一个带有流复制的现有 PostgreSQL 集群 v11.5。
我想设置由 Patroni 管理的高可用性。
我在两台机器上都安装了 Patroni,在另外三台虚拟机上设置了 etcd 集群 [' http://10.AA191:2379 '、' http://10.BB99:2379 '、' http://10. CC170:2379 '] 但使用 systemctl 启动 Patroni 失败。
当我使用patroni -c /etc/patroni.yml
命令启动 Patroni 时,出现以下错误:
2019-12-26 16:51:38,207 DEBUG: Selection next machine in cache. Available machines: ['http://10.A.A.191:2379', 'http://10.B.B.99:2379', 'http://10.C.C.170:2379']
2019-12-26 16:51:38,207 INFO: Selected new etcd server http://10.C.C.170:2379
2019-12-26 16:51:38,208 DEBUG: Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0, status=None)
2019-12-26 16:51:38,208 DEBUG: Starting new HTTP connection (1): 10.C.C.170:2379
2019-12-26 16:51:38,210 DEBUG: http://10.C.C.170:2379 "GET /v2/machines HTTP/1.1" 404 19
2019-12-26 16:51:38,211 ERROR: Failed to get list of machines from http://10.C.C.170:2379/v2: EtcdException('Bad response : 404 page not found\n',)
2019-12-26 16:51:38,211 INFO: Retrying on http://10.A.A.191:2379
2019-12-26 16:51:38,211 DEBUG: Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0, status=None)
2019-12-26 16:51:38,211 DEBUG: Starting new HTTP connection (1): 10.237.132.191:2379
2019-12-26 16:51:38,214 DEBUG: http://10.A.A.191:2379 "GET /v2/machines HTTP/1.1" 404 19
2019-12-26 16:51:38,214 ERROR: Failed to get list of machines from http://10.A.A.191:2379/v2: EtcdException('Bad response : 404 page not found\n',)
2019-12-26 16:51:38,214 INFO: Retrying on http://10.B.B.99:2379
2019-12-26 16:51:38,215 DEBUG: Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0, status=None)
2019-12-26 16:51:38,215 DEBUG: Starting new HTTP connection (1): 10.B.B.99:2379
2019-12-26 16:51:38,217 DEBUG: http://10.B.B.99:2379 "GET /v2/machines HTTP/1.1" 404 19
2019-12-26 16:51:38,217 ERROR: Failed to get list of machines from http://10.B.B.99:2379/v2: EtcdException('Bad response : 404 page not found\n',)
2019-12-26 16:51:38,217 INFO: waiting on etcd
问题似乎出在 API 级别DEBUG: http://10.B.B.99:2379 "GET /v2/machines HTTP/1.1" 404 19
etcd 可从 PostgreSQL 主机访问:
curl -s http://10.B.B.99:2380/members |jq -r
返回
[
{
"id": 730XXXXXXXXXXX000,
"peerURLs": [
"http://10.B.B.99:2380"
],
"name": "etcd1",
"clientURLs": [
"http://0.0.0.0:2379"
]
},
{
"id": 956XXXXXXXXXXX000,
"peerURLs": [
"http://10.C.C.170:2380"
],
"name": "etcd3",
"clientURLs": [
"http://0.0.0.0:2379"
]
},
{
"id": 1551XXXXXXXXXXX000,
"peerURLs": [
"http://10.A.A.191:2380"
],
"name": "etcd2",
"clientURLs": [
"http://0.0.0.0:2379"
]
}
]
etcd1 启动命令:
ExecStart=/usr/local/bin/etcd \
--name etcd1 \
--advertise-client-urls http://0.0.0.0:2379 \
--listen-client-urls http://0.0.0.0:2379 \
--initial-advertise-peer-urls http://10.B.B.99:2380 \
--listen-peer-urls http://0.0.0.0:2380 \
--initial-cluster etcd1=http://10.B.B.99:2380,etcd2=http://10.A.A.191:2380,etcd3=http://10.C.C.170:2380 \
--initial-cluster-token etcd-cluster-atom \
--initial-cluster-state new \
--logger zap \
--log-outputs stdout \
--log-level debug
有人可以帮助我吗?
怎么了?
非常感谢
版本:
etcd 版本:3.4.0
etcdctl 版本:3.4.0
API 版本:3.4
赞助人1.6.3
python-etcd== 0.4.5
感谢 CyberDem0n。
etcd1 启动命令中的两个问题:
API VERSION
Etcd v3.4 默认 API 版本为 v3。
Patroni 目前不支持 v3 API。
Etcd 3.4 默认关闭 API v2。
我在三个 etcd.service 上添加了 --enable-v2=true 标志,此错误已修复。
广告客户网址标志
对于每个 etcd 服务器,我将 0.0.0.0 替换为 flag 上的真实 etcd 服务器 ip
--advertise-client-urls
(如--advertise-client-urls http://10.B.B.99:2379
示例中所示)。