MongoDB Learning (a) Centos6.5 installation of MongoDB

Source: Internet
Author: User

Download work:

wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.4.5.tgz

Unzip the downloaded file to the specified directory

Tar XF mongodb-linux-x86_64-rhel62-3.4.5.tgz-c/usr/
MV mongodb-linux-x86_64-rhel62-3.4.5 MONGO

Create data storage directory, log file directory, master configuration file directory

Mkdir/data/dbmkdir/usr/mongo/logmkdir/usr/mongo/conf

Create a log file

Cd/usr/mongo/logtouch Mongo.log

Finish this and then run the program.

cd/usr/mongo/bin./mongod-port=21707--dbpath=/data/db--logpath=/usr/mongo/log/mongo.log

This is the way the foreground starts the MongoDB process, and if the session window closes, the MongoDB process also stops. But MongoDB also provides a background daemon way to start, only need to add a "--fork" parameter, it is worth noting that the "--fork" parameter must be enabled "--logpath" parameter.

Nohup./bin/mongod--dbpath data/--logpath Log/mongodb.log &

Or use nohup this brought life in the background, generally use--fork parameters, but also to see personal habits!

-------------------------------------------------------------------------------------------------------------

Each boot needs to manually specify the log files, data storage location is too cumbersome, you can create a profile, the program every time you start to specify the contents of the configuration file, convenient many!

Cd/usr/mongo/congvim mongo.conf
port=21707
dbpath=/data/db/
Logpath=/usr/mongo/log/mongo.log
Logappend=true #这里的参数是日志文件的内容是追加的形式添加, if you do not write this parameter, add the form of the overlay
Fork=true #这里是启动后台执行程序

Start the program

./usr/mongo/bin/mongod-f/usr/mongo/conf/mongo.conf #参数都将按照配置文件的内容启动

————————————————————————————————————————————————————

Test:

Re-open a terminal

./usr/mongo/bin/mongo 127.0.0.1:21707 #注意这里的程序文件是mongo

In the database, enter

Insert value into Database  > Db.foo.save ({a:1})  Writeresult ({"ninserted": 1})  query from Database  > Db.foo.find ()   {"_ ID ": ObjectId (" 54f02e3b577c993352468185 ")," a ": 1}

Ok!

MongoDB Learning (a) Centos6.5 installation of MongoDB

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.