Installing MongoDB under Linux and setting up self-booting

Source: Internet
Author: User
Tags mongodb client

1. Download the Linux version of MongoDB (note the difference between 32-bit and 64-bit): http://www.mongodb.org/downloads
2. Place the downloaded MongoDB installation file mongodb-linux-x86_64-2.6.7.gz under/usr/local/
3. Unzip TAR-ZXVF mongodb-linux-x86_64-2.6.7.gz
Rename MV mongodb-linux-x86_64-2.6.7.gz MongoDB
4, create the database file directory, the default is/data/db, I put the database file directory under the current folder, Mkdir-p data/db, create log directory mkdir data/log create log file Touch Data/log/mongodb.log
5. Start the service
Cd/usr/local/mongodb/bin
./mongod--dbpath=. /data/db--logpath=. /log/mongodb.log
6. Start the client shell test
[Email protected] bin]#./mongo
MongoDB Shell version:2.6.7
Connecting To:test


7. Add MongoDB service to random start
Vi/etc/rc.local
Use the VI Editor to open the configuration file and add the following line of code to it
/usr/local/mongodb/bin/mongod--dbpath=/usr/local/mongodb/data/db--port 27017--logpath=/usr/local/mongodb/data/ Log/mongodb.log--fork--smallfiles--logappend&

8. Connect to the MongoDB client, the following message is started successfully

./mongodb/bin/mongo
MongoDB Shell version:2.6.7
Connecting To:test


9, script start off MongoDB
# # Start-mongod.sh
/usr/apps/mongodb/bin/mongod--dbpath=/usr/apps/mongodb/data/db--port 27017--logpath=/usr/apps/mongodb/data/log/ Mongodb.log--fork--smallfiles--logappend&
Put the written script (start-mongod.sh file) into the directory/etc/profile.d/, and the system will automatically execute all shell scripts in that directory when it is started.

Installing MongoDB under Linux and setting up self-booting

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.