mongodb怎么退出
MongoDB 提供几种关闭服务的命令,具体为以下:
[mongo@redhatB data]$ mongod --dbpath=/database/mongodb/data/ --logpath=/var/applog/mongo_log/mongo.log --logappend --port=27017 --journal > start_mongo.log 2>&1 光标:键入 Crtl+C 关闭
一、使用 Crtl+C 关闭
备注:如果以前台方式启动 MongoDB 服务,使用“Crtl+C” 服务会关闭,这种关闭方式会等待,当前进行中的的操作完成,所以依然
是干净的关闭方式。
二、
2.1 开启服务
[mongo@redhatB data]$ mongod -f /database/mongodb/data/mongodb_27017.conf forked process: 18155 all output going to: /var/applog/mongo_log/mongo.log child process started successfully, parent exiting
2.2 登陆数据库
[mongo@redhatB data]$ mongo MongoDB shell version: 2.2.1 connecting to: test
2.3 关闭 MongoDB 服务
> use admin; switched to db admin> db.shutdownServer(); Wed Nov 14 06:07:33 DBClientCursor::init call() failed Wed Nov 14 06:07:33 query failed : admin.$cmd { shutdown: 1.0 } to: 127.0.0.1:27017 server should be down... Wed Nov 14 06:07:33 trying reconnect to 127.0.0.1:27017 Wed Nov 14 06:07:33 reconnect 127.0.0.1:27017 failed couldnt connect to server 127.0.0.1:27017
三、使用mongod命令关闭
[mongo@redhatB data]$ mongod --shutdown --dbpath /database/mongodb/data/ killing process with pid: 17747
四 使用 kill 命令
–4.1 查看 mongo 相关进程
[mongo@redhatB data]$ ps -ef | grep mongo root 17573 14213 0 05:10 pts/1 00:00:00 su - mongo mongo 17574 17573 0 05:10 pts/1 00:00:00 -bash mongo 18288 1 0 06:12 ? 00:00:00 mongod -f /database/mongodb/data/mongodb_27017.conf mongo 18300 17574 6 06:13 pts/1 00:00:00 ps -ef mongo 18301 17574 0 06:13 pts/1 00:00:00 grep mongo
4.2 kill mongo 服务进程
[mongo@redhatB data]$ kill 18288[mongo@redhatB data]$ ps -ef | grep pmon mongo 18304 17574 0 06:13 pts/1 00:00:00 grep pmon
更多学习内容,请点击Python学习网!
来源:PY学习网:原文地址:https://www.py.cn/article.html