kingbaseES R3集群修改system用户密码方案V3.0

方案说明:


   对于kingbaseES R3集群修改system密码相比单机环境有一定的复杂性,需要修改的位置如下:
   1)数据库中system用户密码,可以用alter user命令修改
   2)在recovery.conf和recovery.done文件中,备库连接主库时,需要使用system用户认证(base64加密)
   3)集群认证文件cluster_passwd中需要使用system用户认证,密码采用sys_md5工具加密。

案例数据库版本:


TEST=# select version();
                                                         version
-----------------------------------------------------------------------------------------------------------------
 Kingbase V008R003C002B0180 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46),64-bit
(1 row)

集群架构:

kingbaseES R3集群修改system用户密码方案V3.0

一、修改数据库用户system密码(在主库完成)

1) 通过kingbase_monitor.sh关闭集群

` `通过手工方式启动主备库的数据库服务(sys_ctl),保证主备库的流复制状态正常(sys_stat_replication),登录主库修改system用户访问数据库的口令,备库自动通过主备复制同步修改。``

2)登录数据库修改system用户密码


[kingbase@node1 bin]$ /home/kingbase/cluster/kha/db/bin/ksql -U system -W 123456 -d TEST
ksql (V008R003C002B0180)
Type "help" for help.

TEST=# alter user system with password ‘beijing‘;
ALTER ROLE
TEST=# \q

3)用新密码登录测试


[kingbase@node1 bin]$ /home/kingbase/cluster/kha/db/bin/ksql -U system -W 123456 -d TEST
ksql: FATAL:  password authentication failed for user "system"

[kingbase@node1 bin]$ /home/kingbase/cluster/kha/db/bin/ksql -U system -W beijing -d TEST
ksql (V008R003C002B0180)
Type "help" for help.


TEST=# \c prod;
You are now connected to database "prod" as user "system".

二、在主备库修改recovery.conf 和recovery.done文件密码


注意: 
     1)除了修改主备库data目录下的recovery.done和recovery.conf文件。
     2)还要修改主备库etc下的recovery.done文件,这个文件在备库用network_rewind.sh做recovery时会覆盖备库data下的recovery.conf文件。

1、修改备库recovery.conf:
1) 查看system原密码


[kingbase@node2 data]$ cat recovery.conf
standby_mode=‘on‘
primary_conninfo=‘port=54321 host=192.168.7.248 user=SYSTEM password=MTIzNDU2 application_name=node02‘
recovery_target_timeline=‘latest‘
primary_slot_name =‘slot_node02‘

[kingbase@node2 data]$ echo MTIzNDU2|base64 -d
123456

2)加密system用户新密码


[kingbase@node2 data]$ echo beijing |base64
YmVpamluZwo=

3)修改recovery.conf和recovery.done文件


[kingbase@node2 data]$ cat recovery.conf
standby_mode=‘on‘
primary_conninfo=‘port=54321 host=192.168.7.248 user=SYSTEM password=YmVpamluZwo= application_name=node02‘
recovery_target_timeline=‘latest‘
primary_slot_name =‘slot_node02‘

[kingbase@node2 data]$ cat recovery.done
standby_mode=‘on‘
primary_conninfo=‘port=54321 host=192.168.7.248 user=SYSTEM password=YmVpamluZwo= application_name=node02‘
recovery_target_timeline=‘latest‘
primary_slot_name =‘slot_node02‘

2、修改etc/recovery.done文件
kingbaseES R3集群修改system用户密码方案V3.0

三、修改cluster_passwd文件(注意SYSTEM用户名要用大写)

1、修改主库cluster_passwd

1)备份原cluster_passwd文件

[kingbase@node1 etc]$ cp cluster_passwd cluster_passwd.old

2)通过sys_md5工具生成新的密码


[kingbase@node1 etc]$ cd ../bin
[kingbase@node1 bin]$ ./sys_md5  -m -f ../etc/kingbasecluster.conf -u SYSTEM beijing

3)对比新旧密码


