mongodb 的一些启动命令

时间:2023-03-09 02:01:09
mongodb 的一些启动命令
  1. 启动命令
  2. nohup /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/bin/mongod -dbpath /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/db &
  3. 启动
  4. nohup /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/bin/mongod --config /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/bin/mongodb.conf -master &
  5. 停止
  6. /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/bin/mongod --shutdown -dbpath /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/db
  7. 从库启动
  8. nohup /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/bin/mongod --config /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/bin/mongodb.conf -slave -source 192.168.1.130:27017 &
  9. 停止
  10. /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/bin/mongod --shutdown -dbpath /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/db
  11. 访问mongo
  12. /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/bin/mongo
  13. Error: error: {
  14. "ok" : 0,
  15. "errmsg" : "not master and slaveOk=false",
  16. "code" : 13435,
  17. "codeName" : "NotMasterNoSlaveOk"
  18. }
  19. db.getMongo().setSlaveOk();  #启动slave
  20. 查看服务状态
  21. db.printReplicationInfo();
  22. 杀掉服务
  23. kill -3 `ps -ef|grep mongod|grep -v grep|awk '{print $2}'`
  24. slaveok=ok
  25. wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.4.0.tgz