How to install and use MongoDB in linux

Source: Internet
Author: User
Tags mongodb

The installation code is as follows:

Tar-zxf mongodb-linux-x86_64-2.6.5.tgz
Music mongodb-linux-x86_64-2.6.5/usr/local/
Cd/usr/local
Music mongodb-linux-x86_64-2.6.5 mongodb
 
// Create a data directory
Mkdir/data2/mongodbData
// Create a log file (note that it must be a file)
Touch/data2/mongodbLogs
Note: I started to encounter an error and reminded me of line100. Later I saw that it was caused by insufficient disk space on my VM.

MongoDB startup


# -- Fork means starting in the background
/Usr/local/mongodb/bin/mongod -- dbpath =/data2/mongodbData/-- logpath =/data2/mongodbLogs -- fork

When the startup is successful: (note that the startup process is slow in actual operations, and remember that logs must be a file)

Process information after successful startup:

Add MongoDB as startup

Echo '/usr/local/mongodb/bin/mongod -- dbpath =/data2/mongodbData/-- logpath =/data2/mongodbLogs -- fork'>/etc/rc. local

Disable MongoDB service

Pkill mongod

Note: Do not use kill-9. If it is used, mongod cannot be started. You can enter the data directory of mongodb to see if it is available. lock file to delete the file. Restart.

Use MongoDb

Run the following command in the binfile directory of mongodb:


./Mongo

The following information is displayed: (exit)

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.