当前位置: 首页 > news >正文

金仓读写分离集群修改IP

  • 集群配置

[kingbase@kingbase ~]$ repmgr cluster show

 ID | Name  | Role    | Status    | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string                                                                                                                                

----+-------+---------+-----------+----------+----------+----------+----------+---------+----------------------------------------------------------------------------------------------------------------------------------------------------

 1  | node1 | primary | * running |          | default  | 100      | 3        |         | host=192.168.85.155 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

 2  | node2 | standby |   running | node1    | default  | 100      | 3        | 0 bytes | host=192.168.85.130 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

 3  | node3 | standby |   running | node1    | default  | 100      | 3        | 0 bytes | host=192.168.85.131 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

  • 修改步骤:
  1. 修改3各节点的IP为:

hostname

原ip

新ip

node1

192.168.85.155

192.168.85.200

node2

192.168.85.130

192.168.85.201

node3

192.168.85.131

192.168.85.202

  1. 停集群
  2. 分别修改3各节点的IP地址。

需要修改:

1. /etc/hosts

2.repmgr.conf文件

以下以node1(主节点)为例

  1. 修改 /etc/hosts文件

修改前:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.85.155 kingbase

192.168.85.130 kes-slave1

192.168.85.131 kes-slave2

修改后:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.85.200 kingbase

192.168.85.201 kes-slave1

192.168.85.202 kes-slave2

  1. 修改repmgr.conf

修改前:

conninfo='host=192.168.85.155 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3'

net_device_ip='192.168.85.155'

修改后:

conninfo='host=192.168.85.200 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3'

net_device_ip='192.168.85.200'

  1. 主节点手动启动数据库

[kingbase@kingbase ~]$ sys_ctl start

waiting for server to start....2025-04-24 04:27:33.462 CST [1597] LOG:  sepapower extension initialized

2025-04-24 04:27:33.469 CST [1597] LOG:  starting KingbaseES V008R006C007B0012 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit

2025-04-24 04:27:33.469 CST [1597] LOG:  listening on IPv4 address "0.0.0.0", port 54321

2025-04-24 04:27:33.469 CST [1597] LOG:  listening on IPv6 address "::", port 54321

2025-04-24 04:27:33.470 CST [1597] LOG:  listening on Unix socket "/tmp/.s.KINGBASE.54321"

2025-04-24 04:27:33.587 CST [1597] LOG:  redirecting log output to logging collector process

2025-04-24 04:27:33.587 CST [1597] HINT:  Future log output will appear in directory "sys_log".

 done

server started

  1. 注册主节点到集群

[kingbase@kingbase bin]$ ./repmgr primary register -F

[INFO] connecting to primary database...

[INFO] "repmgr" extension is already installed

[NOTICE] PING 192.168.85.156 (192.168.85.156) 56(84) bytes of data.

--- 192.168.85.156 ping statistics ---

2 packets transmitted, 0 received, 100% packet loss, time 1001ms

[WARNING] ping host"192.168.85.156" failed

[DETAIL] average RTT value is not greater than zero

[INFO] loadvip result: 1, arping result: 1

[NOTICE] node (ID: 1) acquire the virtual ip 192.168.85.156/24 success

[NOTICE] primary node record (ID: 1) updated

  1. 查看集群状态

[kingbase@kingbase bin]$ repmgr cluster show

 ID | Name  | Role    | Status        | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string                                                                                                                                

----+-------+---------+---------------+----------+----------+----------+----------+---------+----------------------------------------------------------------------------------------------------------------------------------------------------

 1  | node1 | primary | * running     |          | default  | 100      | 3        |         | host=192.168.85.200 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

 2  | node2 | standby | ? unreachable | ? node1  | default  | 100      |          | ?       | host=192.168.85.130 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

 3  | node3 | standby | ? unreachable | ? node1  | default  | 100      |          | ?       | host=192.168.85.131 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

