搜索
查看
编辑修改
首页
UNITY
NODEJS
PYTHON
AI
GIT
PHP
GO
CEF3
JAVA
HTML
CSS
搜索
你好赵伟
这个屌丝很懒,什么也没留下!
关注作者
热门标签
jquery
HTML
CSS
PHP
ASP
PYTHON
GO
AI
C
C++
C#
PHOTOSHOP
UNITY
iOS
android
vue
xml
爬虫
SEO
LINUX
WINDOWS
JAVA
MFC
CEF3
CAD
NODEJS
GIT
Pyppeteer
article
热门文章
1
高效构建机器学习系统_如何构建一个机器学习系统?
2
随机信号功率谱估计方法matlab仿真_随机序列功率谱的周期性matlab
3
程序员使用 ChatGPT的 10 种最佳方式_面向程序员的chatgpt
4
给大家推荐9个专业分享生信技术的公众号
5
基于微信小程序的校园外卖平台设计与实现
6
C# In Unity 中级编程_using unityengine;
7
linux工作目录切换命令文件查看及管理命令_linux 切换文件夹
8
Dubbo入门---搭建一个最简单的Demo框架
9
RuoYi-Vue部署服务器流程_宝塔部署若依ruoyi-vue
10
QT+VS 制作登陆界面_vs+qt创建用户登录界面
当前位置:
article
> 正文
实践部署 repmgr+pg9.6构建高可用性集群_firstshare
作者:你好赵伟 | 2024-02-23 09:47:03
赞
踩
firstshare
环境:
vlnx107001.firstshare.cn primary
vlnx107002.firstshare.cn slave
centos7
postresql9.6
repmgr4.0.5
开启防火墙
firewall-cmd --zone=public --add-port=5432/tcp --permanent
重新载入
firewall-cmd --reload
查看
firewall-cmd --zone=public --query-port=5432/tcp
一
、pg9.6 安装
https://www.postgresql.org/download/linux/redhat/
1、安装存储库rpm包
yum install
https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
2、安装客户端软件包
yum install postgresql96
3、安装服务器软件包
yum install postgresql96-server
4、初始化数据库启用自动启动
/usr/pgsql-9.6/bin/postgresql96-setup initdb
systemctl enable postgresql-9.6
systemctl start postgresql-9.6
安装完毕后
默认数据目录为 :/var/lib/pgsql/9.6/data/
bin二进制文件目录:/usr/pgsql-9.6/bin
或者
直接RPM下载
如果您不能或不想使用基于yum的安装方法,则yum存储库中的所有RPM都可用于
直接下载
和手动安装。
https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/repoview/
[root@vlnx107001 zhaowzh]# wget
https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/postgresql96-9.6.8-1PGDG.rhel7.x86_64.rpm
[root@vlnx107001 zhaowzh]# wget
https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/postgresql96-contrib-9.6.8-1PGDG.rhel7.x86_64.rpm
[root@vlnx107001 zhaowzh]# wget
https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/postgresql96-libs-9.6.8-1PGDG.rhel7.x86_64.rpm
[root@vlnx107001 zhaowzh]# wget
https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/postgresql96-server-9.6.8-1PGDG.rhel7.x86_64.rpm
[root@vlnx107001 zhaowzh]# rpm -i postgresql96-libs-9.6.8-1PGDG.rhel7.x86_64.rpm
[root@vlnx107001 zhaowzh]# rpm -i postgresql96-9.6.8-1PGDG.rhel7.x86_64.rpm
[root@vlnx107001 zhaowzh]# rpm -i postgresql96-contrib-9.6.8-1PGDG.rhel7.x86_64.rpm
[root@vlnx107001 zhaowzh]# rpm -i postgresql96-server-9.6.8-1PGDG.rhel7.x86_64.rpm
二、安装repmgr
[root@vlnx107001 zhaowzh]# wget
https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/repmgr96-4.0.5-1.rhel7.x86_64.rpm
[root@vlnx107001 zhaowzh]# wget
https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/repmgr96-debuginfo-4.0.5-1.rhel7.x86_64.rpm
[root@vlnx107001 zhaowzh]# rpm -i repmgr96-4.0.5-1.rhel7.x86_64.rpm
[root@vlnx107001 zhaowzh]# rpm -i repmgr96-debuginfo-4.0.5-1.rhel7.x86_64.rpm
三、构建 ssh 免密互通(以 vlnx107001上操作为例)
[postgres@vlnx107001 ~]$ ssh-keygen -t rsa
注
不要指定密码,即 空密码即可
将密钥传递到 slave服务器上并验证
[postgres@vlnx107001 ~]$ ssh-copy-id -i .ssh/id_rsa.pub postgres@vlnx107002.firstshare.cn
[postgres@vlnx107001 ~]$ ssh
postgres@vlnx107002.firstshare.cn
date
四、编辑
pg_hba.conf 并重新加载配置
local repmgr repmgr trust
host repmgr repmgr 127.0.0.1/32 trust
host repmgr repmgr 172.31.107.2/32 trust
host repmgr repmgr 172.31.107.1/32 trust
host postgres repmgr 172.31.107.2/32 trust
local replication repmgr trust
host replication repmgr 127.0.0.1/32 trust
host replication repmgr 172.31.107.2/32 trust
host replication repmgr 172.31.107.1/32 trust
[postgres@vlnx107001 data]$ pg_ctl -D $PGDATA reload
五、创建 repmgr账号用来管理 集群维护等操作
为repmgr元数据创建专用的PostgreSQL超级用户帐户和数据库
[postgres@vlnx107001 ~]$ createuser --login --superuser repmgr
[postgres@vlnx107001 ~]$ createdb repmgr -O repmgr
验证是否互通
[postgres@vlnx107002 ~]$ psql -h vlnx107001.firstshare.cn -U repmgr -d postgres -c "select version()"
[postgres@vlnx107002 postgresql]$ psql -h vlnx107001.firstshare.cn -U repmgr -d repmgr -c "select version()"
六、编辑 repmgr.conf 配置文件
[root@vlnx107001 ~]# vim /etc/repmgr/9.6/repmgr.conf
#-----------------------------------------------------------------------------
#zhaowenzhong
#----------------------------------------------------------------------------
log_file='/var/log/repmgr/repmgr.log'
pg_bindir=/usr/pgsql-9.6/bin
promote_command='/usr/pgsql-9.6/bin/repmgr standby promote -f /etc/repmgr/9.6/repmgr.conf'
follow_command='/usr/pgsql-9.6/bin/repmgr standby follow -f /etc/repmgr/9.6/repmgr.conf'
cluster=vpgs107001
node_id=107001
node_name=vlnx107001
conninfo='host=172.31.107.1 dbname=repmgr user=repmgr'
data_directory='/var/lib/pgsql/9.6/data/'
service_start_command = 'sudo systemctl start postgresql-9.6'
service_stop_command = 'sudo systemctl stop postgresql-9.6'
service_restart_command = 'sudo systemctl restart postgresql-9.6'
service_reload_command = 'sudo systemctl reload postgresql-9.6'
ssh_options=-o "StrictHostKeyChecking no"
七、注册主服务
要启用repmgr以支持复制群集,主节点必须注册repmgr。这将安装repmgr 扩展和元数据对象,并为主服务器添加元数据记录:
[postgres@vlnx107001 ~]$ repmgr -f /etc/repmgr/9.6/repmgr.conf primary register
验证集群的状态:
[postgres@vlnx107001 ~]$ repmgr -f /etc/repmgr/9.6/repmgr.conf cluster show
repmgr元数据表中
复制群集中的每个服务器都有自己的记录。如果repmgrd 正在使用,则节点的状态或角色更改时会更新字段upstream_node_id,active和 type。
启动监控
[postgres@vlnx107001 ~]$ repmgrd -f /etc/repmgr/9.6l/repmgr.conf --verbose --monitoring-history > /var/log/repmgr/repmgr.log 2>&1 &
八、克隆备用服务器
vlnx107002 上安装 repmgr 省略 (同上)
配置 repmgr.conf
#----------------------------------------------------------------------------
#zhaowenzhong
#----------------------------------------------------------------------------
log_file='/var/log/repmgr/repmgr.log'
pg_bindir=/usr/pgsql-9.6/bin
promote_command='/usr/pgsql-9.6/bin/repmgr standby promote -f /etc/repmgr/9.6/repmgr.conf'
follow_command='/usr/pgsql-9.6/bin/repmgr standby follow -f /etc/repmgr/9.6/repmgr.conf'
cluster=vpgs107001
node_id=107002
node_name=vlnx107002
conninfo='host=172.31.107.2 dbname=repmgr user=repmgr'
data_directory='/var/lib/pgsql/9.6/data/'
service_start_command = 'sudo systemctl start postgresql-9.6'
service_stop_command = 'sudo systemctl stop postgresql-9.6'
service_restart_command = 'sudo systemctl restart postgresql-9.6'
service_reload_command = 'sudo systemctl reload postgresql-9.6'
ssh_options=-o "StrictHostKeyChecking no"
使用--dry-run选项检查可以克隆的待机状态:
[postgres@vlnx107002 ~]$ repmgr -h vlnx107001.firstshare.cn -U repmgr -d repmgr -f /etc/repmgr/9.6/repmgr.conf -F standby clone --dry-run
开始克隆
[postgres@vlnx107002 ~]$ repmgr -h vlnx107001.firstshare.cn -U repmgr -d repmgr -f /etc/repmgr/9.6/repmgr.conf standby clone
克隆从主PostgreSQL的数据目录中的文件节点 使用PostgreSQL的pg_basebackup效用。 将会自动创建一个recovery.conf文件,其中包含从此主服务器开始流式传输的正确参数。
注意: 默认情况下,主数据目录中的任何配置文件都将被复制到备用数据库。通常这些将是postgresql.conf, postgresql.auto.conf,pg_h
ba.conf和 pg_ident.conf。这些可能需要在待机启动之前进行修改
开启slave
[postgres@vlnx107002 data]$ /usr/pgsql-9.6/bin/pg_ctl -D $PGDATA -l /var/lib/pgsql/9.6/data/pg_log/logfile start
在备用服务器节点上启动监控进程
[postgres@vlnx107002 ~]$ repmgrd -f /etc/repmgr/9.6l/repmgr.conf --verbose --monitoring-history > /var/log/repmgr/repmgr.log 2>&1 &
九、验证是否数据同步
登录 primary
repmgr=# SELECT * FROM pg_stat_replication;
注册备用服务器:
[postgres@vlnx107002 pg_log]$ repmgr -f /etc/repmgr/9.6/repmgr.conf standby register
通过在待机状态下执行repmgr cluster show来检查节点是否已注册:
[postgres@vlnx107002 pg_log]$ repmgr -f /etc/repmgr/9.6/repmgr.conf cluster show
声明:
本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:
https://www.wpsshop.cn/w/你好赵伟/article/detail/135458
推荐阅读
article
api
-
ms
-
win
-
core
-
util
-l1-1-0.
dll
文件缺失的完美解决办法_
api
-
ms
-...
其实很多用户玩单机游戏或者安装软件的时候就出现过这种问题,如果是新手第一时间会认为是软件或游戏出错了,其实并不是这样,其...
赞
踩
article
【
Axure
】使用
中继器
实现登陆
注册
功能_
axure
注册
登录
页面
...
演示效果:1、新建 [
登录
]
页面
,导入做好的手机壳素材,拖放“动态面板”到手机屏幕,命名为“
登录
页动态面板”,面板内包...
赞
踩
article
三子
棋
小游戏
(
C语言
)_
codeblocks
写三子
棋
...
我们在
C语言
阶段,学的差不多就应该有能力写一些
小游戏
来检测我们
C语言
到底学的咋样,恰巧三子
棋
和扫雷应该是每一个程序员都会...
赞
踩
article
Postgre
SQL
排查慢
SQL
_排查慢
查询
...
所谓慢
SQL
是指在数据库中执行时间超过指定阈值的语句。慢
查询
太多,对于业务而言,是有很大风险的,可能随时都会因为某种原...
赞
踩
article
自动化
上位机开发
C#
100
例:如何用
面向对象
的方式封装雷赛
运动
控制
卡
EtherCAT
总线
卡
(
C#
代码...
自动化
上位机开发
C#
100
例:雷赛
运动
控制
卡
EtherCAT
总线
卡
C#
封装类。
自动化
上位机开发
C#
100
例:如何用面向对...
赞
踩
article
Java
开发关于UI
界面
_
Android
开发1:基本UI
界面
设计——布局和
组件
...
前言啦啦啦~本学期要开始学习
Android
开发啦~博主在开始学习前是完完全全的小白,只有在平时完成老师要求的实验的过程中...
赞
踩
article
神器
Typora
开始收费
,
是
什么给了它底气?
_
typora
要钱吗...
支持 ARM 版本 Windows 和 Linux在编辑数学公式时提供开关来支持
是
否开启使用 \ 来换行新版本有 15 ...
赞
踩
article
教程|
Unity
中
使用
Tilemap
快速创建2D游戏世界_
unity
ruletile
草地...
教程|
Unity
中
使用
Tilemap
快速创建2D游戏世界本篇文章是
Unity
的技术团队给大家做的关于在
Unity
中如何使...
赞
踩
article
人工
智能
概述(1)
机器
学习
_
智能
机器
人是一种特殊
的
机器
学习
可以用自动
学习
得到
的
特征...
本文从宏观
的
视角介绍了
人工
智能
,
机器
学习
在
人工
智能
领域
的
关系,以及
机器
学习
的
各种基本知识,包括训练方法,数据
的
种类等等,...
赞
踩
article
Postgresql
排序
与
limit
组合场景性能极限
优化
_
posterger
limit
...
构造测试数据create table tbl(id int, num int, arr int[]); create i...
赞
踩
article
devexpress
控件
教程
开发
workflow
设计
器这么简单_
devexpress
工作
流...
今天我们使用DevExpress的
控件
,来实现
工作
流模板
设计
器。新建Form页面,继承DevExpress.XtraDi...
赞
踩
article
基于
matlab
仿真
的
功率因数
测定方法
研究,基于
MATLAB
的
高
功率因数
整流器
仿真
实验平台研究......
1 概述 简单系统可直接建立模型,并分析模块之间
的
相互关系以及模块输入输出关系。但对相对复杂
的
系统,Simulink包含...
赞
踩
article
ChatGPT
+
大
数据
,
会
有
怎样
的
火花?...
ChatGPT
到底
有
什么用?能和
大
数据
擦出怎样
的
火花?
大
家好
,
我是独孤风
,
一位曾经
的
港口煤炭工人
,
目前在某国企任
大
数据
负...
赞
踩
article
2024年
华为
OD
机试真题-
按
身高
和
体重
排队-
Java
-
OD
统一考试(C卷)...
某学校举行运动会,学生们
按
编号(1、2、3…n)进行标识,现需要
按
照
身高
由低到高排列,对
身高
相同的人,
按
体重
由轻到重排列...
赞
踩
article
PostgreSQL:开启慢
日志
|
查询
日志
位置|
查询
data
文件
夹
位置|
查询
config
文件
位置_p...
0. 引言最近在开启
postgres
ql慢
日志
时,定位相关
文件
位置花费了一些功夫,特此记录,供后续有需要的同学参考1. ...
赞
踩
article
R语言无法调用
stats
.dll的问题解决---
unable
to
load
shared
obje...
不知道什么原因,可能是加载了R
to
ols以后,重启Rstudio安装bioconduc
to
r包的时候突然报错“unabl...
赞
踩
article
基于
three
js
+
CSS
3D
Renderer
的
3D
全景_
three
.
js
css3render
...
基于
three
js
+
CSS
3D
Renderer
的
3D
全景可以理解为将相机置放在一个立方体内,调整相机的位置可以拍摄到...
赞
踩
article
SqlSugar
ORM
入门
(
简介
和
增删查改)...
SqlSugar
ORM
入门必看_sqlsugar ormsqlsugar orm 背景 Sq...
赞
踩
article
java
:
无法访问
org
.
springframework
.
web
.
bind
.
annotation
....
java
:
无法访问
org
.
springframework
.
web
.
bind
.
annotation
.RequestMap...
赞
踩
article
Fatal erro:Emula
to
r message:User
data
is
written
i...
Fatal erro:Emula
to
r message:User
data
is
written
in
the
moni...
赞
踩
相关标签
windows
数学建模
sqlserver
axure
postgresql
sql
数据库
自动化
c#
上位机
运动控制
Java开发关于UI界面
人工智能
Typora
编辑器
机器学习
深度学习
自然语言处理
计算机视觉
postgresql优化
排序
limit
优化
ecmascript