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
yum install -y postgresql10-contrib.x86_64 postgresql10-server.x86_64
yum install postgis25_10.x86_64 -y
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
pip install psycopg2-binary
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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。