mongos 分片集群

1、先配置配置服务器,

113-114 两个集群,端口27018,配置文件/etc/mongod27018.conf, 服务 mongod27018.service

mongo --host 127.0.0.1 --port 27018

use admin

db.auth('root', 'password')

rs.stauts()

2、配置分片服务器

113-118 6个分片,每个分片又是一个单独的集群模式,端口27017, 配置文件/etc/mongod27017.conf, 服务 mongod27017.service

mongo --host 127.0.0.1 --port 27017

use admin

db.auth('root', 'password')

rs.stauts()

3、路由服务器

45、49、60 三台路由服务器,配置文件/etc/mongod27017.conf, 没有配置服务,命令行启动

mongos -f /etc/mongod27017.conf 

mongo --host 127.0.0.1 --port 27017

use admin

db.auth('root', 'password')

4、重启顺序

关闭路由mongos服务,pkill mongos;  在关闭所有的分片服务 systemctl stop mongod27017;   最后关闭配置服务 systemctl stop mongod27018

启动配置服务 systemctl start mongod27018; 启动分片服务 systemctl start mongod27017; 启动路由mongos服务 mongos -f /etc/mongod27017.conf

在正常情况下,重启 mongos 实例后,不需要重新添加分片;

  • 查看分片状态:
    使用 sh.status() 来检查 mongos 的分片信息和状态。如果所有分片、集合和片段都正确显示,说明配置是正确的。

  • 查看分片配置:
    确保在 config.shardsconfig.databases 集合中的信息是正确的,可以通过以下命令查看:

    use config
    db.shards.find().pretty()
    db.databases.find().pretty()

 

posted @   华之菜  阅读(11)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
点击右上角即可分享
微信分享提示