postgresql 主从 patroni
1 安装基础包 1.1 postgres yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm 1.2 patroni yum install python36 python36-devel -y? curl https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py python3.6 /tmp/get-pip.py pip3 install patroni[etcd] -i https://pypi.douban.com/simple ? 2 配置,简单demo 2.1 配置 pg 超级用户密码,流复制用户权限及密码,pg_hba.conf? 略 2.2 patroni 配置文件 cat /etc/patroni/patroni_postgresql.yml scope: pgha #集群名 namespace: /pgsql/ #etcd path name: pg_node1 # node 名称 每个节点不同 restapi: listen: 10.1.88.82:8008 connect_address: 127.0.0.1:8008 etcd: hosts: 10.1.88.81:2379,10.1.88.82:2379,10.1.88.83:2379 #host: ip:port #single etd server bootstrap: # this section will be written into Etcd:/<namespace>/<scope>/config after initializing new cluster # and all other cluster members will use it as a `global configuration` dcs: ttl: 30 loop_wait: 10 retry_timeout: 10 maximum_lag_on_failover: 20485760 master_start_timeout: 300 # synchronous_mode: false postgresql: use_pg_rewind: true use_slots: false parameters: listen_addresses: "*" port: 5432 wal_level: logical hot_standby: "on" wal_keep_segments: 1000 max_wal_senders: 10 synchronous_standby_names: ‘*‘ max_connections: 150 max_replication_slots: 10 wal_log_hints: "on" postgresql: listen: 0.0.0.0:5432 connect_address: 10.1.88.82:5432 # local ip data_dir: /var/lib/pgsql/10/data bin_dir: /usr/pgsql-10/bin # config_dir: authentication: replication: username: replicator password: replicator superuser: username: postgres password: postgres #watchdog: # mode: automatic # Allowed values: off,automatic,required # device: /dev/watchdog # safety_margin: 5 tags: nofailover: false noloadbalance: false clonefrom: false nosync: false 2.3 服务配置 cat /usr/lib/systemd/system/patroni.service [Unit] Description=Patroni server Documentation=‘https://github.com/zalando/patroni,https://www.opsdash.com/blog/postgres-getting-started-patroni.html‘ After=syslog.target After=network.target [Service] Type=simple User=postgres Group=postgres # StandardOutput=syslog WorkingDirectory=/etc/patroni/ ExecStart=/usr/local/bin/patroni /etc/patroni/patroni_postgresql.yml ExecReload=/bin/kill -HUP $MAINPID KillMode=mixed KillSignal=SIGINT # Do not set any timeout value,so that systemd will not kill postmaster # during crash recovery. TimeoutSec=0 [Install] WantedBy=multi-user.target ? 英文 https://www.opsdash.com/blog/postgres-getting-started-patroni.html https://www.linode.com/docs/databases/postgresql/create-a-highly-available-postgresql-cluster-using-patroni-and-haproxy 中文 https://blog.csdn.net/ctypyb2002/article/details/81002436 https://blog.csdn.net/ctypyb2002/article/details/81007990 https://blog.csdn.net/ctypyb2002/article/details/81206652 https://blog.csdn.net/ctypyb2002/article/details/81540288 https://blog.csdn.net/ctypyb2002/article/details/82887607 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |