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 gcc -y
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
create user replicator replication login encrypted password 'replicator';
local all all trust
host all all 127.0.0.1/ trust
# IPv4 local connections:
host all all 10.1.0.0/ md5
# IPv6 local connections:
host all all ::/ md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/ trust
host replication all 10.1.0.0/ md5
host replication all ::/ trust
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:
connect_address: 10.1.88.82: etcd:
hosts: 10.1.88.81:,10.1.88.82:,10.1.88.83:
#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:
loop_wait:
retry_timeout:
maximum_lag_on_failover:
master_start_timeout:
# synchronous_mode: false
postgresql:
use_pg_rewind: true
use_slots: false
parameters:
listen_addresses: "*"
port:
wal_level: logical
hot_standby: "on"
wal_keep_segments:
max_wal_senders:
#synchronous_standby_names: '*'
max_connections:
max_replication_slots:
wal_log_hints: "on" postgresql:
listen: 0.0.0.0:
connect_address: 10.1.88.82: # local ip
data_dir: /var/lib/pgsql//data
bin_dir: /usr/pgsql-/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: 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= [Install]
WantedBy=multi-user.target
基本操作
patronictl -c /etc/patroni/patroni_postgresql.yml list
patronictl -c /etc/patroni/patroni_postgresql.yml show-config
patronictl -c /etc/patroni/patroni_postgresql.yml edit-config
删除 属性
patronictl -c /etc/patroni/patroni_postgresql.yml edit-config -s postgresql.parameters.synchronous_standby_names=null
错误 解决
data dir for the cluster is not empty, but system ID is invalid; consider doing reinitalize
patronictl -c /etc/patroni/patroni_postgresql.yml reinit pgha pg_node81
利用Restful API 动态修改数据库属性
https://patroni.readthedocs.io/en/latest/dynamic_configuration.html#dynamic-configuration
重启数据库
patronictl -c /etc/patroni/patroni_postgresql.yml restart pgha
官方文档
https://patroni.readthedocs.io/en/latest/
英文
https://www.opsdash.com/blog/postgres-getting-started-patroni.html
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
postgresql 主从 patroni的更多相关文章
- postgresql 主从配置
安装postgresql 主从是否一定需要分两台机器,主从必须要同一个版本,不然启动会报错. 3. 配置Master数据库 su – postgres /usr/local/pgsql/bin/pg_ ...
- 再不了解PostgreSQL,你就晚了之PostgreSQL主从流复制部署
前言 在MySQL被收购之后,虽然有其替代品为: MariaDB,但是总感觉心里有点膈应.大家发现了另一款开源的数据库: PostgreSQL. 虽然centos自带版本9.2也可以用,但是最近的几次 ...
- postgresql主从同步配置
前言 不久前,公司的一台物理机器硬件坏了,导致运行在其上的虚拟机都挂了.很不凑巧的是,我负责的那台虚拟机的系统盘坏了(ps:感觉老天在玩我),导致里面的数据永远的离我而去(ps:当时我的内心是崩溃的) ...
- postgresql , etcd , patroni 做failover
os: centos 7.4etcd:3.2 主从IP信息192.168.56.101 node1 master192.168.56.102 node2 slave192.168.56.103 nod ...
- CentOS7 PostgreSQL 主从配置( 二)
同步流复制配置PostgreSql的流复制是异步的,缺点是Standby上的数据落后于主库上的数据,如果使用Hot Standby做读写分离,就会存在数据一致性的问题.PostgreSql9.1版本后 ...
- CentOS7 PostgreSQL 主从配置( 一)
主库配置 pg_hba.conf host replication all 10.2.0.0/0 trust postgresql.conf listen_addresses = '*' max_wa ...
- postgresql主从配置
master:10.0.1.114 slaver:10.0.1.116 一.yum安装https://blog.csdn.net/weixin_41048363/article/details/803 ...
- Ubuntu PostgreSql主从切换
主机:192.168.100.70 从机:192.168.100.71 通用配置(即主从都要配置) 修改/etc/postgresql/10/main/pg_hba.conf host all all ...
- Docker部署PostgreSQL主从
#准备 PostgreSQL12.3版本容器两台,部署参考https://www.cnblogs.com/zspwf/p/16113298.html 主库: 192.168.3.14:2200 从库: ...
随机推荐
- 接口没添加@responseBody注解
今天在重写springaop小demo时,发现调用接口时,可以在控制台上正常返回结果,但是页面报错,debug半天,可以看到是调用了modelview的时候出错,找不到视图了.. debug的时候控制 ...
- Arithmetic Slices II - Subsequence LT446
446. Arithmetic Slices II - Subsequence Hard A sequence of numbers is called arithmetic if it consis ...
- 【RabbitMQ】 Java简单的实现RabbitMQ
准备工作 1.安装RabbitMQ,参考[RabbitMQ] RabbitMQ安装 2.新建Java项目,引入RabbitMQ的Maven依赖 <dependency> <group ...
- sqlserver中如何将mdf文件还原到数据库
- Win7 VS2013环境编译CGAL-4.7
看到有人在QQ空间感叹编译CGAL配置折腾了一天时间,自己也想试试,虽然并不打算用,但感觉这库也挺有名的,想必日后用得着,于是着手试着编译. 首先是看一下官网的windows下配置说明 http:// ...
- jitter
release jitter of tasks there is a distinction between the real activation request and the actual ac ...
- 使用hibernate从一方获取多方信息时报错:org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role
引起原因:hibernate加载关联对象的方式有懒加载方式和立即加载方式. 如果在多对一的配置中没有指定加载方式,而一对多的配置中指定了懒加载方式,因此在获取一方是可获取到值,而获取多方时sessio ...
- 作用域的一些说明,static关键词
作用域的一些说明 变量分为全局变量和局部变量.学过C语言的童鞋都知道,全局变量的作用域是整个整个文件.在即使在函数内部也有效,但在php中,如果在函数中使用全局变量,php会认为这个变量没有定义.如果 ...
- 学以致用三----centos7.2基本环境补充
补充: 在上一篇里,加时间戳 echo ‘export HISTTIMEFORMAT ="%F %T `whoami`" ’ >> /etc/profile sourc ...
- 好文推荐系列---------(4)使用Yeoman自动构建Ember项目
好文原文地址:http://segmentfault.com/a/1190000000368881 我决定学习前端开发的效率工具Yeoman.本文将首先介绍Yeoman的基本情况,接着我们会使用Yeo ...