【我和openGauss的故事】为集群增加VIP
lqkitten openGauss 2023-08-04 18:01 发表于四川
openGauss发布以来,原生支持一主多备,RTO<10S,高可用性能大大增强。自openGauss3.0开始,更新了集群管理套件CM,易用性也得到了提高。但对于客户端来说,数据库端的切换,需要手工完成。
openGauss增加VIP后,客户端的连接就如连接ORACLE RAC的scan VIP一样,对于服务端的切换无感知。
要使用VIP,可以在安装前规划,在配置文件中指定,也可以对已安装的集群进行手工增加。下面就测试手工增加方法。
1.已安装集群的相关信息
数据库版本 gsql -V gsql (openGauss 5.0.0 build a07d57c3) compiled at 2023-03-29 03:37:13 commit 0 last mr
集群状态
[omm@db1 srv]$ cm_ctl query -Cv [ CMServer State ] node instance state ----------------------- 1 db1 1 Primary 2 db2 2 Standby 3 db3 3 Standby [ Cluster State ] cluster_state : Normal redistributing : No balanced : Yes current_az : AZ_ALL [ Datanode State ] node instance state | node instance state | node instance state --------------------------------------------------------------------------------------------------------- 1 db1 6001 P Primary Normal | 2 db2 6002 S Standby Normal | 3 db3 6003 S Standby Normal [omm@db1 srv]$ gs_om -t status --detail [ CMServer State ] node node_ip instance state ----------------------------------------------------------------------- 1 db1 192.168.56.11 1 /opt/huawei/data/cmserver/cm_server Primary 2 db2 192.168.56.12 2 /opt/huawei/data/cmserver/cm_server Standby 3 db3 192.168.56.13 3 /opt/huawei/data/cmserver/cm_server Standby [ Cluster State ] cluster_state : Normal redistributing : No balanced : Yes current_az : AZ_ALL [ Datanode State ] node node_ip instance state ------------------------------------------------------------------------- 1 db1 192.168.56.11 6001 /opt/huawei/install/data/dn P Primary Normal 2 db2 192.168.56.12 6002 /opt/huawei/install/data/dn S Standby Normal 3 db3 192.168.56.13 6003 /opt/huawei/install/data/dn S Standby Normal
2.给omm用户增加sudo权限,三台机器都执行
echo “omm ALL=(ALL) NOPASSWD:ALL”>>/etc/sudoers
3. 在主库上添加VIP
添加前
[omm@db1 cm_agent]$ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00