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

MongoDB 分片集群修改管理员密码


文章目录

      • 一、注释MongoDB分片集群认证参数(三台主机都要操作)
          • 1、停止MongoDB分片集群所有容器
          • 2、注释用户认证参数
          • 3、启动MongoDB分片集群所有容器
          • 4、验证MongoDB分片conf服务、shared1、shared2、shared3是否不需要用户和密码登录
      • 二、修改MongoDB分片集群管理员密码
          • 1、修改config服务主节点管理员密码
          • 2、修改shared1分片主节点管理员密码
          • 3、修改shared2分片主节点管理员密码
          • 4、修改shared3分片主节点管理员密码
      • 三、去掉MongoDB分片集群认证参数注释(三台主机都要操作)
          • 1、停止MongoDB分片集群所有容器
          • 2、去掉注释用户认证参数
          • 3、启动MongoDB分片集群所有容器
          • 4、验证MongoDB分片conf服务、shared1、shared2、shared3使用用户和密码登录




MongoDB分片集群主机规划:

主机名称主机IPCPU内存mongos端口config端口share1端口share2端口share3端口操作系统及软件版本
mongodb01192.168.91.612*416GB2701727019271012710227103CentOS 7.9 mongo 4.4.29 mongos 4.4.29 mongod 4.4.29 mongosh 2.2.29
mongodb02192.168.91.622*416GB2701727019271012710227103CentOS 7.9 mongo 4.4.29 mongos 4.4.29 mongod 4.4.29 mongosh 2.2.29
mongodb03192.168.91.632*416GB2701727019271012710227103CentOS 7.9 mongo 4.4.29 mongos 4.4.29 mongod 4.4.29 mongosh 2.2.29



一、注释MongoDB分片集群认证参数(三台主机都要操作)


1、停止MongoDB分片集群所有容器
systemctl stop mongos
systemctl stop shard3
systemctl stop shard2
systemctl stop shard1
systemctl stop mongodsystemctl status mongos
systemctl status shard3
systemctl status shard2
systemctl status shard1
systemctl status mongod

2、注释用户认证参数
[root@epmongodb01 ~]#vim /data/mongodb/configsvr/conf/configsvr.conf
#security:
#  keyFile: /data/mongodb/keyfile/keyfile
#  authorization: enabled[root@epmongodb01 ~]#vim /data/mongodb/shard1/conf/shard1.conf
#security:
#  keyFile: /data/mongodb/keyfile/keyfile
#  authorization: enabled[root@epmongodb01 ~]#vim /data/mongodb/shard2/conf/shard2.conf
#security:
#  keyFile: /data/mongodb/keyfile/keyfile
#  authorization: enabled[root@epmongodb01 ~]#vim /data/mongodb/shard3/conf/shard3.conf
#security:
#  keyFile: /data/mongodb/keyfile/keyfile
#  authorization: enabled[root@epmongodb01 ~]#vim /data/mongodb/mongos/conf/mongos.conf
#security:
#  keyFile: /data/mongodb/keyfile/keyfile

3、启动MongoDB分片集群所有容器
systemctl start mongod
systemctl start shard1
systemctl start shard2
systemctl start shard3
systemctl start mongossystemctl status mongod
systemctl status shard1
systemctl status shard2
systemctl status mongos

4、验证MongoDB分片conf服务、shared1、shared2、shared3是否不需要用户和密码登录
### 验证conf服务
mongosh --host 192.168.91.61 --port 27017
show dbs
exit### 验证shared1服务
mongosh --host 192.168.91.61 --port 27101
show dbs
exit### 验证shared2服务
mongosh --host 192.168.91.61 --port 27102
show dbs
exit### 验证shared3服务
mongosh --host 192.168.91.61 --port 27103
show dbs
exit



二、修改MongoDB分片集群管理员密码

提示:MongoDB分片集群可以修改管理员密码,也可以删除掉原来的管理员再重新创建新的管理员。


1、修改config服务主节点管理员密码
mongosh --host 192.168.91.61 --port 27019use admin 
db.system.users.find();db.changeUserPassword('root','123456');
db.auth('root','123456')

2、修改shared1分片主节点管理员密码
mongosh --host 192.168.91.61 --port 27101use admin 
db.system.users.find();db.changeUserPassword('root','123456');
db.auth('root','123456')

