瀚高数据库
目录
环境
文档用途
详细信息
环境
系统平台:Linux x86-64 Red Hat Enterprise Linux 7
版本:4.5.7
文档用途
本文档用于指导db_ha集群添加/删除节点操作。
详细信息
1、新增节点安装和其他节点同版本数据库
rpm -ivh hgdb4.5.7-see-centos7-x86-64-20220307.rpm
2、安装集群软件
rpm -ivh db_ha4.1.1-see-centos7-x86_64.rpm
3、搭建流复制并启动数据库
pg_basebackup -h 192.168.80.228 -U sysdba -D /opt/HighGo4.5.7-see/data -Fp -P -Xs -R -v
pg_ctl start
4、检查该节点流复制状态
ps -ef | grep -v grep | grep walreceive
root 5584 5577 0 10:52 ? 00:00:17 postgres: ha: walreceiver streaming 0/CE000000
5、从主节点将相关配置文件复制过来
scp /usr/local/db_ha/conf/agent.conf root@ip:/usr/local/db_ha/conf
scp /usr/local/db_ha/conf/agent.conf root@io:/etc/sysconfig
scp /usr/local/db_ha/self_start_service/db_ha-agent.service root@ip:/usr/local/db_ha/self_start_service
scp /usr/local/db_ha/self_start_service/db_ha-agent.service root@ip:/lib/systemd/system
scp /usr/local/db_ha/conf/db_ha.conf root@ip:/usr/local/db_ha/conf
scp ~/.pgpass root@ip:/root
scp ~/.bash_profile root@ip:/root
注意:
确认一下环境变量是否是.bash_profile,也有可能是.bashrc
6、新增节点更改密码文件权限,环境变量生效,设置agent服务开机自启动
chmod 0600 ~/.pgpass
source ~/.bash_profile
systemctl daemon-reload
systemctl enable db_ha-agent.service
7、新增节点启动agent,并加入集群
/usr/local/db_ha/bin/agent /usr/local/db_ha/conf/agent.conf
db_ha add 192.168.80.230 6666 -f /usr/local/db_ha/conf/db_ha.conf -n ha -p 5866 -s
参数注解:
-a, Example Add a standby asynchronization node
-s, Example Add a standby synchronization node
-n [application name], Specifies the application name
8、检查集群
/usr/local/db_ha/bin/db_ha select -f /usr/local/db_ha/conf/db_ha.conf
connect monitor success
cluster num = 3 secondary monitor is normal
nodeip=192.168.80.228,nodetype=PRIMARY,replicationName=node1 streamingType=NONE streamingState=none healthy=t agentState=NORMAL
nodeip=192.168.80.230,nodetype=STANDBY,replicationName=ha streamingType=SYNC streamingState=streaming healthy=t agentState=NORMAL
nodeip=192.168.80.229,nodetype=STANDBY,replicationName=ha streamingType=SYNC streamingState=streaming healthy=t agentState=NORMAL
9、删除节点
db_ha delete 192.168.80.230 -f /usr/local/db_ha/conf/db_ha.conf
注意:
①删除节点,集群不会监控该节点,但是该节点数据库运行正常,且正常通过流复制同步数据。
②如果完全删除该节点,做好数据备份,停库,卸载即可。
pg_ctl stop
rpm -e hgdb-see-4.5.7