Install MongoDB in Linux and set auto-start.

Source: Internet
Author: User
Tags install mongodb mongodb client

Install MongoDB in Linux and set auto-start.
1. Download mongodb linux version (note the difference between 32-bit and 64-bit),: http://www.mongodb.org/downloads
2.place the downloaded mongodbinstallation file mongodb-linux-x86_64-2.6.7.gz to/usr/local /.
3. Decompress tar-zxvf mongodb-linux-x86_64-2.6.7.gz
Rename music mongodb-linux-x86_64-2.6.7.gz mongodb

4. Create a database file directory. The default value is/data/db. I put the database file directory under the current folder, mkdir-p data/db, create log directory mkdir-p data/log create log store file cd data/log/

Touch 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.
[Root @ localhost bin] #./mongo
MongoDB shell version: 2.6.7
Connecting to: test


7. Add the mongoDB service to the random start
Vi/etc/rc. local
Use the vi editor to open the configuration file and add the following line of code
/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. If the following information is displayed, the startup is successful.

./Mongodb/bin/mongo
MongoDB shell version: 2.6.7
Connecting to: test


9. Shut down mongodb at script startup
# 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) under the/etc/profile. d/directory, the system will automatically execute all shell scripts under the directory after the system starts

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.