3、修改shared2分片主节点管理员密码
mongosh --host 192.168.91.61 --port 27102use admin 
db.system.users.find();db.changeUserPassword('root','123456');
db.auth('root','123456')

4、修改shared3分片主节点管理员密码
mongosh --host 192.168.91.61 --port 27103use admin 
db.system.users.find();db.changeUserPassword('root','123456');
db.auth('root','123456')



三、去掉MongoDB分片集群认证参数注释(三台主机都要操作)


1、停止MongoDB分片集群所有容器
systemctl stop mongos
systemctl stop shard3
systemctl stop shard2
systemctl stop shard1
systemctl stop mongodsystemctl status mongos
systemctl status shard3
systemctl status shard2
systemctl status shard1
systemctl status mongod

2、去掉注释用户认证参数
[root@epmongodb01 ~]#vim /data/mongodb/configsvr/conf/configsvr.conf
security:keyFile: /data/mongodb/keyfile/keyfileauthorization: enabled[root@epmongodb01 ~]#vim /data/mongodb/shard1/conf/shard1.conf
security:keyFile: /data/mongodb/keyfile/keyfileauthorization: enabled[root@epmongodb01 ~]#vim /data/mongodb/shard2/conf/shard2.conf
security:keyFile: /data/mongodb/keyfile/keyfileauthorization: enabled[root@epmongodb01 ~]#vim /data/mongodb/shard3/conf/shard3.conf
security:keyFile: /data/mongodb/keyfile/keyfileauthorization: enabled[root@epmongodb01 ~]#vim /data/mongodb/mongos/conf/mongos.conf
security:keyFile: /data/mongodb/keyfile/keyfile

3、启动MongoDB分片集群所有容器
systemctl start mongod
systemctl start shard1
systemctl start shard2
systemctl start shard3
systemctl start mongossystemctl status mongod
systemctl status shard1
systemctl status shard2
systemctl status mongos

4、验证MongoDB分片conf服务、shared1、shared2、shared3使用用户和密码登录
### 验证conf服务
mongosh --host 192.168.91.61 --port 27017 -u root –p 123456
show dbs
exit### 验证shared1服务
mongosh --host 192.168.91.61 --port 27101 -u root –p 123456
show dbs
exit### 验证shared2服务
mongosh --host 192.168.91.61 --port 27102 -u root –p 123456
show dbs
exit### 验证shared3服务
mongosh --host 192.168.91.61 --port 27103 -u root –p 123456
show dbs
exit
http://www.dtcms.com/a/340908.html

相关文章:

  • 密码加密算法和JWT无状态认证
  • K距离间隔重排字符串 (LeetCode 358) — Swift解法 + 可运行Demo
  • 360T7刷OpenWRT笔记
  • 深入解析EventPoller:Disruptor的轮询式事件处理机制
  • Download:几款主流的全球范围的NDVI产品参数说明和下载
  • Spring Boot 发展史
  • 机器学习——数据清洗
  • JS对象与JSON转换全解析
  • C/C++嵌入式笔试核心考点精解
  • AI 与 OCR 识别:深度融合的智能信息提取技术
  • Elasticsearch 写入全链路:从单机到集群
  • 实验8.20
  • nvidia最新论文:小型语言模型是代理人工智能的未来
  • iOS App 上架实战 从内测到应用商店发布的全周期流程解析
  • Linux 文件系统权限管理(补充)
  • 管理项目服务器连接数据库
  • Linux 文本处理三剑客:awk、grep、sed 完全指南
  • 中小型企业是否需要使用高防服务器
  • Linux-文本搜索工具grep
  • C++进阶-----C++11
  • Hangfire定时部署(.NET 8 + SQL Server)
  • Android 资源替换:静态替换 vs 动态替换
  • PHP特有的安全漏洞及渗透测试利用方法(通俗易懂)
  • 项目1总结其一
  • 49 C++ STL模板库18-类模板-pair
  • ROS 2系统Callback Group概念笔记
  • 突发!DeepSeek刚刚开源V3.1-Base
  • UTF-8 编解码可视化分析
  • 【Day 30】Linux-SQL语句
  • C/C++ 与嵌入式岗位常见笔试题详解