[kingbase@node1 bin]$ cat ../etc/cluster_passwd
SUPERMANAGER_V8ADMIN:md5f7902af5f3f7cdcad02b5ca09320d102
SYSTEM:md53b8241a37e0492c38a986844abb8d06b

[kingbase@node1 bin]$ cat ../etc/cluster_passwd.old
SUPERMANAGER_V8ADMIN:md5f7902af5f3f7cdcad02b5ca09320d102
SYSTEM:md53afebd0fba6df9fc2cf82c0b09926bcc

2、修改备库cluster_passwd


[kingbase@node2 data]$ cd ../..
[kingbase@node2 kha]$ cd kingbasecluster/bin

[kingbase@node2 bin]$ cat ../etc/cluster_passwd
SUPERMANAGER_V8ADMIN:md5f7902af5f3f7cdcad02b5ca09320d102
SYSTEM:md53afebd0fba6df9fc2cf82c0b09926bcc

[kingbase@node2 bin]$ ./sys_md5  -m -f ../etc/kingbasecluster.conf -u SYSTEM beijing
[kingbase@node2 bin]$ cat ../etc/cluster_passwd
SUPERMANAGER_V8ADMIN:md5f7902af5f3f7cdcad02b5ca09320d102
SYSTEM:md53b8241a37e0492c38a986844abb8d06b

四、重启集群

1) 重启集群服务

[kingbase@node2 bin]$ ./kingbase_monitor.sh restart
-----------------------------------------------------------------------
2021-03-22 11:07:20 KingbaseES automation beging...
2021-03-22 11:07:20 stop kingbasecluster [192.168.7.248] ...

Authorized users only. All activities may be monitored and reported.
DEL VIP NOW AT 2021-03-22 11:07:20 ON enp0s3
No VIP on my dev, nothing to do.

Authorized users only. All activities may be monitored and reported.
2021-03-22 11:07:21 Done...
2021-03-22 11:07:21 stop kingbasecluster [192.168.7.249] ...

Authorized users only. All activities may be monitored and reported.
DEL VIP NOW AT 2021-03-22 11:07:21 ON enp0s3
No VIP on my dev, nothing to do.

Authorized users only. All activities may be monitored and reported.
2021-03-22 11:07:22 Done...
2021-03-22 11:07:22 stop kingbase [192.168.7.248] ...

Authorized users only. All activities may be monitored and reported.
set /home/kingbase/cluster/kha/db/data down now...
2021-03-22 11:07:24 Done...
2021-03-22 11:07:25 Del kingbase VIP [192.168.7.245/24] ...

Authorized users only. All activities may be monitored and reported.
DEL VIP NOW AT 2021-03-22 11:07:25 ON enp0s3
execute: [/sbin/ip addr del 192.168.7.245/24 dev enp0s3]
Oprate del ip cmd end.
2021-03-22 11:07:25 Done...
2021-03-22 11:07:25 stop kingbase [192.168.7.249] ...

Authorized users only. All activities may be monitored and reported.
set /home/kingbase/cluster/kha/db/data down now...
2021-03-22 11:07:33 Done...
2021-03-22 11:07:34 Del kingbase VIP [192.168.7.245/24] ...

Authorized users only. All activities may be monitored and reported.
DEL VIP NOW AT 2021-03-22 11:07:34 ON enp0s3
No VIP on my dev, nothing to do.
2021-03-22 11:07:34 Done...
......................
all stop..

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
ping trust ip 192.168.7.1 success ping times :[3], success times:[3]

Authorized users only. All activities may be monitored and reported.
ping trust ip 192.168.7.1 success ping times :[3], success times:[3]

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
start crontab kingbase position : [1]
Redirecting to /bin/systemctl restart crond.service

