Mongodb installation and configuration

Source: Internet
Author: User
Tags mongo shell
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();

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.