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)