From 26d51ce9e63bdef336a254cc64cb212baf2e490f Mon Sep 17 00:00:00 2001 From: liuzhanfeng2 Date: Mon, 25 Nov 2024 10:17:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E9=80=9A=E8=BF=87ip=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E9=85=8D=E7=BD=AEvip=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...71\346\200\247\344\273\213\347\273\215.md" | 93 ++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git "a/content/zh/docs/ToolandCommandReference/\347\211\271\346\200\247\344\273\213\347\273\215.md" "b/content/zh/docs/ToolandCommandReference/\347\211\271\346\200\247\344\273\213\347\273\215.md" index ca64a02d4..54ff5a9d7 100644 --- "a/content/zh/docs/ToolandCommandReference/\347\211\271\346\200\247\344\273\213\347\273\215.md" +++ "b/content/zh/docs/ToolandCommandReference/\347\211\271\346\200\247\344\273\213\347\273\215.md" @@ -462,6 +462,8 @@ cm支持包含级联备组网下的DN仲裁。 - 需要可用VIP,即需要可对外提供服务的VIP(跟现有网卡处于同一网段中)。 +- 目前支持通过ifconfig和ip命令配置vip,但是ip命令配置vip目前只支持在数据库集群安装情况下配置vip。 + **VIP配置操作步骤:** @@ -601,7 +603,7 @@ floatIpMap1表示floatIp与dataListenIp的对应关系,其顺序与dataListenI 安装成功后VIP便会自动绑定到对应的主机上,可以使用cm_ctl show命令查看VIP状态 -- 带CM的数据库集群已安装的场景下配置VIP +- 带CM的数据库集群已安装的场景下通过ifconfig配置VIP 1. ifconfig提权 @@ -679,6 +681,95 @@ cm_ctl res --edit --res_name="VIP_az3" --add_inst="node_id=7,res_instance_id=600 3. 在数据库pg_hba.conf文件中以sha256方式添加floatIp +- 带CM的数据库集群已安装的场景下通过ip配置VIP + +1. ip提权 +修改权限文件/etc/sudoers或执行visudo命令,添加以下内容,为集群用户添加ifconfig权限。 + +``` +Cmnd_Alias COMMAND_FLAG = /usr/sbin/ip +集群用户名 ALL=(root) NOPASSWD: COMMAND_FLAG +``` + +2. 配置自定义资源文件cm_resource.json + +通过cm_ctl res命令新增floatIp资源,仍以上述的xml中的节点情况为例 +``` +# 新增VIP资源,res_name为资源名称,资源类型resources_type必须指定为VIP,float_ip表示该自定义VIP资源的虚拟ip,cmd表示添加vip的方式,目前只支持cmd=ip,netmask表示子网掩码,子网掩码只能以ip形式写入。 +cm_ctl res --add --res_name="VIP_az1" --res_attr="resources_type=VIP,float_ip=10.10.10.100,cmd=ip,netmask=255.255.255.0" +cm_ctl res --add --res_name="VIP_az2" --res_attr="resources_type=VIP,float_ip=20.20.20.100,cmd=ip,netmask=255.255.255.0" +cm_ctl res --add --res_name="VIP_az3" --res_attr="resources_type=VIP,float_ip=30.30.30.100,cmd=ip,netmask=255.255.255.0" +# 编辑各自定义VIP资源VIP_az1、VIP_az2、VIP_az3,添加节点,node_id表示对应的节点id,res_instance_id用于告知CM绑定的DN实例id,需要与对应的DN实例id对应 +cm_ctl res --edit --res_name="VIP_az1" --add_inst="node_id=1,res_instance_id=6001" --inst_attr="base_ip=10.10.10.10" +cm_ctl res --edit --res_name="VIP_az1" --add_inst="node_id=2,res_instance_id=6002" --inst_attr="base_ip=10.10.10.11" +cm_ctl res --edit --res_name="VIP_az1" --add_inst="node_id=3,res_instance_id=6003" --inst_attr="base_ip=10.10.10.12" +cm_ctl res --edit --res_name="VIP_az2" --add_inst="node_id=4,res_instance_id=6004" --inst_attr="base_ip=20.20.20.20" +cm_ctl res --edit --res_name="VIP_az2" --add_inst="node_id=5,res_instance_id=6005" --inst_attr="base_ip=20.20.20.21" +cm_ctl res --edit --res_name="VIP_az3" --add_inst="node_id=6,res_instance_id=6006" --inst_attr="base_ip=30.30.30.30" +cm_ctl res --edit --res_name="VIP_az3" --add_inst="node_id=7,res_instance_id=6007" --inst_attr="base_ip=30.30.30.31" +``` + +执行完成后,建议使用cm_ctl res --check命令进行检查。自定义资源文件要求每个节点都要有且一致,检查完成没有错误后,需要手动将该文件分发到其他节点,分发完成后需要重启集群才能生效。该配置文件对格式要求比较严格,所以该操作不建议使用直接修改文件的方式配置,建议配置后使用cm_ctl res --check命令进行校验。 + +执行完成后,在cmdataPath/cm_agent/目录下会生成一个自定义资源配置文件cm_resource.json,示例如下: +``` +{ + "resources": + [{"name": "VIP_az1", + "resources_type": "VIP", + "instances": + [{"node_id": 1, + "res_instance_id": 6001, + "inst_attr": "base_ip=10.10.10.10" + }, + {"node_id": 2, + "res_instance_id": 6002, + "inst_attr": "base_ip=10.10.10.11" + }, + {"node_id": 3, + "res_instance_id": 6003, + "inst_attr": "base_ip=10.10.10.12" + }], + "float_ip": "10.10.10.100", + "cmd": "ip", + "netmask": "255.255.255.0" + }, + { + "name": "VIP_az2", + "resources_type": "VIP", + "instances": + [{"node_id": 4, + "res_instance_id": 6004, + "inst_attr": "base_ip=20.20.20.20" + }, + {"node_id": 5, + "res_instance_id": 6005, + "inst_attr": "base_ip=20.20.20.21" + }], + "float_ip": "20.20.20.100", + "cmd": "ip", + "netmask": "255.255.255.0" + }, + { + "name": "VIP_az3", + "resources_type": "VIP", + "instances": + [{"node_id": 6, + "res_instance_id": 6006, + "inst_attr": "base_ip=30.30.30.30" + }, + {"node_id": 7, + "res_instance_id": 6007, + "inst_attr": "base_ip=30.30.30.31" + }], + "float_ip": "30.30.30.100", + "cmd": "ip", + "netmask": "255.255.255.0" + }] +} +``` + +3. 在数据库pg_hba.conf文件中以sha256方式添加floatIp >![](public_sys-resources/icon-note.png) **说明:** > 对于多中心集群,如果没有额外的硬件网络设施支持,一个VIP无法同时服务于多个中心,所以需要为每个中心或az配置一个VIP。 -- Gitee