[WARNING] following issues were detected

  - unable to connect to node "node2" (ID: 2)

  - node "node2" (ID: 2) is registered as an active standby but is unreachable

  - unable to connect to node "node3" (ID: 3)

  - node "node3" (ID: 3) is registered as an active standby but is unreachable

[HINT] execute with --verbose option to see connection error messages

  1. 备节点node2集群注册

[kingbase@kes-slave1 bin]$ repmgr standby register -h 192.168.85.200 -Uesrep –desrep -F

[WARNING] following problems with command line parameters detected:

  --no-wait will be ignored when executing STANDBY REGISTER

[INFO] connecting to local node "node2" (ID: 2)

[INFO] connecting to primary database

[WARNING] unable to connect to remote host "" via ES

[ERROR] unable to connect via ES to host ""

[NOTICE] failed to update nodes_info file on primary node.

[INFO] standby registration complete

[NOTICE] standby node "node2" (ID: 2) successfully registered

  1. 备节点node2加入集群

[kingbase@kes-slave1 ~]$ repmgr node rejoin -h 192.168.85.200 -U esrep -d esrep

[NOTICE] rejoin target is node "node1" (ID: 1)

[INFO] timelines are same, this server is not ahead

[DETAIL] local node lsn is 0/180004D0, rejoin target lsn is 0/19000898

[INFO] creating replication slot as user "esrep"

[NOTICE] setting node 2's upstream to node 1

[WARNING] unable to ping "host=192.168.85.201 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3"

[DETAIL] PQping() returned "PQPING_NO_RESPONSE"

[NOTICE] begin to start server at 2025-04-23 20:31:21.297656

[NOTICE] starting server using "/home/kingbase/cluster/install/kingbase/bin/sys_ctl  -w -t 90 -D '/home/kingbase/cluster/install/kingbase/data' -l /home/kingbase/cluster/install/kingbase/bin/logfile start"

[NOTICE] start server finish at 2025-04-23 20:31:21.525235

[NOTICE] NODE REJOIN successful

[DETAIL] node 2 is now attached to node 1

  1. 备节点node3集群注册

[kingbase@kes-slave2 etc]$ repmgr standby register -h 192.168.85.200 -Uesrep -F

[WARNING] following problems with command line parameters detected:

  --no-wait will be ignored when executing STANDBY REGISTER

[INFO] connecting to local node "node3" (ID: 3)

[WARNING] database connection parameters not required when the standby to be registered is running

[DETAIL] repmgr uses the "conninfo" parameter in "repmgr.conf" to connect to the standby

[INFO] connecting to primary database

[INFO] standby registration complete

[NOTICE] standby node "node3" (ID: 3) successfully registered

  1. 备节点node3加入集群

[kingbase@kes-slave2 ~]$ repmgr node rejoin -h 192.168.85.200 -U esrep -d esrep

[NOTICE] rejoin target is node "node1" (ID: 1)

[INFO] timelines are same, this server is not ahead

[DETAIL] local node lsn is 0/180004D0, rejoin target lsn is 0/19000A88

[INFO] creating replication slot as user "esrep"

[NOTICE] setting node 3's upstream to node 1

[WARNING] unable to ping "host=192.168.85.202 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3"

[DETAIL] PQping() returned "PQPING_NO_RESPONSE"

[NOTICE] begin to start server at 2025-04-23 20:32:13.040717

[NOTICE] starting server using "/home/kingbase/cluster/install/kingbase/bin/sys_ctl  -w -t 90 -D '/home/kingbase/cluster/install/kingbase/data' -l /home/kingbase/cluster/install/kingbase/bin/logfile start"

[NOTICE] start server finish at 2025-04-23 20:32:13.269271

[NOTICE] NODE REJOIN successful

[DETAIL] node 3 is now attached to node 1

  1. 主节点查看流复制状态

kingbase@kingbase bin]$ ksql -Usystem -dtest

ksql (V8.0)

Type "help" for help.

test=# select * from sys_stat_replication ;

 pid  | usesysid | usename | application_name |  client_addr   | client_hostname | client_port |         backend_start         | backend_x

