KingbaseES R6 集群sys_monitor.sh change_password一键修改集群用户密码
案例说明:
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一键修改集群用户密码的更多相关文章
- KingbaseES R6 集群一键修改集群和数据库参数测试案例
案例说明: 集群环境修改集群或数据库参数,需要在每个node上都要修改,在每个节点而执行修改操作,容易出现漏改或节点上参数不一致等错误:在KingbaseES V8R6的集群中增加了,一键修改参数 ...
- KingbaseES R3 集群一键修改集群用户密码案例
案例说明: 在KingbaseES R3集群的最新版本中增加了kingbase_monitor.sh一键修改集群用户密码的功能,本案例是对此功能的测试. kingbaseES R3集群一键修改密码说明 ...
- KingbaseES R6 集群禁用 root ssh 后需要修改集群为es_server 案例
案例说明: 在生产环境下,由于安全需要,主机间不允许建立root用户的ssh信任连接,这样导致KingbaseES R6 repmgr集群,通过sys_monitor.sh脚本启动集群时,节点之间不能 ...
- KingbaseES R3 集群修改system用户密码方案
方案说明: 对于kingbaseES R3集群修改system密码相比单机环境有一定的复杂性,需要修改的位置如下: 1)数据库中system用户密码,可以用alter user命令修改 2)在reco ...
- 网页一键加入QQ群
三步简单实现功能:网页提供加入qq群按钮 让他人一键加入qq群 第一步:进入qq群官网:http://qun.qq.com/join.html 第二步:选择需要加入的群并生成网页代码 第三步:在网页 ...
- KingbaseES R6 集群修改ssh端口执行sys_backup.sh备份案例
数据库环境:** test=# select version(); version ---------------------------------------------------------- ...
- KingbaseES R6 通过脚本构建集群案例
案例说明: KingbaseES V8R6部署一般可采用图形化方式快速部署,但在生产一线,有的服务器系统未启用图形化环境,所以对于KingbaseES V8R6的集群需采用手工字符界面方式部署,本 ...
- KingbaseES R6 主备流复制集群创建级联复制案例
案例环境: 数据库: test=# select version(); version -------------------------------------------------------- ...
- KingbaseES R6 集群修改物理IP和VIP案例
在用户的实际环境里,可能有时需要修改主机的IP,这就涉及到集群的配置修改.以下以例子的方式,介绍下KingbaseES R6集群如何修改IP. 一.案例测试环境 操作系统: [KINGBASE@nod ...
随机推荐
- multiset 用法复习
前言 看题解上有 \(\text{multiset}\) 然后发现没脑子的我又忘了... 正文 \(\text{multiset}\) 可以看成一个序列,插入一个数,删除一个数都能够在 \(O(\lo ...
- 面试突击62:group by 有哪些注意事项?
注意:本文以下内容基于 MySQL 5.7 InnoDB 数据库引擎. 1.group by 后面不能加 where 在 MySQL 中,所有的 SQL 查询语法要遵循以下语法顺序: select f ...
- 使用supervisor设置应用开机自启
安装supervisor: sudo apt install supervisor -y 创建配置文件: sudo vim /etc/supervisor/conf.d/frpc.conf frpc. ...
- C++系统函数
C++语言预先编写了很多常用函数提供给广大程序员使用,这些函数被统称为系统函数.C++语言全盘继承了C语言的标准C库,另外又增加了一些新的库(更多的是系统类库),这些新库被统称为C++标准库. 一.C ...
- MongoDB慢查询与索引
MongoDB慢查询 慢查询分析 开启内置的慢查询分析器 db.setProfilingLevel(n,m),n的取值可选0,1,2 0:表示不记录 1:表示记录慢速操作,如果值为1,m需要传慢查询的 ...
- 分享一个WPF 实现 Windows 软件快捷小工具
分享一个WPF 实现 Windows 软件快捷小工具 Windows 软件快捷小工具 作者:WPFDevelopersOrg 原文链接:https://github.com/WPFDevelopers ...
- 获取字典中values值中最大的数,返回对应的keys
1.字典中键值对的获取 print(data.values()) # 查看字典的值 print(data.keys()) # 查看字典的key 2.对字典中的值进行排序 sorted(data.val ...
- Windows快捷安装应用方法(此处以Virtualbox为例)
1.执行已下载的virtualbox的安装exe文件,使用pywinauto模拟点击Windows安装的对应控件 1.1.启动exe文件 start *.exe 1.2.使用pywinauto(也适用 ...
- mysql玩法
如何字段名查找所在的表名 SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = '字段名字' select sys ...
- WPF 截图控件之文字(七)「仿微信」
前言 接着上周写的截图控件继续更新添加 文字. 1.WPF实现截屏「仿微信」 2.WPF 实现截屏控件之移动(二)「仿微信」 3.WPF 截图控件之伸缩(三) 「仿微信」 4.WPF 截图控件之绘制方 ...