Authorized users only. All activities may be monitored and reported.
ADD VIP NOW AT 2021-03-22 11:07:43 ON enp0s3
execute: [/sbin/ip addr add 192.168.7.245/24 dev enp0s3 label enp0s3:2]
execute: /sbin/arping -U 192.168.7.245 -I enp0s3 -w 1
ARPING 192.168.7.245 from 192.168.7.245 enp0s3
Sent 1 probes (1 broadcast(s))
Received 0 response(s)

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
start crontab kingbase position : [2]
Redirecting to /bin/systemctl restart crond.service

Authorized users only. All activities may be monitored and reported.
ping vip 192.168.7.245 success ping times :[3], success times:[3]

Authorized users only. All activities may be monitored and reported.
ping vip 192.168.7.245 success ping times :[3], success times:[3]
now,there is a synchronous standby.
wait kingbase recovery 5 sec...

Authorized users only. All activities may be monitored and reported.
start crontab kingbasecluster line number: [2]
Redirecting to /bin/systemctl restart crond.service

Authorized users only. All activities may be monitored and reported.
/home/kingbase/cluster/kha/db/bin/all_monitor.sh: line 306: warning: command substitution: ignored null byte in input

Authorized users only. All activities may be monitored and reported.
start crontab kingbasecluster line number: [3]
Redirecting to /bin/systemctl restart crond.service

Authorized users only. All activities may be monitored and reported.
/home/kingbase/cluster/kha/db/bin/all_monitor.sh: line 306: warning: command substitution: ignored null byte in input
......................
all started..
...
now we check again

Authorized users only. All activities may be monitored and reported.
/home/kingbase/cluster/kha/db/bin/all_monitor.sh: line 306: warning: command substitution: ignored null byte in input

Authorized users only. All activities may be monitored and reported.
/home/kingbase/cluster/kha/db/bin/all_monitor.sh: line 306: warning: command substitution: ignored null byte in input

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
=======================================================================
|             ip |                       program|              [status]
[  192.168.7.248]|             [kingbasecluster]|              [active]
[  192.168.7.249]|             [kingbasecluster]|              [active]
[  192.168.7.248]|                    [kingbase]|              [active]
[  192.168.7.249]|                    [kingbase]|              [active]
=======================================================================

2)查看集群服务进程

[kingbase@node2 bin]$ ps -ef |grep kingbase
kingbase    2169       1  0 Mar19 ?        00:00:00 /usr/lib/systemd/systemd --user
kingbase    2170    2169  0 Mar19 ?        00:00:00 (sd-pam)
root        3856    2562  0 Mar19 pts/0    00:00:00 su - kingbase
kingbase    3857    3856  0 Mar19 pts/0    00:00:00 -bash
kingbase  380605       1  0 Mar21 ?        00:00:04 /home/kingbase/cluster/kha6/kha6/kingbase/bin/kbha -A daemon -f /home/kingbase/cluster/kha6/kha6/kingbase/bin/../etc/repmgr.conf
kingbase  717813       1  0 11:07 ?        00:00:00 /home/kingbase/cluster/kha/db/bin/kingbase -D /home/kingbase/cluster/kha/db/data
kingbase  717814  717813  0 11:07 ?        00:00:00 kingbase: logger process
kingbase  717815  717813  0 11:07 ?        00:00:00 kingbase: startup process   recovering 000000010000000000000006
kingbase  717819  717813  0 11:07 ?        00:00:00 kingbase: checkpointer process
kingbase  717820  717813  0 11:07 ?        00:00:00 kingbase: writer process
kingbase  717821  717813  0 11:07 ?        00:00:00 kingbase: stats collector process
kingbase  717822  717813  0 11:07 ?        00:00:00 kingbase: wal receiver process   streaming 0/60000D0
root      718723       1  0 11:08 ?        00:00:00 ./kingbasecluster -n
root      718766  718723  0 11:08 ?        00:00:00 kingbasecluster: watchdog
root      718767  718723  0 11:08 ?        00:00:00 kingbasecluster: lifecheck
root      718768  718767  0 11:08 ?        00:00:00 kingbasecluster: heartbeat receiver
root      718769  718767  0 11:08 ?        00:00:00 kingbasecluster: heartbeat sender
root      718770  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718771  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718772  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718773  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718774  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718775  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718776  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718777  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718778  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718779  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718780  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718781  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718782  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718783  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718784  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718785  718723  0 11:08 ?        00:00:00 kingbasecluster: wait for connection request
root      718786  718723  0 11:08 ?        00:00:00 kingbasecluster: PCP: wait for connection request
root      718787  718723  0 11:08 ?        00:00:00 kingbasecluster: worker process

