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. 从库启动  
  9. 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 &  
  10.   
  11. 停止  
  12. /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  
  13. 访问mongo  
  14. /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/bin/mongo  
  15.   
  16.   
  17. Error: error: {  
  18.         "ok" : 0,  
  19.         "errmsg" : "not master and slaveOk=false",  
  20.         "code" : 13435,  
  21.         "codeName" : "NotMasterNoSlaveOk"  
  22. }  
  23. db.getMongo().setSlaveOk();  #启动slave
  24.   
  25.   
  26. 查看服务状态  
  27. db.printReplicationInfo();  
  28.   
  29.   
  30. 杀掉服务  
  31. kill -3 `ps -ef|grep mongod|grep -v grep|awk '{print $2}'`  
  32.   
  33. slaveok=ok  
  34.   
  35. wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.4.0.tgz 
原文地址:https://www.cnblogs.com/moss_tan_jun/p/6269172.html