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