五、在主库上验证集群状态

[kingbase@node1 bin]$ ./ksql -U SYSTEM -W beijing -p 9999 TEST
ksql (V008R003C002B0180)
Type "help" for help.

TEST=# show pool_nodes;
 node_id |   hostname    | port  | status | lb_weight |  role   | select_cnt | load_balance_node | replication_de
lay
---------+---------------+-------+--------+-----------+---------+------------+----------
 0       | 192.168.7.248 | 54321 | up     | 0.500000  | primary | 0          | true              | 0
 1       | 192.168.7.249 | 54321 | up     | 0.500000  | standby | 0          | false             | 0
(2 rows)

TEST=# select * from sys_stat_replication;
  pid   | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         backend
_start         | backend_xmin |   state   | sent_location | write_location | flush_location | replay_location | s
ync_priority | sync_state
--------+----------+---------+------------------+---------------+-----------------+-----
 744439 |       10 | SYSTEM  | node02           | 192.168.7.249 |                 |       18376 | 2021-03-22 11:0
7:44.130199+08 |              | streaming | 0/60000D0     | 0/60000D0      | 0/60000D0      | 0/60000D0       |
           2 | sync
(1 row)

六、总结
测试案例是在通用机版本下完成,不同的版本修改,system用户是数据库管理中的管理员,对于密码的修改,尽量能在测试环境下先测试成功后,再在生产环境实施。

七、附件:详细测试案例

kingbaseES R3集群修改SYSTEM用户密码测试案例

系统环境:

[kingbase@node2 bin]$ cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)
test=# select version();
                                                         version                                                  
       
------------------------------------------------------------------------------------------------------------------
 Kingbase V008R003C002B0270 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 
64-bit
(1 row)

一、通过kingbase_monitor.sh关闭集群,手工启动主备数据库服务

主库:

[kingbase@node2 ~]$ ps -ef |grep kingbase
kingbase  2827     1  0 12:01 ?        00:00:00 /home/kingbase/cluster/R6HA/KHA/kingbase/bin/kbha -A daemon -f /home/kingbase/cluster/R6HA/KHA/kingbase/bin/../etc/repmgr.conf
root      3789  3694  0 12:08 pts/0    00:00:00 su - kingbase
kingbase  3790  3789  0 12:08 pts/0    00:00:00 -bash
kingbase  4061     1  0 12:10 pts/0    00:00:00 /home/kingbase/cluster/kha/db/bin/kingbase -D ../data
kingbase  4062  4061  0 12:10 ?        00:00:00 kingbase: logger process   
kingbase  4064  4061  0 12:10 ?        00:00:00 kingbase: checkpointer process   
kingbase  4065  4061  0 12:10 ?        00:00:00 kingbase: writer process   
kingbase  4066  4061  0 12:10 ?        00:00:00 kingbase: wal writer process   
kingbase  4067  4061  0 12:10 ?        00:00:00 kingbase: autovacuum launcher process   
kingbase  4068  4061  0 12:10 ?        00:00:00 kingbase: archiver process   
kingbase  4069  4061  0 12:10 ?        00:00:00 kingbase: stats collector process   
kingbase  4070  4061  0 12:10 ?        00:00:00 kingbase: bgworker: syslogical supervisor   
kingbase  4077  4061  0 12:10 ?        00:00:00 kingbase: wal sender process SYSTEM 192.168.7.248(13986) streaming 0/160000D0

备库:

[kingbase@node1 bin]$ ps -ef |grep kingbase
kingbase  2452     1  0 12:00 ?        00:00:00 /home/kingbase/cluster/R6HA/KHA/kingbase/bin/kbha -A daemon -f /home/kingbase/cluster/R6HA/KHA/kingbase/bin/../etc/repmgr.conf
root      3809  3706  0 12:09 pts/0    00:00:00 su - kingbase
kingbase  3810  3809  0 12:09 pts/0    00:00:00 -bash
kingbase  3989     1  0 12:10 pts/0    00:00:00 /home/kingbase/cluster/kha/db/bin/kingbase -D ../data
kingbase  3990  3989  0 12:10 ?        00:00:00 kingbase: logger process   
kingbase  3991  3989  0 12:10 ?        00:00:00 kingbase: startup process   recovering 000000020000000000000015
kingbase  3995  3989  0 12:10 ?        00:00:00 kingbase: checkpointer process   
kingbase  3996  3989  0 12:10 ?        00:00:00 kingbase: writer process   
kingbase  3997  3989  0 12:10 ?        00:00:00 kingbase: stats collector process 

查看主备流复制状态:

[kingbase@node2 bin]$ ./ksql -U system -W 123456 test -p 54322
ksql (V008R003C002B0270)
Type "help" for help.

test=# select * from sys_stat_replication;
 pid  | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         backend_st
art         | backend_xmin |   state   | sent_location | write_location | flush_location | replay_location | sync_
priority | sync_state 
------+----------+---------+------------------+---------------+-----------------+-------------+-------------------
------------+--------------+-----------+---------------+----------------+--------------
 4077 |       10 | SYSTEM  | node1            | 192.168.7.248 |                 |       13986 | 2021-03-01 12:10:1
0.297089+08 |              | streaming | 0/160000D0    | 0/160000D0     | 0/160000D0     | 0/160000D0      |      
       1 | sync
(1 row)

在主库修改system用户登录数据库密码,自动复制到备库:

test=# alter user system with password ‘123456Abc‘;
ALTER ROLE

主库测试新密码登录:

[kingbase@node2 bin]$ ./ksql -U system -W 123456Abc test -p 54322
ksql (V008R003C002B0270)
Type "help" for help.

test=# select * from sys_stat_replication;         
 pid  | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         backend_st
art         | backend_xmin |   state   | sent_location | write_location | flush_location | replay_location | sync_
priority | sync_state 
------+----------+---------+------------------+---------------+-----------------+--------
 4077 |       10 | SYSTEM  | node1            | 192.168.7.248 |                 |       13986 | 2021-03-01 12:10:1
0.297089+08 |              | streaming | 0/16000528    | 0/16000528     | 0/16000528     | 0/16000528      |      
       1 | sync
(1 row)

test=# select * from sys_replication_slots;
 slot_name  | plugin | slot_type | datoid | database | active | active_pid | xmin | catalog_xmin | restart_lsn | c
onfirmed_flush_lsn 
------------+--------+-----------+--------+----------+--------+------------+------+------
 slot_node1 |        | physical  |        |          | t      |       4077 | 2102 |              | 0/16000608  | 
 slot_node2 |        | physical  |        |          | f      |            |      |              |             | 
(2 rows)

备库测试新密码登录:

[kingbase@node1 bin]$ ./ksql -U system -W 123456Abc test -p 54322
ksql (V008R003C002B0270)
Type "help" for help.

test=# select sys_is_in_recovery();
 sys_is_in_recovery 
--------------------
 t
(1 row)

二、修改recovery.conf(recovery.done)system用户密码

1、对新密码通过base64加密


