案例说明:

kingbaseES R6集群用户密码修改,需要修改两处:

 1)修改数据库用户密码(alter user);
2)修改.encpwd文件中用户密码;

可以通过sys_monitor.sh change_password一键同时修改数据库内部用户密码和.encpwd文件中密码。

案例测试版本:

test=# select version();
version
----------------------------------------------------------------------------------------------------------------------
KingbaseES V008R006C003B0010 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit
(1 row)

集群架构:

sys_monitor.sh change_password user new_password —修改集群使用的用户的密码

描述:

sys_monitor.sh change_password user new_password判断用户是否为集群使用的用户,如果是则修改用户密码,如果不是则提示用户集群未使用该用户,请使用sql方式修改用户密码。

选项:

以下是脚本执行参数:

change_password: 脚本调用修改用户密码函数

user: 要进行修改密码的用户,只能是集群初始化时指定的用户和esrep

new_password: 用户的新密码

注意事项:

1.必须在集群所有节点状态正常的情况下才能执行修改密码操作
2.sys_monitor.sh change_password 用户名 '密码' 使用一键修改密码功能时 密码参数必须使用''括起来
3.用户必须是已经使用.encpwd免密配置文件配置了免密的用户才能进行修改密码,否则会提示集群未使用该用户,请使用sql alter user命令进行修改密码

一、查看esrep用户原密码

1).encpwd文件

 [kingbase@node1 ~]$ cat .encpwd
*:*:*:system:MTIzNDU2
*:*:*:esrep:S2luZ2Jhc2VoYTExMA== [kingbase@node1 ~]$ echo 'S2luZ2Jhc2VoYTExMA=='|base64 -d
Kingbaseha110

2)数据库用户密码

用户密码登录测试(‘Kingbaseha110’):

[kingbase@node3 bin]$ ./ksql -U esrep -W esrep
Password:
ksql (V8.0)
Type "help" for help.

二、一键修改esrep用户密码

[kingbase@node3 bin]$ ./sys_monitor.sh  --help
Usage: ./sys_monitor.sh {start|stop|restart|stoplocal|set [--restart]|change_password user password} [kingbase@node3 bin]$ ./sys_monitor.sh change_password esrep 'beijing'
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------
1 | node248 | standby | running | node243 | default | 90 | 26 | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=2
3 | node243 | primary | * running | | default | 100 | 26 | host=192.168.7.243 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=2
4 | node249 | standby | running | node243 | default | 100 | 26 | host=192.168.7.249 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
ALTER ROLE

三、新密码登录测试

# 新的用户密码登录(‘beijing’):

[kingbase@node3 bin]$ ./ksql -U esrep -W esrep
Password:
ksql (V8.0)
Type "help" for help.

# 查看.encpwd文件

[kingbase@node3 ~]$ cat .encpwd
*:*:*:system:MTIzNDU2
*:*:*:esrep:YmVpamluZw== [kingbase@node3 ~]$ echo 'YmVpamluZw=='|base64 -d
beijing

# 所有节点密码都已经被修改

[kingbase@node1 ~]$ cat .encpwd
*:*:*:system:MTIzNDU2
*:*:*:esrep:YmVpamluZw== [kingbase@node2 ~]$ cat .encpwd
*:*:*:system:MTIzNDU2
*:*:*:esrep:YmVpamluZw==

四、重启集群测试

