搜索
查看
编辑修改
首页
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
centos(18)-putty/winscp实现ssh密钥登录_winscp 证书登录
2
运行android工程时出现INSTALL_PARSE_FAILED_NO_CERTIFICATES
3
是否还在为找不到合适的GPT网站而烦恼?不用担心,这里有一些值得一看的汇总!_哪里可以找到gpt
4
vscode远程连接机器开发,总显示setting up: downloading vs code server
5
在国内如何使用某知名GPT,附在线体验链接
6
GetShell的姿势总结
7
3秒开服《幻兽帕鲁》!如何抓住游戏背后的云计算机遇?
8
Solr空间搜索原理分析与实践_空间检索原理
9
wordpress主题速度_提升WordPress速度和性能的终极指南
10
Leetcode 417 题 太平洋大西洋水流问题
当前位置:
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
谈谈
SqlSurgar
:
深入探析内在机制
_
sqlsugar
defaultdbtypemapper
...
前言sqlsurgar自称是最简单,最高效的ORM框架。其他的暂且不考究,只有几百KB的大小可以说是非常轻量级的,昨日看...
赞
踩
article
mybatis
环境搭建启动
Exception
in
thread “ma
in
” FATAL ERRO...
刚刚开始接触框架,尽管跟着视频学习,但也免不了有“手贱打错”和版本差异带来的小问题。下面我给大家分享一下我动手搭建myb...
赞
踩
article
“
抖音
盒子
”
APP
低调上线
,
这不是
始料未及
,
而是
蓄谋已久
_
抖音
魔盒app源码...
抖音
要做独立电商的消息已经陆陆续续传了半年多了
,
而就在12月16日
,
抖音
电商独立
APP
——
抖音
盒子
在iOS和安卓系统正式...
赞
踩
article
Three
.
js
前端
3D
开发:
使用
CSS
3D
Renderer
渲染
全景图
...
此实例主要通过
使用
THREE.
CSS
3D
Renderer
和 THREE.CSS
3D
Object,实现以鼠标拖曳方式在...
赞
踩
article
比较几种步进
电机
加
减速
控制
方案_指数型
加
减速
曲线
的原理及应用...
加
减速
算法是运动
控制
中的关键技术之一,也是实现高速、高效率的关键因素之一。在工业
控制
中,一方面要求
加
工的过程平滑、稳定,...
赞
踩
article
自动化
上位机开发
C#
100
例:如何用
面向对象
的方式封装雷赛
运动
控制
卡
EtherCAT
总线
卡
(
C#
代码...
自动化
上位机开发
C#
100
例:雷赛
运动
控制
卡
EtherCAT
总线
卡
C#
封装类。
自动化
上位机开发
C#
100
例:如何用面向对...
赞
踩
article
postgresql
安装
以后
服务
未
监听
或者启动后又关闭的解决方法_
乌班图
安装
pgsql
后没
监听
...
好久没有写博客了,感慨很多啊。 今天
安装
postgresql
,又出现老毛病。提示“
服务
器未
监听
”,查了一下资料是
服务
器未...
赞
踩
article
Axure
RP
8
基础教程-制作
下拉
菜单
_
axure
rp
8
设置点击
下拉
菜单
再次点击收回
菜单
...
动态面板是
Axure
RP
8
中的一款高级组件,在隐藏与显示、滑动效果 、拖动效果、多状态效果切换等操作的场景中,动态面...
赞
踩
article
Typora
开始收费
了
,
这
可
咋整?
_
typora
多少钱...
知乎上有个提问:「Mac上最好的Markdown文本编辑器是什么?」其中
,
答案为
Typora
的匿名用户获得
了
267 个...
赞
踩
article
记一次
PostgreSQL
数据
库
超级慢故障排除_
pg
修改几百
行
数据
的
表特别卡...
title: 记一次
PostgreSQL
数据
库
超级慢故障排除categories:
数据
库
tags:- PostgreS...
赞
踩
article
VS2015
创建
其他
对象
所用
编译器
旧的
编译器
创建
的;请重新生成旧的
对象
和库问题调试_是
使用
比
创建
其...
按各大博主所说:项目属性->常规->项目默认值->全程序优化将这里的默认项“
使用
链接时间代码生成”改为“无全程序优化“,...
赞
踩
article
XAF
如何
将
文件
存储
在
文件
系统
中而不是
数据库
中...
How to store files in the file system, instead of the databa...
赞
踩
article
GIT
实战篇,教你如何
使用
GIT
可视化
工具
_
github
绿色
按钮
可视化
操作
...
经过前三期的学习,不管是
GIT
模型还是
GIT
命令,相信大家都已经有了比较全面的了解。当然,尽管
GIT
命令永远是最强大而全...
赞
踩
article
unity
解包
_【
Unity
游戏
客户端框架搭建】五
、
热
更新
...
前言
游戏
上线后,难免会有一些测试阶段没发现的bug,bug这东西,可大可小。如果没有
热
更,
更新
一点问题就需要玩家去商店...
赞
踩
article
百面
嵌入式
专栏(
岗位
分析
)
海康
高级
linux
开发
工程师
分析
...
百面
嵌入式
专栏(
岗位
分析
)
海康
高级
linux
开发
工程师
分析
...
赞
踩
article
Mac版的MAT启动报错
java
.
lang
.IllegalStateException: The p...
打开报错日志,可以看到如下信息:没有指定-data信息。解决方法找到以下路径(根据自己的安装路径)中的MemoryAna...
赞
踩
article
postgres
explain
可视化
分析神器_
sql
执行
计划
可视化
工具...
该工具提供了一个简单易用的界面,用户可以通过它将他们的 SQL 查询提交给 Explain.dalibo.com,该工具...
赞
踩
article
Postgresql
ODBC
驱动,用
sqlserver
添加
dblink
跨库访问
postgresql
...
在同样是SQLserver
数据库
跨库访问时,只需要以下方法declare @rowcount intset @rowco...
赞
踩
article
【
C#
】
IQueryable
和
IEnumerable
的区别和互相转换_
iqueryable
转化为is...
【
C#
】
IQueryable
和
IEnumerable
的区别1.
IQueryable
接口是继承自
IEnumerable
的接...
赞
踩
article
java
整合
onlyoffice
的各种坑_the
document
security
token
i...
onlyoffice
_the
document
security
token
is not correctly form...
赞
踩
相关标签
sql
mybatis
java
spring
产品运营
经验分享
前端
javascript
3d
步进电机
加减速
自动化
c#
上位机
运动控制
postgresql
服务器
百度
file
axure
原型工具
Java程序员
编程
程序人生