[`kingbase@node2 data]$ echo "123456Abc"| base64
MTIzNDU2QWJjCg==

2、更新主库recovery.done密码

[kingbase@node2 data]$ cat recovery.done 
standby_mode=‘on‘
primary_conninfo=‘port=54322 host=192.168.7.248 user=SYSTEM password=MTIzNDU2QWJjCg== application_name=node2‘
recovery_target_timeline=‘latest‘
primary_slot_name =‘slot_node2‘

3、主库etc/recovery.done文件:
kingbaseES R3集群修改system用户密码方案V3.0

4、更新备库recovery.conf密码

[kingbase@node1 data]$ cat recovery.conf 
standby_mode=‘on‘
primary_conninfo=‘port=54322 host=192.168.7.249 user=SYSTEM password=MTIzNDU2QWJjCg== application_name=node1‘
recovery_target_timeline=‘latest‘
primary_slot_name =‘slot_node1‘

5、备库etc/recovery.done文件:
kingbaseES R3集群修改system用户密码方案V3.0

三、更新cluster_passwd中md5加密的密码

主库更新:

[kingbase@node2 etc]$ cat cluster_passwd 
SUPERMANAGER_V8ADMIN:md5f7902af5f3f7cdcad02b5ca09320d102
SYSTEM:md53afebd0fba6df9fc2cf82c0b09926bcc**
[kingbase@node2 etc]$ cp cluster_passwd cluster_passwd.old

[kingbase@node2 bin]$ ./sys_md5  -m -f ../etc/kingbasecluster.conf -u SYSTEM 123456Abc
[kingbase@node2 bin]$ cat ../etc/cluster_passwd
SUPERMANAGER_V8ADMIN:md5f7902af5f3f7cdcad02b5ca09320d102
SYSTEM:md5a6c84a57d7fbe4af93b5d9e9ef9f4d46

备库更新:

[kingbase@node1 kha]$ cd kingbasecluster/bin
[kingbase@node1 bin]$ cat ../etc/cluster_passwd 
SUPERMANAGER_V8ADMIN:md5f7902af5f3f7cdcad02b5ca09320d102
SYSTEM:md53afebd0fba6df9fc2cf82c0b09926bcc

[kingbase@node1 bin]$ ./sys_md5  -m -f ../etc/kingbasecluster.conf -u SYSTEM 123456Abc
[kingbase@node1 bin]$ cat ../etc/cluster_passwd 
SUPERMANAGER_V8ADMIN:md5f7902af5f3f7cdcad02b5ca09320d102
SYSTEM:md5a6c84a57d7fbe4af93b5d9e9ef9f4d46

四、重新用kingbase_monitor.sh启动集群

[kingbase@node1 bin]$ ./kingbase_monitor.sh restart
-----------------------------------------------------------------------
2021-03-01 12:24:18 KingbaseES automation beging...
2021-03-01 12:24:18 stop kingbasecluster [192.168.7.248] ...
DEL VIP NOW AT 2021-03-01 12:24:19 ON enp0s3
No VIP on my dev, nothing to do.
2021-03-01 12:24:20 Done...
2021-03-01 12:24:20 stop kingbasecluster [192.168.7.249] ...
DEL VIP NOW AT 2021-03-01 12:23:17 ON enp0s3
No VIP on my dev, nothing to do.
2021-03-01 12:24:21 Done...
2021-03-01 12:24:21 stop kingbase [192.168.7.248] ...
set /home/kingbase/cluster/kha/db/data down now...
2021-03-01 12:24:24 Done...
2021-03-01 12:24:25 Del kingbase VIP [192.168.7.245/24] ...
DEL VIP NOW AT 2021-03-01 12:24:25 ON enp0s3
No VIP on my dev, nothing to do.
2021-03-01 12:24:26 Done...
2021-03-01 12:24:26 stop kingbase [192.168.7.249] ...
set /home/kingbase/cluster/kha/db/data down now...
2021-03-01 12:24:30 Done...
2021-03-01 12:24:31 Del kingbase VIP [192.168.7.245/24] ...
DEL VIP NOW AT 2021-03-01 12:23:28 ON enp0s3
No VIP on my dev, nothing to do.
2021-03-01 12:24:31 Done...
......................
all stop..
ping trust ip 192.168.7.1 success ping times :[3], success times:[2]
ping trust ip 192.168.7.1 success ping times :[3], success times:[2]
start crontab kingbase position : [1]
Redirecting to /bin/systemctl restart  crond.service
start crontab kingbase position : [2]
Redirecting to /bin/systemctl restart  crond.service
ADD VIP NOW AT 2021-03-01 12:23:43 ON enp0s3
execute: [/sbin/ip addr add 192.168.7.245/24 dev enp0s3 label enp0s3:2]
execute: /home/kingbase/cluster/kha/db/bin/arping -U 192.168.7.245 -I enp0s3 -w 1
ARPING 192.168.7.245 from 192.168.7.245 enp0s3
Sent 1 probes (1 broadcast(s))
Received 0 response(s)
ping vip 192.168.7.245 success ping times :[3], success times:[2]
ping vip 192.168.7.245 success ping times :[3], success times:[3]
now,there is a synchronous standby.
wait kingbase recovery 5 sec...
start crontab kingbasecluster line number: [2]
Redirecting to /bin/systemctl restart  crond.service
start crontab kingbasecluster line number: [3]
Redirecting to /bin/systemctl restart  crond.service
......................
all started..
...
now we check again
=======================================================================
|             ip |                       program|              [status] 
[  192.168.7.248]|             [kingbasecluster]|              [active]
[  192.168.7.249]|             [kingbasecluster]|              [active]
[  192.168.7.248]|                    [kingbase]|              [active]
[  192.168.7.249]|                    [kingbase]|              [active]
=======================================================================

五、测试system用户新密码访问


[kingbase@node2 bin]$ ./ksql -U system -W 123456Abc test -p 54322
ksql (V008R003C002B0270)
Type "help" for help.

test=# select * from sys_replication_slots;
 slot_name  | plugin | slot_type | datoid | database | active | active_pid | xmin | catalog_xmin | restart_lsn | c
onfirmed_flush_lsn 
------------+--------+-----------+--------+----------+--------+------------+------+------
 slot_node1 |        | physical  |        |          | t      |       7132 | 2102 |              | 0/170000D0  | 
 slot_node2 |        | physical  |        |          | f      |            |      |              |             | 
(2 rows)

test=# select * from sys_stat_replication; 
 pid  | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         backend_st
art         | backend_xmin |   state   | sent_location | write_location | flush_location | replay_location | sync_
priority | sync_state 
------+----------+---------+------------------+---------------+-----------------+------
 7132 |       10 | SYSTEM  | node1            | 192.168.7.248 |                 |       14037 | 2021-03-01 12:23:4
2.131536+08 |              | streaming | 0/170000D0    | 0/170000D0     | 0/170000D0     | 0/170000D0      |      
       1 | sync
(1 row)

[kingbase@node2 bin]$ ./ksql -U SYSTEM -W 123456Abc test -p 9999
ksql (V008R003C002B0270)
Type "help" for help.

test=# show pool_nodes;
 node_id |   hostname    | port  | status | lb_weight |  role   | select_cnt | load_balance_node | replication_del
ay 
---------+---------------+-------+--------+-----------+---------+------------+-------------------+----------------
---
 0       | 192.168.7.248 | 54322 | up     | 0.500000  | standby | 0          | true              | 0
 1       | 192.168.7.249 | 54322 | up     | 0.500000  | primary | 0          | false             | 0
(2 rows)

test=# select * from sys_stat_replication;
 pid  | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         backend_st
art         | backend_xmin |   state   | sent_location | write_location | flush_location | replay_location | sync_
priority | sync_state 
------+----------+---------+------------------+---------------+-----------------+-------
 7132 |       10 | SYSTEM  | node1            | 192.168.7.248 |                 |       14037 | 2021-03-01 12:23:4
2.131536+08 |              | streaming | 0/170000D0    | 0/170000D0     | 0/170000D0     | 0/170000D0      |      
       1 | sync
(1 row)

kingbaseES R3集群修改system用户密码方案V3.0

上一篇:iOS开发UIEvent事件简介


下一篇:js面向对象实现Tab切换