MongoDB (4): A variety of ways to turn off service commands

Source: Internet
Author: User

http://blog.csdn.net/czw698/article/details/8791153

MongoDB provides several commands for shutting down the service, specifically the following:


One use crtl+c off

[Email protected] data]$ Mongod--dbpath=/database/mongodb/data/--logpath=/var/applog/mongo_log/mongo.log-- Logappend--port=27017--journal > Start_mongo.log 2>&1
Cursor: type crtl+c close

Note: If you start the MongoDB service as a foreground, the use of the "crtl+c" service will be turned off, which will wait for
The currently in progress operation is completed, so it is still a clean shutdown mode.

Two using the database command to close
--2.1 Open Service

[Email protected] 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 Landing Database

[Email protected] data]$ MONGO
MongoDB Shell version:2.2.1
Connecting To:test

--2.3 Close MongoDB Service

> Use admin;
Switched to DB admin

> db.shutdownserver ();
Wed Nov 06:07:33 Dbclientcursor::init call () failed
Wed Nov 06:07:33 Query failed:admin. $cmd {shutdown:1.0} to:127.0.0.1:27017
Server should is down ...
Wed Nov 06:07:33 trying reconnect to 127.0.0.1:27017
Wed Nov 06:07:33 Reconnect 127.0.0.1:27017 failed couldnt connect to server 127.0.0.1:27017

Three use the Mongod command to close

[Email protected] data]$ mongod --shutdown --dbpath/database/mongodb/data/
Killing process with pid:17747

Note: The shutdown option of the Mongod command can cleanly shut down the MongoDB service.

Four using the KILL command
--4.1 viewing MONGO related processes

[Email protected] 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 Service process

 [[email  Protected] data]$ kill 18288

[[email protected] data]$ ps-ef | grep pmon
mongo    18304 17574&n Bsp 0 06:13 pts/1    00:00:00 grep pmon

Note: You can use the KILL command of the operating system to send a SIGINT or SIGTERM signal to the mongod process.
That is, "Kill-2 pid," or "kill-15 pid".

It is not recommended to use "kill-9 pid" because if MongoDB is running without logging on (--journal),
may result in data loss.

Five references
Http://www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo
http://docs.mongodb.org/manual/reference/mongod/
Http://www.cnblogs.com/taobataoma/archive/2007/08/30/875743.html

MongoDB (4): A variety of ways to turn off service commands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.