HG_REPMGR configure配置
目录
文档用途
详细信息
相关文档
文档用途
HG_REPMG配置参考
详细信息
一、系统要求
HG_Repmgr 支持 Linux 和 Windows 操作系统。推荐操作系统使用 Redhat/CentOs 7.0 及以上版本。
二、环境准备
以下步骤,如无特殊说明,均需在所有节点执行。
1. 配置防火墙和 SELinux 请关闭防火墙和 SELinux 并关闭开机自启。
2. 修改主机名
3. 配置 IP 地址
4. 修改/etc/hosts
5. 时间同步 配置三个节点的时间同步,建议配置 NTP 时间服务器。(详细步骤略)
6. 创建用户 在所有节点创建相同的系统用户 highgo,使用该用户安装 HighGo DB V5。
7. 设置互信 在所有节点间设置 highgo 用户互信。
8. 安装 HighGo DB V5 使用 highgo 用户安装 HighGo DB V5。(详细步骤略) 推荐使用 HighGo DB 5.0 及以上版本,所有节点的数据库版本必须一致。
3 配置 HG_REPMGR
1. 设置 HGDB 的环境变量,确保 pg_config 在$PATH 中(所有节点)
vi .bash_profile export PGPORT=5866 export PGDATA=/home/highgo/hgdb/data export HGDB_HOME=/home/highgo/hgdb export LD_LIBRARY_PATH=/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/ lib:/usr/local/lib:$HGDB_HOME/lib export PATH=$HOME/bin:$HGDB_HOME/bin:$PATH export HG_BASE=/home/lmy/highgo/diag source .bash_profile |
注意:
[highgo@dbrs ~]$ ssh dbrs2 ssh: /opt/highgo/5.6.1/lib/libcrypto.so.10: version `OPENSSL_1.0.2' not found (required by ssh) [highgo@dbrs ~]$ 此问题解决方案,把/opt/highgo/5.6.1/lib放到系统环境变量的后面 |
2. 清空备节点的 data 目录(所有备节点)
pg_ctl stop cd $PGDATA rm –r * |
3 设置 HGDB 参数并重启数据库(仅主节点)
cd $PGDATA vi postgresql.replication.conf listen_addresses='*' log_destination = 'csvlog' logging_collector = on log_directory = 'log' log_filename = 'highgodb-%Y-%m-%d_%H%M%S.log' max_wal_senders = 10 wal_level = 'hot_standby' hot_standby = on wal_log_hints = on archive_mode = on #archive_directory = '/opt/highgo/5.6.1/arch' archive_command = 'cp %p /opt/highgo/5.6.1/arch' wal_keep_segments = 5000 |
需要的目录需要创建出来
mkdir $PGHOME/arch |
将该文件包含到 postgresql.conf 中:
vi postgresql.conf include 'postgresql.replication.conf' |
重启数据库
pg_ctl restart |
4. 为 HG_Repmgr 创建用户和数据库(仅主节点)
createuser -P -s hgrepmgr -->将密码设置为 highgo createdb hgrepmgr -O hgrepmgr |
5. 配置 pg_hba.conf(仅主节点) 在 pg_hba.conf 中追加:
# cus host replication hgrepmgr 192.168.90.0/24 md5 host hgrepmgr hgrepmgr 192.168.90.0/24 md5 |
重新加载
pg_ctl reload |
6. 配置密码文件(所有节点) 在所有节点使用 highgo 用户创建密码文件:
vi ~/.pgpass dbrs:5866:replication:hgrepmgr:highgo dbrs:5866:hgrepmgr:hgrepmgr:highgo dbrs2:5866:replication:hgrepmgr:highgo dbrs2:5866:hgrepmgr:hgrepmgr:highgo 修改文件权限: chmod 0600 .pgpass |
7. 测试主端数据库是否可达(所有备节点)
psql 'host=dbrs user=hgrepmgr dbname=hgrepmgr connect_timeout=2' [highgo@dbrs2 ~]$ psql 'host=dbrs user=hgrepmgr dbname=hgrepmgr connect_timeout=2' psql (5.6.1) Type "help" for help. hgrepmgr=# |
备节只需安装软件,调用psql可以连接主库。
3.2 配置 HG_Repmgr
1. 修改配置文件(仅主节点) 修改$HGDB_HOME/conf 中的 hg_repmgr.conf 文件,内容如下:
node_id=1 node_name=dbrs conninfo='host=dbrs user=hgrepmgr dbname=hgrepmgr connect_timeout=2' data_directory='/opt/highgo/5.6.1/data' pg_bindir='/opt/highgo/5.6.1/bin' passfile='/home/highgo/.pgpass' |
2 注册主节点(仅主节点)
repmgr primary register [highgo@dbrs conf]$ repmgr -f /opt/highgo/5.6.1/conf/hg_repmgr.conf primary register INFO: connecting to primary database... NOTICE: attempting to install extension "repmgr" NOTICE: "repmgr" extension successfully installed NOTICE: primary node record (id: 1) registered [highgo@dbrs conf]$ repmgr cluster show [highgo@dbrs conf]$ repmgr -f /opt/highgo/5.6.1/conf/hg_repmgr.conf cluster show ID | Name | Role | Status | Upstream | Location | Connection string ----+------+---------+-----------+----------+----------+----------------------------------------------------------- 1 | dbrs | primary | * running | | default | host=dbrs user=hgrepmgr dbname=hgrepmgr connect_timeout=2 [highgo@dbrs conf]$ |
提示:
Repmgr v4.7版本:默认路径不认,需要手动指定 -f
不指定-f的话,把hg_repmgr.conf 拷贝到以下路径里
3.3 克隆并注册备节点(所有备节点)
1)修改配置文件 修改 node2 的$HGDB_HOME/conf 中 hg_repmgr.conf 文件,内容如下:
node_id=2 node_name=dbrs2 conninfo='host=dbrs2 user=hgrepmgr dbname=hgrepmgr connect_timeout=2' data_directory='/opt/highgo/5.6.1/data' pg_bindir='/opt/highgo/5.6.1/bin' passfile='/home/highgo/.pgpass' |
其他节点类似,更改上述配置文件中的
node_id、node_name和conninfo。
2)检查备节点是否可被克隆 (备节点执行、 -h指的主节点,想想流复制配置pg_basebackup)
repmgr -f /opt/highgo/5.6.1/conf/hg_repmgr.conf -h dbrs -U hgrepmgr -d hgrepmgr standby clone --dry-run [highgo@dbrs2 ~]$ repmgr -f /opt/highgo/5.6.1/conf/hg_repmgr.conf -h dbrs -U hgrepmgr -d hgrepmgr standby clone --dry-run NOTICE: destination directory "/opt/highgo/5.6.1/data" provided INFO: connecting to source node DETAIL: connection string is: host=dbrs user=hgrepmgr dbname=hgrepmgr DETAIL: current installation size is 1437 MB NOTICE: standby will attach to upstream node 1 HINT: consider using the -c/--fast-checkpoint option INFO: all prerequisites for "standby clone" are met [highgo@dbrs2 ~]$ |
3)克隆备节点 (备节点执行、 -h指的主节点,想想流复制配置pg_basebackup)
repmgr -f /opt/highgo/5.6.1/conf/hg_repmgr.conf -h dbrs -U hgrepmgr -d hgrepmgr standby clone [highgo@dbrs2 ~]$ repmgr -f /opt/highgo/5.6.1/conf/hg_repmgr.conf -h dbrs -U hgrepmgr -d hgrepmgr standby clone NOTICE: destination directory "/opt/highgo/5.6.1/data" provided INFO: connecting to source node DETAIL: connection string is: host=dbrs user=hgrepmgr dbname=hgrepmgr DETAIL: current installation size is 1437 MB INFO: checking and correcting permissions on existing directory "/opt/highgo/5.6.1/data" NOTICE: starting backup (using pg_basebackup)... HINT: this may take some time; consider using the -c/--fast-checkpoint option INFO: executing: /opt/highgo/5.6.1/bin/pg_basebackup -l "repmgr base backup" -D /opt/highgo/5.6.1/data -h dbrs -p 5866 -U hgrepmgr -X stream NOTICE: standby clone (using pg_basebackup) complete NOTICE: you can now start your PostgreSQL server HINT: for example: pg_ctl -D /opt/highgo/5.6.1/data start HINT: after starting the server, you need to register this standby with "repmgr standby register" [highgo@dbrs2 ~]$ [highgo@dbrs2 ~]$ |
4)启动并注册备节点
pg_ctl -D /opt/highgo/5.6.1/data start repmgr -f /opt/highgo/5.6.1/conf/hg_repmgr.conf standby register [highgo@dbrs2 ~]$ repmgr -f /opt/highgo/5.6.1/conf/hg_repmgr.conf standby register INFO: connecting to local node "dbrs2" (ID: 2) INFO: connecting to primary database WARNING: --upstream-node-id not supplied, assuming upstream node is primary (node ID 1) INFO: standby registration complete NOTICE: standby node "dbrs2" (id: 2) successfully registered [highgo@dbrs2 ~]$ |
更多详细信息请登录【瀚高技术支持平台】查看瀚高技术支持平台
HG_REPMGR configure配置相关推荐
- linux 编译配置文件,Linux程序源码编译安装的configure配置详解
Linux环境下,如果通过源代码编译安装程序的简单过程可以 描述为:./configure-->make-->make install.其中./configure配置脚本功能就是对你的系统 ...
- configure配置脚本的使用
Linux下软件的安装一般由3个步骤组成: ./configure --host=arm-linux ... //配置make //编译make install //安装 若取消编译: make cl ...
- configure 配置参数说明
configure 配置参数说明 1 说明 2 开发环境 3 configure参数说明 3.1 查看configure 配置选项 3.2 参数说明 3.2.1 build 参数 3.2.2 host ...
- Linux程序源码编译安装的configure配置详解
Linux环境下,如果通过源代码编译安装程序的简单过程可以描述为:./configure–>make–>make install.其中./configure配置脚本功能就是对你的系统做很多 ...
- configure - 配置源代码树
configure脚本配置Apache的源代码树并且将其安装到指定的平台上.丰富的选项允许你根据自己的特定状况和特定需求对Apache进行定制. 这个脚本位于源代码树的根目录下,并且只能用于类Unix ...
- 【AWSL】之Linux源代码编译及配置yum源(tar 解包、./configure配置软件模块、make)
源代码编译 序言 一.源代码概述 1.使用源代码安装软件的优点 2.应用场合举例 3.安装源代码软件为什么使用编译安装 二.编译安装的基本思路 三.配置本地yum源仓库 四.`yum常用命令` 五.` ...
- php源码安装配置,php源码安装时configure配置参数 | 学步园
在Linux下安装PHP,源代码方式安装,总需要配置很多参数.这里列出常用配置参数,并详细用中文解释说明了. 给大家一些参考./configure –prefix=/usr/local/PHP ...
- php怎么配置configure,PHP编译参数configure配置详解(持续更新中)
编译参数-使用 ./configure -h 在源代码目录中,该命令可以查看所有编译参数以及对应的英文解释 编译参数-说明 --prefix=/opt/php //指定 php 安装目录 --with ...
- php7 configure 参数,PHP编译参数configure配置详解
编译参数-使用 ./configure -h 在源代码目录中,该命令可以查看所有编译参数以及对应的英文解释 编译参数-说明 --prefix=/opt/php //指定 php 安装目录 --with ...
- configure配置安装详解
由于最近项目需要在HMI层生成二维码,所以去网上找了第三方开源库.可是下载下来里面都是源码,没有动态库或者静态库,所以就需要自己去编译生成.源码库中只有一个configure的可运行得配置脚本,之前用 ...
最新文章
- EOJ Monthly 2018.1
- 开源OSS.Social微信项目进阶介绍
- C# 空合并运算符 ??
- linux中断响应时间太慢_linux+arm系统学习与基础学习
- 科目三电子路考细节部分
- 力扣--349两个数组的交集I-II
- android 设备标识
- 机器算法基础——回归分析
- 也来说说电影《少年班》中周知庸问王大法的问题
- 2020年最好用的离线下载网盘,不限速度和空间
- 注册公司流程和费用(2016版)
- 高德地图中缩放级别(zoom)和比例尺(getScalePerPixel)之间的计算关系
- win10安装消息队列服务器,win10下celery搭建使用
- Xilinx 7系列FPGA收发器架构之硬件设计指导(一)
- DNA sequence HDU 1560
- 实现Photoshop液化工具箱中向前变形工具
- 字符串为null 和 字符串长度为0
- mysql 数据截断,注意Mysql数据截断
- 音视频开发为什么要学SRS流媒体服务器
- 小程序推送服务通知(前后端代码)