Java教程

KingbaseES V8R6集群维护之--修改数据库服务端口案例

本文主要是介绍KingbaseES V8R6集群维护之--修改数据库服务端口案例,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!


案例说明:

对于KingbaseES数据库单实例环境,只需要修改kingbase.conf文件的‘port’参数即可,但是对于KingbaseES V8R6集群中涉及到多个配置文件的修改,并且在应用了sys_backup.sh工具建立物理备份后,还要修改备份对应的配置文件。

适用版本:
KingbaseES V8R6

集群节点信息:

[kingbase@node101 bin]$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.1.101   node101  # primary
192.168.1.102   node102  # standby

集群节点状态:

=注意:数据库服务port信息不但在配置文件存在,还被注册到了esrep数据库的nodes表中,在修改repmgr的配置文件后,还需要更新数据库中的表。=

[kingbase@node101 bin]$ ./repmgr cluster show
 ID | Name    | Role    | Status    | Upstream | Location | Priority | Timeline | Connection string                                    
----+---------+---------+-----------+----------+----------+----------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node101 | primary | * running |          | default  | 100      | 13       | host=192.168.1.101 user=system dbname=esrep port=54322 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
 2  | node102 | standby |   running | node101  | default  | 100      | 13       | host=192.168.1.102 user=system dbname=esrep port=54322 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

一、集群和数据库及备份配置文件(all nodes)

=注意:需要修改集群和数据库的配置文件,需要先关闭集群停止数据库服务,然后再修改配置文件。以下port端口为修改前的端口。=

1、数据库相关配置文件

# 配置文件存储目录
[kingbase@node102 data]$ pwd
/home/kingbase/cluster/R6HA/kha/kingbase/data

# db服务启动配置
[kingbase@node102 data]$ cat es_rep.conf |grep port
port='54322'

# 主库连接信息配置
[kingbase@node102 data]$ cat kingbase.auto.conf |grep port
primary_conninfo = 'user=system connect_timeout=10 host=192.168.1.101 port=54322 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3 application_name=node102'

2、repmgr集群配置文件

# 配置文件目录
[kingbase@node101 etc]$ pwd
/home/kingbase/cluster/R6HA/kha/kingbase/etc

# repmgr配置
[kingbase@node102 etc]$ cat repmgr.conf |grep port
conninfo='host=192.168.1.102 user=system dbname=esrep port=54322 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3'

# 节点配置
[kingbase@node102 etc]$ cat all_nodes_tools.conf |grep port
db_port=54322

3、sys_backup.sh配置文件

#初始化配置 
[kingbase@node101 bin]$ pwd
/home/kingbase/cluster/R6HA/kha/kingbase/bin

[kingbase@node101 bin]$ cat sys_backup.conf|grep port
# database port of single
_single_db_port="54322"

# sys_rman配置
[kingbase@node101 kbbr_repo]$ pwd
/home/kingbase/kbbr_repo

[kingbase@node101 kbbr_repo]$ cat sys_rman.conf |grep port
kb1-port=54322

二、修改数据库服务端口(all nodes)
对以上配置文件通过系统命令修改,本案例原服务端口(port = 54322),修改为:port = 54321;

三、启动集群

=如下所示,启动集群会出现节点注册失败,原因是,只修改了配置文件,数据库服务按照新的端口(54321)启动,但是esrep数据库中的节点注册信息没有修改,仍然按照原有的端口(54322)连接数据库注册,所以注册失败。=

[kingbase@node101 bin]$ ./sys_monitor.sh start
2022-06-09 21:31:54 Ready to start all DB ...
2022-06-09 21:31:54 begin to start DB on "[192.168.1.101]".
waiting for server to start.... done
server started
2022-06-09 21:31:56 execute to start DB on "[192.168.1.101]" success, connect to check it.
2022-06-09 21:31:57 DB on "[192.168.1.101]" start success.
2022-06-09 21:31:57 Try to ping trusted_servers on host 192.168.1.101 ...
2022-06-09 21:32:01 Try to ping trusted_servers on host 192.168.1.102 ...
2022-06-09 21:32:05 begin to start DB on "[192.168.1.102]".
waiting for server to start.... done
server started
2022-06-09 21:32:07 execute to start DB on "[192.168.1.102]" success, connect to check it.
2022-06-09 21:32:08 DB on "[192.168.1.102]" start success.
 ID | Name    | Role    | Status        | Upstream | Location | Priority | Timeline | Connection string                                