[kingbase@node3 bin]$ ./sys_monitor.sh restart
2021-03-01 13:07:08 Ready to stop all DB ...
There is no service "node_export" running currently.
There is no service "postgres_ex" running currently.
There is no service "node_export" running currently.
There is no service "postgres_ex" running currently.
There is no service "node_export" running currently.
There is no service "postgres_ex" running currently.
2021-03-01 13:07:18 begin to stop repmgrd on "[192.168.7.248]".
2021-03-01 13:07:18 repmgrd on "[192.168.7.248]" already stopped.
2021-03-01 13:07:18 begin to stop repmgrd on "[192.168.7.243]".
2021-03-01 13:07:19 repmgrd on "[192.168.7.243]" already stopped.
2021-03-01 13:07:19 begin to stop repmgrd on "[192.168.7.249]".
2021-03-01 13:07:20 repmgrd on "[192.168.7.249]" already stopped.
2021-03-01 13:07:20 begin to stop DB on "[192.168.7.248]".
waiting for server to shut down.... done
server stopped
2021-03-01 13:07:21 DB on "[192.168.7.248]" stop success.
2021-03-01 13:07:21 begin to stop DB on "[192.168.7.249]".
sys_ctl: directory "/home/kingbase/cluster/R6HA/KHA/kingbase/data" does not exist
2021-03-01 13:07:23 DB on "[192.168.7.249]" stop success.
2021-03-01 13:07:23 begin to stop DB on "[192.168.7.243]".
waiting for server to shut down..... done
server stopped
2021-03-01 13:07:25 DB on "[192.168.7.243]" stop success.
2021-03-01 13:07:25 Done.
2021-03-01 13:07:25 Ready to start all DB ...
2021-03-01 13:07:25 begin to start DB on "[192.168.7.243]".
waiting for server to start.... done
server started
2021-03-01 13:07:27 execute to start DB on "[192.168.7.243]" success, connect to check it.
2021-03-01 13:07:28 DB on "[192.168.7.243]" start success.
2021-03-01 13:07:28 Try to ping trusted_servers on host 192.168.7.248 ...
2021-03-01 13:07:30 Try to ping trusted_servers on host 192.168.7.243 ...
2021-03-01 13:07:33 Try to ping trusted_servers on host 192.168.7.249 ...
2021-03-01 13:07:36 begin to start DB on "[192.168.7.248]".
waiting for server to start.... done
server started
2021-03-01 13:07:37 execute to start DB on "[192.168.7.248]" success, connect to check it.
2021-03-01 13:07:38 DB on "[192.168.7.248]" start success.
2021-03-01 13:07:38 begin to start DB on "[192.168.7.249]".
sys_ctl: directory "/home/kingbase/cluster/R6HA/KHA/kingbase/data" does not exist
2021-03-01 13:07:40 execute to start DB on "[192.168.7.249]" failed.
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------
1 | node248 | standby | running | node243 | default | 90 | 26 | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=2
3 | node243 | primary | * running | | default | 100 | 26 | host=192.168.7.243 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=2
4 | node249 | standby | running | node243 | default | 100 | 26 | host=192.168.7.249 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2021-03-01 13:07:40 The primary DB is started.
2021-03-01 13:07:45 Success to load virtual ip [192.168.7.240/24] on primary host [192.168.7.243].
2021-03-01 13:07:45 Try to ping vip on host 192.168.7.248 ...
2021-03-01 13:07:47 Try to ping vip on host 192.168.7.243 ...
2021-03-01 13:07:50 Try to ping vip on host 192.168.7.249 ...
2021-03-01 13:07:53 begin to start repmgrd on "[192.168.7.248]".
[2021-03-01 13:08:03] [NOTICE] using provided configuration file "/home/kingbase/cluster/R6HA/KHA/kingbase/bin/../etc/repmgr.conf"
[2021-03-01 13:08:03] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/KHA/kingbase/hamgr.log" 2021-03-01 13:07:53 repmgrd on "[192.168.7.248]" start success.
2021-03-01 13:07:53 begin to start repmgrd on "[192.168.7.243]".
[2021-03-01 13:07:54] [NOTICE] using provided configuration file "/home/kingbase/cluster/R6HA/KHA/kingbase/bin/../etc/repmgr.conf"
[2021-03-01 13:07:54] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/KHA/kingbase/hamgr.log" 2021-03-01 13:07:54 repmgrd on "[192.168.7.243]" start success.
2021-03-01 13:07:54 begin to start repmgrd on "[192.168.7.249]".
[2021-03-01 13:06:04] [NOTICE] using provided configuration file "/home/kingbase/cluster/R6HA/KHA/kingbase/bin/../etc/repmgr.conf"
[2021-03-01 13:06:04] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/KHA/kingbase/hamgr.log" 2021-03-01 13:07:56 repmgrd on "[192.168.7.249]" start success.
ID | Name | Role | Status | Upstream | repmgrd | PID | Paused? | Upstream last seen
----+---------+---------+-----------+----------+---------+-------+---------+--------------------
1 | node248 | standby | running | node243 | running | 2625 | no | 0 second(s) ago
3 | node243 | primary | * running | | running | 22122 | no | n/a
4 | node249 | standby | running | node243 | running | 16939 | no | n/a
2021-03-01 13:08:08 Done.

# 查看集群节点状态信息

[kingbase@node3 bin]$ ./repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------
1 | node248 | standby | running | node243 | default | 90 | 26 | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=2
3 | node243 | primary | * running | | default | 100 | 26 | host=192.168.7.243 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=2
4 | node249 | standby | running | node243 | default | 100 | 26 | host=192.168.7.249 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