min |   state   |  sent_lsn  | write_lsn  | flush_lsn  | replay_lsn | write_lag | flush_lag | replay_lag | sync_priority | sync_state |  

       reply_time          

------+----------+---------+------------------+----------------+-----------------+-------------+-------------------------------+----------

----+-----------+------------+------------+------------+------------+-----------+-----------+------------+---------------+------------+---

----------------------------

 1673 |    16385 | esrep   | node2            | 192.168.85.201 |                 |       25154 | 2025-04-24 04:31:19.887214+08 |         

    | streaming | 0/19001058 | 0/19001058 | 0/19001058 | 0/19001058 |           |           |            |             1 | quorum     | 20

25-04-23 20:33:54.152167+08

 1687 |    16385 | esrep   | node3            | 192.168.85.202 |                 |        9135 | 2025-04-24 04:32:12.101960+08 |         

    | streaming | 0/19001058 | 0/19001058 | 0/19001058 | 0/19001058 |           |           |            |             1 | quorum     | 20

25-04-23 20:33:53.805082+08

(2 rows)

  1. 所有节点启动repmgrd守护进程

[kingbase@kingbase bin]$ repmgrd -d

[2025-04-24 04:35:21] [NOTICE] redirecting logging output to "/home/kingbase/cluster/install/kingbase/log/hamgr.log"

  1. 主节点重新启动集群查看状态

[kingbase@kingbase bin]$ ./repmgr cluster show

 ID | Name  | Role    | Status    | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string                                                                                                                                 

----+-------+---------+-----------+----------+----------+----------+----------+---------+----------------------------------------------------------------------------------------------------------------------------------------------------

 1  | node1 | primary | * running |          | default  | 100      | 3        |         | host=192.168.85.200 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

 2  | node2 | standby |   running | node1    | default  | 100      | 3        | 0 bytes | host=192.168.85.201 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

 3  | node3 | standby |   running | node1    | default  | 100      | 3        | 0 bytes | host=192.168.85.202 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

http://www.xdnf.cn/news/99757.html

相关文章:

  • 从性能到安全:大型网站系统架构演化的 13 个核心维度
  • Qt案例 使用QFtpServerLib开源库实现Qt软件搭建FTP服务器,使用QFTP模块访问FTP服务器
  • C语言中小写字母转大写字母
  • 数据通信学习笔记之OSPF的基础术语
  • 有哪些信誉良好的脂多糖供应商推荐?
  • 16.第二阶段x64游戏实战-分析二叉树结构
  • 前端js需要连接后端c#的wss服务
  • python自动化测试1——鼠标移动偏移与移动偏移时间
  • Redis 服务自动开启
  • Linux——进程优先级/切换/调度
  • Elasticsearch 堆内存使用情况和 JVM 垃圾回收
  • Maven 项目中引入本地 JAR 包
  • LinkedList与链表
  • 论文阅读 | 大模型工具调用控制的策略优化
  • Centos9安装docker
  • (20)VTK C++开发示例 --- 读取 DEM(高程地图)文件
  • 科学养生,拥抱健康生活
  • 电脑如何监控?六个电脑监控方法分享,请查收
  • 基于大模型的胃食管反流病全周期预测与诊疗方案研究
  • 【重学Android】03.高版本 Android Studio 不能使用引用库资源ID的问题
  • 服务器上部署Nginx的几种方式
  • vant Dialog组件调用的坑
  • Linux : 理解文件系统
  • CentOS 系统 DeepSeek 部署
  • [java八股文][Java基础面试篇]设计模式
  • VR 全景看车的独特优势​
  • 封装 element-ui 二次弹框
  • 详解:中兴新支点操作系统智慧政务信创解决方案
  • Prometheus定义主机监控告警实例
  • 【Amazing晶焱科技高速 CAN Bus 传输与 TVS/ESD/EOS 保护,将是车用电子的生死关键无标题】