----+---------+---------+---------------+----------+----------+----------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node101 | primary | ? unreachable |          | default  | 100      | ?        | host=192.168.1.101 user=system dbname=esrep port=54322 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
 2  | node102 | standby | ? unreachable | node101  | default  | 100      | ?        | host=192.168.1.102 user=system dbname=esrep port=54322 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
WARNING: following issues were detected
  - unable to connect to node "node101" (ID: 1)
  - node "node101" (ID: 1) is registered as an active primary but is unreachable
  - unable to connect to node "node102" (ID: 2)
  - node "node102" (ID: 2) is registered as an active standby but is unreachable
2022-06-09 21:32:08 There is no primary DB running, will do nothing and exit.

数据库服务端口:

[kingbase@node101 bin]$ netstat -antlp |grep 54321
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:54321           0.0.0.0:*               LISTEN      30704/kingbase

三、更新集群节点注册信息

# 重新注册primary
[kingbase@node101 bin]$ ./repmgr primary register --force
INFO: connecting to primary database...
INFO: "repmgr" extension is already installed
NOTICE: primary node record (ID: 1) updated
You have new mail in /var/spool/mail/kingbase

# 重新注册standby
[kingbase@node102 bin]$ ./repmgr standby register --force
INFO: connecting to local node "node102" (ID: 2)
INFO: connecting to primary database
INFO: standby registration complete
NOTICE: standby node "node102" (ID: 2) successfully registered

# 查看节点状态信息
[kingbase@node102 bin]$ ./repmgr cluster show
 ID | Name    | Role    | Status    | Upstream | Location | Priority | Timeline | Connection string                                    
----+---------+---------+-----------+----------+----------+----------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node101 | primary | * running |          | default  | 100      | 13       | host=192.168.1.101 user=system dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
 2  | node102 | standby |   running | node101  | default  | 100      | 13       | host=192.168.1.102 user=system dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
 
 #如上所示,重新注册节点后,port信息被更新。

四、重启集群测试

[kingbase@node101 bin]$ ./sys_monitor.sh restart
.......
2022-06-09 21:35:28 repmgrd on "[192.168.1.102]" start success.
 ID | Name    | Role    | Status    | Upstream | repmgrd | PID   | Paused? | Upstream last seen
----+---------+---------+-----------+----------+---------+-------+---------+--------------------
 1  | node101 | primary | * running |          | running | 32468 | no      | n/a
 2  | node102 | standby |   running | node101  | running | 27753 | no      | 2 second(s) ago
[2022-06-09 21:35:33] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/kha/kingbase/log/kbha.log"

[2022-06-09 21:35:47] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/kha/kingbase/log/kbha.log"

2022-06-09 21:35:43 Done.

# 如上所示,重启集群后状态正常。

五、查看sys_rman备份信息

[kingbase@node101 bin]$ ./sys_rman --config=/home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase  info
stanza: kingbase
    status: ok
    cipher: none

    db (current)
        wal archive min/max (V008R006C005B0041): 000000030000000000000023/0000000D0000000000000055

        full backup: 20220426-113919F
            timestamp start/stop: 2022-04-26 11:39:19 / 2022-04-26 11:39:27
            wal start/stop: 00000007000000000000003A / 00000007000000000000003A
            database size: 95.8MB, database backup size: 95.8MB
            repo1: backup set size: 11.1MB, backup size: 11.1MB
            
 # 如上所示,sys_rman备份信息查询正常。  

六、总结

 1、对于数据库服务端口的修改,无法在线修改,需要重启集群及数据库服务。
 2、对于生产环境,在集群部署时,应该提前确定好数据库服务端口。
 3、集群数据库服务端口修改需要在所有节点执行。
这篇关于KingbaseES V8R6集群维护之--修改数据库服务端口案例的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!