启动关闭
先启动mongodb,我这里没有设置mongodb开机自动启动
# 启动服务 sudo service mongod start # 再次查看 sudo service mongod status
📢📢📢在root权限下
- mongodb的启动顺序是,先启动所有节点配置服务器(在节点master、worker1、worker2配置)
mongod -f /usr/local/mongodb/conf/config.conf
- 再启动所有节点的分片
- shard1 server(在节点master、worker1、worker2)
mongod -f /usr/local/mongodb/conf/shard1.conf
- shard2 server(在节点master、worker1、worker2)
mongod -f /usr/local/mongodb/conf/shard2.conf
- shard3 server(在节点master、worker1、worker2)
mongod -f /usr/local/mongodb/conf/shard3.conf
- 最后启动所有节点的mongos (在节点master、worker1、worker2)
mongos -f /usr/local/mongodb/conf/mongos.conf
- 连接mongos
mongosh 127.0.0.1:20000
- 关闭时,直接killall杀掉所有进程
killall mongod killall mongos