【MongoDB】关闭
1:kill
1)kill -2 进程号。kill -2 等同于【Ctrl + c】
2)当数据库运行时,切记不要使用kill -9 ,有可能导致数据文件损坏
1 2 3 4 5 6 7 8 9 10 11 |
[mdb@xxf ~]$ mongod --logpath=/data/log/L.log --fork about to fork child process, waiting until server is ready for connections. forked process: 3755 child process started successfully, parent exiting [mdb@xxf ~]$ [mdb@xxf ~]$ pgrep -l mongod 3755 mongod [mdb@xxf ~]$ kill -2 3755 [mdb@xxf ~]$ [mdb@xxf ~]$ pgrep -l mongod [mdb@xxf ~]$ |
2:命令行:shutdown命令,需要使用在admin数据库下运行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
[mdb@xxf ~]$ mongod -f mongodb.cfg --fork about to fork child process, waiting until server is ready for connections. forked process: 4109 child process started successfully, parent exiting [mdb@xxf ~]$ [mdb@xxf ~]$ pgrep -l mongod 4109 mongod [mdb@xxf ~]$ [mdb@xxf ~]$ mongo MongoDB shell version: 3.2.1 connecting to: test <strong>> use admin</strong> switched to db admin <strong>> db.shutdownServer();</strong> server should be down... 2016-01-09T16:58:33.503+0800 I NETWORK [thread1] trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed 2016-01-09T16:58:33.504+0800 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused 2016-01-09T16:58:33.504+0800 I NETWORK [thread1] reconnect 127.0.0.1:27017 (127.0.0.1) failed failed > > exit bye [mdb@xxf ~]$ [mdb@xxf ~]$ pgrep -l mongod [mdb@xxf ~]$ |