gpt4 book ai didi

postgresql - 运行守护神失败

转载 作者:行者123 更新时间:2023-11-29 13:14:41 26 4
gpt4 key购买 nike

我已遵循本教程:https://linode.com/docs/databases/postgresql/create-a-highly-available-postgresql-cluster-using-patroni-and-haproxy/ ,以便使用 Patroni 和 HAProxy 设置高可用性 PostgreSQL 集群。

但是当我尝试启动 patroni 时出现此错误:

ubuntu@sudo patroni /etc/patroni.yml 
2018-05-31 09:49:37,159 INFO: Failed to import patroni.dcs.consul
2018-05-31 09:49:37,166 INFO: Selected new etcd server http://privateetcdIP:2379
2018-05-31 09:49:37,173 INFO: Lock owner: None; I am postgresqlm
2018-05-31 09:49:37,175 INFO: trying to bootstrap a new cluster
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
2018-05-31 09:49:37,185 INFO: removing initialize key after failed attempt to bootstrap the cluster
2018-05-31 09:49:37,673 INFO: Lock owner: None; I am postgresqlm
Traceback (most recent call last):
File "/usr/local/bin/patroni", line 9, in <module>
load_entry_point('patroni==1.4.4', 'console_scripts', 'patroni')()
File "/usr/local/lib/python2.7/dist-packages/patroni/__init__.py", line 176, in main
return patroni_main()
File "/usr/local/lib/python2.7/dist-packages/patroni/__init__.py", line 145, in patroni_main
patroni.run()
File "/usr/local/lib/python2.7/dist-packages/patroni/__init__.py", line 114, in run
logger.info(self.ha.run_cycle())
File "/usr/local/lib/python2.7/dist-packages/patroni/ha.py", line 1164, in run_cycle
info = self._run_cycle()
File "/usr/local/lib/python2.7/dist-packages/patroni/ha.py", line 1077, in _run_cycle
return self.post_bootstrap()
File "/usr/local/lib/python2.7/dist-packages/patroni/ha.py", line 976, in post_bootstrap
self.cancel_initialization()
File "/usr/local/lib/python2.7/dist-packages/patroni/ha.py", line 971, in cancel_initialization
raise PatroniException('Failed to bootstrap cluster')

/etc/patroni.yml的配置是:

scope: postgres
namespace: /db/
name: postgresqlm

restapi:
listen: privateIPoffirstnode:8008
connect_address: privateIPoffirstnode:8008

etcd:
host: privateIPofetcd:2379

bootstrap:
dcs:
ttl: 30
loop_wait: 10
retry_timeout: 10
maximum_lag_on_failover: 1048576
postgresql:
use_pg_rewind: true
max_connections: 100

initdb:
- encoding: UTF8
- data-checksums

pg_hba:
- host replication replicator 127.0.0.1/32 md5
- host replication replicator privateIPoffirstnode/0 md5
- host replication replicator privateIPofsecondnode/0 md5
- host replication replicator privateIPofthirdnode/0 md5
- host all all 0.0.0.0/0 md5

users:
admin:
password: admin
options:
- createrole
- createdb

postgresql:
listen: privateIPoffirstnode:5432
connect_address: privateIPoffirstnode:5432
data_dir: /data/patroni
pgpass: /tmp/pgpass
bin_dir: /usr/lib/postgresql/9.5/bin
authentication:
replication:
username: replicator
password: rep-pass
superuser:
username: postgres
password: '12345'
parameters:
unix_socket_directories: '.'

tags:
nofailover: false
noloadbalance: false
clonefrom: false
nosync: false

/etc/systemd/system/patroni.service的配置是:

[Unit]
Description=Runners to orchestrate a high-availability PostgreSQL
After=syslog.target network.target

[Service]
Type=simple

User=postgres
Group=postgres

ExecStart=/usr/local/bin/patroni /etc/patroni.yml

KillMode=process

TimeoutSec=30

Restart=no

[Install]
WantedBy=multi-user.targ

etcd 配置:

ETCD_LISTEN_PEER_URLS="http://privateIPofetcd:2380"

ETCD_LISTEN_CLIENT_URLS="http://localhost:2379,http://privateIPofetcd:2379"

ETCD_INITIAL_ADVERTISE_PEER_URLS="http://privateIPofetcd:2380"

ETCD_INITIAL_CLUSTER="etcd0=http://privateIPofetcd:2380,"

ETCD_ADVERTISE_CLIENT_URLS="http://privateIPofetcd:2379"

ETCD_INITIAL_CLUSTER_TOKEN="cluster1"

ETCD_INITIAL_CLUSTER_STATE="new"

当然,我在privateIPoffirstnode、privateIPofsecondnode等都有真实ip

那么,有人知道这个错误是什么意思吗?

最佳答案

我认为答案是显而易见的。如果您使用 sudo 启动 patrani,它将以 root 身份运行,这正是您收到的错误消息。

为什么不通过 systemctl 启动它?您的 /etc/systemd/system/patroni.service 已经正确配置了一个不是 rootUser

关于postgresql - 运行守护神失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50621620/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com