Install mongodb 2.6.5 under CentOS 6.5
Mongo DB is a very popular non-relational database (NoSql) in the IT industry, and its flexible data storage method is favored by current IT employees. Mongo DB implements the object-oriented idea very well. In Mongo DB, each record is a Document object. The biggest advantage of Mongo DB is that all data persistence operations do not need developers to write SQL statements manually, and you can easily implement CRUD operations by calling methods directly. Here's how to install mongodb:
1. Check whether mongodb has been installed, and if so, 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# mv mongodb-linux-x86_64-2.6.5 / doiido/mongodb
4. Set up the storage directory of database and log
# mkdir / doiido/mongodb/data# mkdir / doiido/mongodb/logs# touch / doiido/mongodb/logs/mongodb.log
5. Establish a configuration file
# vi / doiido/mongodb/bin/mongodb.confdbpath=/doiido/mongodb/datalogpath=/doiido/mongodb/logs/mongodb.logport=27017fork=truenohttpinterface=true
6. Start mongodb
# / doiido/mongodb/bin/mongod-- bind_ip localhost-f / doiido/mongodb/bin/mongodb.conf
7. Set up boot boot
# echo "/ doiido/mongodb/bin/mongod-- config / doiido/mongodb/bin/mongodb.conf" > > / etc/rc.local
8. Testing
8.1. Enter shell mode of mongodb
# / doiido/mongodb/bin/mongo
8.2. View the list of databases
> show dbs
8.3. Current db version
> db.version ()
9. Stop mongodb
9.1. Enter mongodb and close
# / doiido/mongodb/bin/mongo > db.shutdownServer ()
9.2. Use the mongodb instruction to close
# mongod-shutdown-config / doiido/mongodb/bin/mongodb.conf
9.3. Use the kill instruction
# ps-ef | grep mongo# kill pid
Note: kill-9 pid cannot be used in this place, which will result in data loss and mongodb may report an error.
If you shut down mongodb using kill-9 pid and mongodb does not start properly, delete the mongod.lock file:
# rm-f / doiido/mongodb/data/mongod.lock# / doiido/mongodb/bin/mongod-- config / doiido/mongodb/bin/mongodb.conf