KingbaseES R6 集群sys_monitor.sh change_password一键修改集群用户密码的更多相关文章

  1. KingbaseES R6 集群一键修改集群和数据库参数测试案例

    ​ 案例说明: 集群环境修改集群或数据库参数,需要在每个node上都要修改,在每个节点而执行修改操作,容易出现漏改或节点上参数不一致等错误:在KingbaseES V8R6的集群中增加了,一键修改参数 ...

  2. KingbaseES R3 集群一键修改集群用户密码案例

    案例说明: 在KingbaseES R3集群的最新版本中增加了kingbase_monitor.sh一键修改集群用户密码的功能,本案例是对此功能的测试. kingbaseES R3集群一键修改密码说明 ...

  3. KingbaseES R6 集群禁用 root ssh 后需要修改集群为es_server 案例

    案例说明: 在生产环境下,由于安全需要,主机间不允许建立root用户的ssh信任连接,这样导致KingbaseES R6 repmgr集群,通过sys_monitor.sh脚本启动集群时,节点之间不能 ...

  4. KingbaseES R3 集群修改system用户密码方案

    方案说明: 对于kingbaseES R3集群修改system密码相比单机环境有一定的复杂性,需要修改的位置如下: 1)数据库中system用户密码,可以用alter user命令修改 2)在reco ...

  5. 网页一键加入QQ群

    三步简单实现功能:网页提供加入qq群按钮  让他人一键加入qq群 第一步:进入qq群官网:http://qun.qq.com/join.html 第二步:选择需要加入的群并生成网页代码 第三步:在网页 ...

  6. KingbaseES R6 集群修改ssh端口执行sys_backup.sh备份案例

    数据库环境:** test=# select version(); version ---------------------------------------------------------- ...

  7. KingbaseES R6 通过脚本构建集群案例

      案例说明: KingbaseES V8R6部署一般可采用图形化方式快速部署,但在生产一线,有的服务器系统未启用图形化环境,所以对于KingbaseES V8R6的集群需采用手工字符界面方式部署,本 ...

  8. KingbaseES R6 主备流复制集群创建级联复制案例

    案例环境: 数据库: test=# select version(); version -------------------------------------------------------- ...

  9. KingbaseES R6 集群修改物理IP和VIP案例

    在用户的实际环境里,可能有时需要修改主机的IP,这就涉及到集群的配置修改.以下以例子的方式,介绍下KingbaseES R6集群如何修改IP. 一.案例测试环境 操作系统: [KINGBASE@nod ...

随机推荐

  1. nifi从入门到实战(保姆级教程)——环境篇

    背景: 公司领导决定将各种基础数据的导入从代码中分离出来,用Apache Nifi替换.使开发者们更关注在业务上,而不用关心基础的由来. Apache Nifi对于整个团队都是一个全新的工具,之前大家 ...

  2. windows 2003系统安装

    一.使用workstation创建虚拟机 二.系统安装 点击"Enter" 点击"F8" 点击"Enter" 如下图所示: 点击" ...

  3. React技巧之字符串插值

    原文链接:https://bobbyhadz.com/blog/react-string-interpolation 作者:Borislav Hadzhiev 正文从这开始~ 总览 在React中,使 ...

  4. -bash: /usr/local/maven/apache-maven-3.8.1/bin/mvn: 权限不够

    chmod a+x /usr/local/maven/apache-maven-3.8.1/bin/mvn

  5. 数据结构-查找-二叉排序查找(平衡二叉树,B树,B+树概念)

    0.为什么需要二叉排序树 1)数组存储方式: 优点:通过下标访问元素,速度快,对于有序数组,可以通过二分查找提高检索效率: 缺点:如果检索具体某个值,或者插入值(按一定顺序)会整体移动,效率较低: 2 ...

  6. 代码补全——Vim/Neovim中YouCompleteMe添加第三方库的支持

    参考链接: https://github.com/ycm-core/YouCompleteMe#c-family-semantic-completion https://cloud.tencent.c ...

  7. Phabricator Conduit API介绍

    在Phabricator页面,可以完成创建和编辑Project.Task等操作.但是如果想实现外部系统可以自主操作Phabricator,那么就需要调用Phabricator Conduit API, ...

  8. 从零开始完整开发基于websocket的在线对弈游戏【五子棋】,只用几十行代码完成全部逻辑。

    五子棋是规则简单明了的策略型游戏,先形成五子连线者获胜.本课程习作采用两人在线对弈的方式进行比赛,拿着手机在上下班路上玩特别合适. 整个过程在众触低代码应用平台进行,使用表达式描述游戏逻辑(高度简化版 ...

  9. 队列Q_via牛客网

    题目 链接:https://ac.nowcoder.com/acm/contest/28537/L 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语 ...

  10. inotify 目录文件变更实时监控

    # inotify 软件 # 安装:通过epel,安装在客户端 # 功能:实时监控目录下文件的更变 # 监控事件:创建.删除.修改.移动... # 安装位置:客户端 # 安装命令: sudo apt- ...