8

db_ha集群添加/删除节点

 1 year ago
source link: https://blog.51cto.com/u_13646489/5757511
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

db_ha集群添加/删除节点

精选 原创

瀚高实验室 2022-10-14 17:07:45 博主文章分类:Highgo DB ©著作权

文章标签 bash 数据库 删除节点 文章分类 MySQL 数据库 阅读数227

瀚高数据库

系统平台: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
  • 打赏
  • 收藏
  • 评论
  • 分享
  • 举报

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK