首页 > 其他分享 >【我和openGauss的故事】为集群实现VIP

【我和openGauss的故事】为集群实现VIP

时间:2023-08-07 10:33:04浏览次数:49  
标签:00 cm forever 192.168 lft VIP 集群 ff openGauss

【我和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
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:04:f9:a3 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
       valid_lft 74572sec preferred_lft 74572sec
    inet6 fe80::c8c2:7f4c:914f:a32d/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:50:47:12 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.11/24 brd 192.168.56.255 scope global noprefixroute enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::890a:d968:b65d:f59a/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
 ifconfig enp0s8:15400 192.168.56010 netmask 255.255.255.0 up

添加后

[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
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:04:f9:a3 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
       valid_lft 74572sec preferred_lft 74572sec
    inet6 fe80::c8c2:7f4c:914f:a32d/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:50:47:12 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.11/24 brd 192.168.56.255 scope global noprefixroute enp0s8
       valid_lft forever preferred_lft forever
  inet 192.168.56.10/24 brd 192.168.56.255 scope global secondary enp0s8:15400
   inet6 fe80::890a:d968:b65d:f59a/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

4.给集群添加VIP资源 VIP作为openGauss的资源管理

[omm@db2 cm_agent]$cm_ctl res --add --res_name="VIP_az1" --res_attr="resources_type=VIP,float_ip=192.168.56.10"
cm_ctl: add res(VIP_az1) success.

将每个实例加到资源中

[omm@db2 cm_agent]$ cm_ctl res --edit --res_name="VIP_az1" --add_inst="node_id=1,res_instance_id=6001" --inst_attr=base_ip=192.168.56.11
cm_ctl: edit res(VIP_az1) success.
  
[omm@db2 cm_agent]$ cm_ctl res --edit --res_name="VIP_az1" --add_inst="node_id=2,res_instance_id=6002" --inst_attr=base_ip=192.168.56.12
cm_ctl: edit res(VIP_az1) success.

[omm@db2 cm_agent]$ cm_ctl res --edit --res_name="VIP_az1" --add_inst="node_id=2,res_instance_id=6003" --inst_attr=base_ip=192.168.56.13
cm_ctl: edit res(VIP_az1) success.

查询VIP在哪个节点

[omm@db3 ~]$ cm_ctl show

[  Network Connect State  ]

Network timeout:       6s
Current CMServer time: 2023-08-03 06:18:42
Network stat('Y' means connected, otherwise 'N'):
|  \  |  Y  |  Y  |
|  Y  |  \  |  Y  |
|  Y  |  Y  |  \  |


[  Node Disk HB State  ]

Node disk hb timeout:    200s
Current CMServer time: 2023-08-03 06:18:43
Node disk hb stat('Y' means connected, otherwise 'N'):
|  N  |  N  |  N  |

[  FloatIp Network State  ]

node   instance base_ip       float_ip_name float_ip
----------------------------------------------------------
1  db1 6001     192.168.56.11 VIP_az1       192.168.56.10

模拟主节点故障

[omm@db3 ~]$ cm_ctl stop -n 1
cm_ctl: stop the node: 1.
cm_ctl: stop node, nodeid: 1
...........
cm_ctl: stop node successfully.

主节点切换到节点2,VIP也到了节点2

[omm@db1 cm_agent]$ cm_ctl show

[  Network Connect State  ]

Network timeout:       6s
Current CMServer time: 2023-08-03 06:19:40
Network stat('Y' means connected, otherwise 'N'):
|  \  |  N  |  N  |
|  N  |  \  |  Y  |
|  N  |  Y  |  \  |


[  Node Disk HB State  ]

Node disk hb timeout:    200s
Current CMServer time: 2023-08-03 06:19:41
Node disk hb stat('Y' means connected, otherwise 'N'):
|  N  |  N  |  N  |

[  FloatIp Network State  ]

node   instance base_ip       float_ip_name float_ip
----------------------------------------------------------
2  db2 6002     192.168.56.12 VIP_az1     192.168.56.10

节点1的IP,已没有192.168.56.10

[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
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:04:f9:a3 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
       valid_lft 74572sec preferred_lft 74572sec
    inet6 fe80::c8c2:7f4c:914f:a32d/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:50:47:12 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.11/24 brd 192.168.56.255 scope global noprefixroute enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::890a:d968:b65d:f59a/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

节点2的IP,已增加192.168.56.10

[omm@db2 ~]$ 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
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:04:f9:a3 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
       valid_lft 74550sec preferred_lft 74550sec
    inet6 fe80::c8c2:7f4c:914f:a32d/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:41:73:29 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.12/24 brd 192.168.56.255 scope global noprefixroute enp0s8
       valid_lft forever preferred_lft forever
    inet 192.168.56.10/24 brd 192.168.56.255 scope global secondary enp0s8:15400
       valid_lft forever preferred_lft forever
    inet6 fe80::5373:d66d:7a39:ddc2/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

资源配置文件

[omm@db1 cm_agent]$ cat cm_resource.json
{
        "resources":    [{
                        "name": "VIP_az1",
                        "resources_type":       "VIP",
                        "instances":    [{
                                        "node_id":      1,
                                        "res_instance_id":      6001,
                                        "inst_attr":    "base_ip=192.168.56.11"
                                }, {
                                        "node_id":      2,
                                        "res_instance_id":      6002,
                                        "inst_attr":    "base_ip=192.168.56.12"
                                }, {
                                        "node_id":      3,
                                        "res_instance_id":      6003,
                                        "inst_attr":    "base_ip=192.168.56.13"
                                }],
                        "float_ip":     "192.168.56.10"
                }]

同步配置文件到其余节点

scp 	cm_resource.json db2:/opt/huawei/data/cmserver/cm_agent
scp 	cm_resource.json db3:/opt/huawei/data/cmserver/cm_agent

启动节点1

[omm@db3 ~]$ cm_ctl start -n 1
cm_ctl: start the node: 1.
cm_ctl: start node, nodeid: 1
...........
cm_ctl: start node successfully.
		
[omm@db1 cm_agent]$ 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 Standby
2  db2 192.168.56.12   2    /opt/huawei/data/cmserver/cm_server Primary
3  db3 192.168.56.13   3    /opt/huawei/data/cmserver/cm_server Standby

[   Cluster State   ]

cluster_state   : Normal
redistributing  : No
balanced        : No
current_az      : AZ_ALL

[  Datanode State   ]

node   node_ip         instance                         state
-------------------------------------------------------------------------
1  db1 192.168.56.11   6001 /opt/huawei/install/data/dn P Standby Normal
2  db2 192.168.56.12   6002 /opt/huawei/install/data/dn S Primary Normal
3  db3 192.168.56.13   6003 /opt/huawei/install/data/dn S Standby Normal

【我和openGauss的故事】为集群实现VIP_Network

现在CM的主节点和数据库的主节点在同一机器上了。

标签:00,cm,forever,192.168,lft,VIP,集群,ff,openGauss
From: https://blog.51cto.com/u_16191492/6991285

相关文章

  • MTK 2.9.2 迁移Oracle 11g 至 openGauss 5.0.0操作指南
    MTK2.9.2迁移Oracle11g至openGauss5.0.0操作指南尚雷openGauss2023-08-0418:01发表于四川前言:最近在进行一些去O的验证测试,之前测试过MTK迁移Oracle到MogDB,正好测试下Oracle到openGauss的迁移,于是做了如下测试,并整理记录成文,还望对此熟悉的朋友多多指正。一、简介MTK全......
  • Windows11使用docker desktop安装kafka&zookeeper集群
    docker-compose安装zookeeper集群参考文章:http://t.csdn.cn/TtTYIhttps://blog.csdn.net/u010416101/article/details/122803105?spm=1001.2014.3001.5501准备工作:​ 在开始新建集群之前,新建好文件夹,用来挂载kafka、zookeeper数据,如下:zookeeper文件夹D:\soft\docker\zookee......
  • Zookeeper 集群 + Kafka 集群
    目录一、Zookeeper概述1.Zookeeper定义2.Zookeeper工作机制3.Zookeeper特点4.Zookeeper数据结构5.Zookeeper应用场景6.Zookeeper选举机制(1)第一次启动选举机制(2)非第一次启动选举机制二、部署Zookeeper集群一、Zookeeper概述1.Zookeeper定义Zookeeper是一个开......
  • Kafka集群
    Kafka集群使用消息队列,通过异步处理请求,从而缓解系统的压力。消息队列常应用于异步处理,流量削峰,应用解耦,消息通讯等场景。目录1.Kafka概述2.消息队列好处3.消息队列的模式4.Kafka的特性5.Kafka系统架构6.部署kafka集群7.总结     1.Kafka概述1.消息......
  • Zookeeper集群
    Zookeeper就将负责通知已经在Zookeeper上注册的那些观察者做出相应的反应。也就是说Zookeeper=文件系统+通知机制。目录一、Zookeeper概述二、Zookeeper工作机制三、Zookeeper特点四、Zookeeper数据结构五、Zookeeper应用场景六、Zookeeper选举机制七、部署Zo......
  • openGauss学习笔记-32 openGauss 高级数据管理-批处理模式
    openGauss学习笔记-32openGauss高级数据管理-批处理模式openGauss支持从文本文件执行SQL语句。openGauss提供了gsql工具实现SQL语句的批量处理。以下场景建议使用批处理:如果您重复运行查询(例如,每天或每周),将其设为脚本可以让您避免每次进行重复输入。您可以通过复制和编辑脚......
  • 最完美WIN11_Pro_22H2.22631.2129软件选装纯净版VIP51.3
    【系统简介】=============================================================1.本次更新母盘来自UUP_WIN11_Pro_22H2.22631.2129。进一步精简优化调整。2.只为呈现最好的作品,手工精简优化部分较多。3.OS版本号为22631.2129。个别要求高的就下MSDN吧,里面啥功能都有。4.集成《DrvCeo......
  • Hadoop完全分布式集群安装
    Hadoop完全分布式集群安装使用版本:hadoop-3.2.0安装VMware看一下这张图,图里面表示是三个节点,左边这一个是主节点,右边的两个是从节点,hadoop集群是支持主从架构的。不同节点上面启动的进程默认是不一样的。下面我们就根据图中的规划实现一个一主两从的hadoop集群安装hado......
  • centos7.9 部署mongodb-4.4.18 分片集群
    准备基本环境名称ip地址cpu内存es监听端口redis-65110.0.2.18c64G9200redis-65210.0.2.28c64G9200redis-65310.0.2.38c64G9200......
  • openGauss的SQL引擎在3.1.0版本中做了哪些优化?
    openGauss的SQL引擎在3.1.0版本中做了哪些优化?收录于合集#技术干货83个查询执行能力对数据库来说至关重要,这直接决定了查询语句生成的执行计划以何种方式进行执行,如果哪个执行算子的执行表现不好,将会对数据库的整体性能产生极大的影响。同时,执行算子的实现也极大考验一款数据库的工......