Install Mongodb 2.6.5 and centosmongodb in CentOS 6/Linux

Source: Internet
Author: User
Tags install mongodb

Install Mongodb 2.6.5 and centosmongodb in CentOS 6/Linux
Mongo DB is a non-relational database (NoSql) that is very popular in the IT industry. Its flexible data storage method is favored by current IT practitioners. Mongo DB implements the object-oriented approach. In Mongo DB, each record is a Document object. The biggest advantage of Mongo DB is that all data persistence operations can easily implement CRUD operations without the need for developers to manually write SQL statements. Here we will introduce how to install mongodb:

System Environment: CentOS 6.5
Mongo DB: mongodb-linux-x86_64-2.6.5.tgz

1. Check whether mongodb has been installed. If yes, delete it.
# Rpm-qa | grep mongodb

2. Download mongodb (download to/doiido/soft)
# Mkdir/doiido/soft
# Wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.5.tgz-P/doiido/soft

3. Decompress mongodb
# Cd/doiido/soft
# Tar zxvf mongodb-linux-x86_64-2.6.5.tgz
# Music mongodb-linux-x86_64-2.6.5/doiido/mongodb

4. Create a storage directory for databases and logs
# Mkdir/doiido/mongodb/data
# Mkdir/doiido/mongodb/logs
# Touch/doiido/mongodb/logs/mongodb. log

5. Create a configuration file
# Vi/doiido/mongodb/bin/mongodb. conf
Dbpath =/doiido/mongodb/data
Logpath =/doiido/mongodb/logs/mongodb. log
Port = 27017
Fork = true
Nohttpinterface = true

6. Start mongodb
#/Doiido/mongodb/bin/mongod -- bind_ip localhost-f/doiido/mongodb/bin/mongodb. conf

7. Set startup
# Echo "/doiido/mongodb/bin/mongod -- config/doiido/mongodb/bin/mongodb. conf">/etc/rc. local

8. Test
8.1 enter the mongodb shell mode
#/Doiido/mongodb/bin/mongo

8.2 view the Database List
> Show dbs

8.3. Current db version
> Db. version ();

9. Stop mongodb
9.1 go to mongodb and close
#/Doiido/mongodb/bin/mongo
> Db. shutdownServer ();

9.2 disable using the mongodb command
# Mongod -- shutdown -- config/doiido/mongodb/bin/mongodb. conf

9.3 use the kill command
# Ps-ef | grep mongo
# Kill pid
Note: The kill-9 pid cannot be used here, which may cause data loss and mongodb may report an error.
If you disable mongodb using the kill-9 pid and mongodb cannot be started properly, delete the mongod. lock file:
# Rm-f/doiido/mongodb/data/mongod. lock

#/Doiido/mongodb/bin/mongod -- config/doiido/mongodb/bin/mongodb. conf


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.