1. MongoDB Installation
First download MongoDB, official website address; Http://www.mongodb.org/downloads
Curl-o http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.1.tgz
Unzip
TAR-ZXVF mongodb-linux-x86_64-2.6.1.tgz
New Catalog
Mkdir-p mongodbcp-r-N mongodb-linux-x86_64-2.6.1/mongodb
2. Starting from the command line
Start MongoDB by executing./bin/mongod to see all the options for Mongod startup
CD MongoDB./bin/mongod--help
Main options:--dbpath: Data Save directory, default is/data/db/, each mongod requires a separate data directory, startup will be generated in the data directory Mongod.lock, this file to prevent other Mongod process use the directory. --port: Boot port, default = 27017--fork: Boot as daemon. --logpath: Log directory--config specify the configuration file.
Start MongoDB
mkdir data./bin/mongod--port 9000--fork--logpath/home/mongodb/log/mongodb.log --dbpath/home/mongodb/data/
3. Start in profile mode
Setting up a configuration file
mkdir Configvim config/mongodb.conf
Write the above configuration to a file
# mongodb Config fileport = 9000fork = Truelogpath =/home/mongodb/log/mongodb.logdbpath =/home/mongodb/data/
Start
./bin/mongod--config/home/mongdb/conf/mongodb.conf
It is recommended to use the configuration file mode to start.
4. MongoDB stop can be stopped by using the Kill process mode. If the process number is 10000, kill 10000 is used. The system saves the data, then closes the connection and stops the service. You cannot use kill-9 to shut down the database directly, resulting in corruption of the data file.
Another way to turn off the use of the MONGO shell, which is the surest way
./bin/mongo--port 9000use admindb.shutdownserver ();
Address: http://blog.csdn.net/yonggang7/article/details/25543283