暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

MogDB虚拟机克隆(或修改IP)后PTK和gs_om无法正常使用

原创 由迪 2023-10-11
467

原作者:吴世兴

  • 适用范围
  • 问题概述
  • 问题原因
  • 解决方案
  • 参考文档

适用范围

1、使用PTK快速安装的MogDB 2.x和3.x版本;
2、使用gs_install脚本标准安装的MogDB 2.x和3.x版本;

问题概述

1、MogDB虚拟机克隆后,新拉起的虚拟机的MogDB无法用gs_om正常管理,也不能通过PTK管理;
2、虚拟机/物理机在修改IP、主机名后也会出现同样问题。

PTK报错:

[root@host1 ~]# ptk ls
ERRO[2022-07-08T19:50:54.945] failed to init cluster_czGUk6's cluster info 
  cluster_name | instances | user | data_dir | db_version  
---------------+-----------+------+----------+-------------

gs_om报错:

[omm@host1 ~]$ gs_om -t status
[GAUSS-51652] : Failed to get cluster node info.exception is: list index out of range.

问题原因

虚拟机克隆后,IP和主机名等发生了变化,PTK/gs_om依赖静态文件内记录的信息来管理MogDB,故需要修改配置文件/重新生成静态文件;

解决方案

1、对于使用PTK安装的MogDB:
1.1、修改PTK的配置文件,解决PTK无法使用问题:
配置文件位置:.ptk/data/cluster_czGUk6/topology.yml
修改配置文件内的IP为实际的IP:

[root@host1 cluster_czGUk6]# vi topology.yml 
global:
  cluster_name: cluster_czGUk6
  user: omm
  group: omm
  db_password: ******
  db_port: 26000
  base_dir: /mogdb3
  app_dir: /mogdb3/app
  data_dir: /mogdb3/data
  log_dir: /mogdb3/log
  tool_dir: /mogdb3/tool
  tmp_dir: /mogdb3/tmp
  cm_dir: /mogdb3/cm
db_servers:
- host: 192.168.86.160
  db_port: 26000
  ha_ips:
  - 192.168.86.160
  ha_port: 26001
  role: primary
  az_name: AZ1
  az_priority: 1
  ssh_option:
    host: 192.168.86.160
    port: 22
    user: root
~
~

"topology.yml" 26L, 480C written

[root@host1 cluster_czGUk6]# ptk ls
   cluster_name  |      instances       | user |   data_dir   | db_version   
-----------------+----------------------+------+--------------+--------------
  cluster_czGUk6 | 192.168.86.160:26000 | omm  | /mogdb3/data | MogDB-3.0.0  

1.2 重新生成gs_om使用的配置文件,解决gs_om无法使用问题:
1.2.1 使用PTK生成gs_om使用的xml文件:

[root@host1 ~]#  ptk gen-om-xml -f config.yaml
/root/config_20220708202520.xml
[root@host1 ~]# cp config_20220708202520.xml /home/omm/

1.2.2 使用PTK生成的的xml文件重新生成gs_om的静态配置文件:

[omm@host1 ~]$ gs_om -t generateconf -X /home/omm/config_20220708202520.xml --distribute
Generating static configuration files for all nodes.
Creating temp directory to store static configuration files.
Successfully created the temp directory.
Generating static configuration files.
Successfully generated static configuration files.
Static configuration files for all nodes are saved in /mogdb3/tool/script/static_config_files.
Distributing static configuration files to all nodes.
Successfully distributed static configuration files.

[omm@host1 ~]$ gs_om -t status --detail
[   Cluster State   ]

cluster_state   : Normal
redistributing  : No
current_az      : AZ_ALL

[  Datanode State   ]

    node  node_ip         port      instance             state
------------------------------------------------------------------------------
1  host1 192.168.86.160  26000      6001 /mogdb3/data   P Primary Normal

如果在以上过程中出现了以下报错:

[omm@host1 ~]$ gs_om -t generateconf -X /home/omm/config_20220708202520.xml --distribute
[GAUSS-51233] : The Port(0) is invalid on the node(veelx4). Please check it.

需要手动修改CM的数量为0,或者将CM端口修改为实际的(如果有CM的话):

vi /home/omm/config_20220708202520.xml
CM数量:<PARAM name="cmsNum" value="0"></PARAM>
CM端口:<PARAM name="cmServerPortBase" value="15000"></PARAM>

2、使用gs_install脚本标准安装的MogDB(只有gs_om问题):
该方法安装MogDB时需要手动配置xml文件,故需要先找到安装时使用的xml文件,对其进行修改:
xml配置文件通常位于:/opt/software/mogdb/cluster_config.xml
修改其中的主机名和IP为实际的即可。

参考文档

PTK官方文档:
https://docs.mogdb.io/zh/ptk/v0.2/overview

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论