目录

文档用途

详细信息

相关文档

文档用途

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配置相关推荐

  1. linux 编译配置文件,Linux程序源码编译安装的configure配置详解

    Linux环境下,如果通过源代码编译安装程序的简单过程可以 描述为:./configure-->make-->make install.其中./configure配置脚本功能就是对你的系统 ...

  2. configure配置脚本的使用

    Linux下软件的安装一般由3个步骤组成: ./configure --host=arm-linux ... //配置make //编译make install //安装 若取消编译: make cl ...

  3. configure 配置参数说明

    configure 配置参数说明 1 说明 2 开发环境 3 configure参数说明 3.1 查看configure 配置选项 3.2 参数说明 3.2.1 build 参数 3.2.2 host ...

  4. Linux程序源码编译安装的configure配置详解

    Linux环境下,如果通过源代码编译安装程序的简单过程可以描述为:./configure–>make–>make install.其中./configure配置脚本功能就是对你的系统做很多 ...

  5. configure - 配置源代码树

    configure脚本配置Apache的源代码树并且将其安装到指定的平台上.丰富的选项允许你根据自己的特定状况和特定需求对Apache进行定制. 这个脚本位于源代码树的根目录下,并且只能用于类Unix ...

  6. 【AWSL】之Linux源代码编译及配置yum源(tar 解包、./configure配置软件模块、make)

    源代码编译 序言 一.源代码概述 1.使用源代码安装软件的优点 2.应用场合举例 3.安装源代码软件为什么使用编译安装 二.编译安装的基本思路 三.配置本地yum源仓库 四.`yum常用命令` 五.` ...

  7. php源码安装配置,php源码安装时configure配置参数 | 学步园

    在Linux下安装PHP,源代码方式安装,总需要配置很多参数.这里列出常用配置参数,并详细用中文解释说明了. 给大家一些参考./configure –prefix=/usr/local/PHP     ...

  8. php怎么配置configure,PHP编译参数configure配置详解(持续更新中)

    编译参数-使用 ./configure -h 在源代码目录中,该命令可以查看所有编译参数以及对应的英文解释 编译参数-说明 --prefix=/opt/php //指定 php 安装目录 --with ...

  9. php7 configure 参数,PHP编译参数configure配置详解

    编译参数-使用 ./configure -h 在源代码目录中,该命令可以查看所有编译参数以及对应的英文解释 编译参数-说明 --prefix=/opt/php //指定 php 安装目录 --with ...

  10. configure配置安装详解

    由于最近项目需要在HMI层生成二维码,所以去网上找了第三方开源库.可是下载下来里面都是源码,没有动态库或者静态库,所以就需要自己去编译生成.源码库中只有一个configure的可运行得配置脚本,之前用 ...

最新文章

  1. pandas使用sort_index函数按照索引排序对dataframe的数据行进行排序(sort dataframe rows by index)
  2. 推荐系统正成为所有领域的一种标配
  3. linux如何搭建mqtt服务器,【MQTT】在Ubuntu下搭建MQTT服务器
  4. cogs2840. 二叉查找树
  5. 全面永久退出!又一巨头被逼上绝路!
  6. 活动目录的灾难恢复操作指导之三
  7. oracle中创建一个用户,只能查看指定的视图,如何授权,创建别名
  8. vi-vim :删除、撤销、恢复删除、复制删除
  9. ThinkPHP3.2 常量参考
  10. 【cocos2d-x 手游研发小技巧(4)与Android混编实现换“头像图片”】
  11. 5个冷门的MacOS快捷键,小众但好用
  12. Java Persistence with MyBatis 3(中文版) 第二章 引导MyBatis
  13. python读取properties文件_读取properties文件
  14. c语言第三章重点知识点总结,c语言重点知识点总结
  15. 服务器与客户端的简单实现
  16. 2022 google chrome 翻译DNS
  17. 中国农业机械融资租赁市场预测与投资战略报告(2023版)
  18. XSS(Cross Site Scripting)攻击简介
  19. 【PX4-AutoPilot教程-1】PX4源码文件目录架构分析
  20. 5个简历模板下载及制作网站

热门文章

  1. 杆刚度校核c语言程序,c语言 求解单元刚度矩阵
  2. 74LV165与74HC595 使用
  3. 多旋翼飞行器设计与控制(四) —— 动力系统建模与估计
  4. php探针不显示ip,php探针代码_PHP探针获取客户端信息
  5. 阿里云php探针,X 探针(刘海探针)开源 PHP 探针介绍
  6. Ubuntu 系列学习(四)ubuntu 22.04 安装 微信、QQ
  7. oracle考试试题及其答案,Oracle期末考试试题及答案-
  8. matlab 大数阶乘,紧急求助:怎么用matlab计算1000的阶乘啊?
  9. php 连接timesten,timesten常见的一些简单问题
  10. 解决django传递URL报错Specifying a namespace in include() without providing an app_name is not supported.