1. mongodb installation first download mongodb, official website address; www. mongodb. orgdownloadscurl-Odownloads.mongodb.orglinuxmongodb-linux-x86_64-2.6.1.tgz decompress the tar-zxvfmongodb-linux-x86_64-2.6.1.tgz to create a directory mkdir-pw.dbcp-R-nmongodb-li
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 decompress tar-zxvf mongodb-linux-x86_64-2.6.1.tgz new directory mkdir-p mongodbcp-R-n mongodb-li
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
Extract
tar -zxvf mongodb-linux-x86_64-2.6.1.tgz
Create directory
mkdir -p mongodbcp -R -n mongodb-linux-x86_64-2.6.1/ mongodb
2. Run the command line to start mongodb by running./bin/mongod, and view all the startup options of mongod.
cd mongodb ./bin/mongod --help
Main options: -- dbpath: data storage directory. The default value is/data/db/. Each mongod requires an independent data directory. mongod is generated in the data directory at startup. lock, this file prevents other mongod processes from using this directory. -- Port: The Start port. The default value is 27017 -- fork. It is started as a daemon. -- Logpath: Specifies the configuration file in the log directory -- config.
Start mongodb
mkdir data./bin/mongod --port 9000 --fork --logpath /home/mongodb/log/mongodb.log --dbpath /home/mongodb/data/
3. Start creating a configuration file as 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
We recommend that you use the configuration file to start the instance. 4. You can stop mongodb by killing the process. If the process number is 10000, kill 10000 is used. In this way, the system will save the data, close the connection, and stop the service. You cannot use kill-9 to directly close the database, resulting in damage to the data file.
Another method is to disable mongo shell, which is the safest way.
./bin/mongo --port 9000use admindb.shutdownServer();