Install MongoDB in Linux and set auto-start.
1. Download mongodb linux version (note the difference between 32-bit and 64-bit),: http://www.mongodb.org/downloads
2.place the downloaded mongodbinstallation file mongodb-linux-x86_64-2.6.7.gz to/usr/local /.
3. Decompress tar-zxvf mongodb-linux-x86_64-2.6.7.gz
Rename music mongodb-linux-x86_64-2.6.7.gz mongodb
4. Create a database file directory. The default value is/data/db. I put the database file directory under the current folder, mkdir-p data/db, create log directory mkdir-p data/log create log store file cd data/log/
Touch mongodb. log
5. Start the service
Cd/usr/local/mongodb/bin
./Mongod -- dbpath = ../data/db -- logpath = ../log/mongodb. log
6. Start the client shell test.
[Root @ localhost bin] #./mongo
MongoDB shell version: 2.6.7
Connecting to: test
7. Add the mongoDB service to the random start
Vi/etc/rc. local
Use the vi editor to open the configuration file and add the following line of code
/Usr/local/mongodb/bin/mongod -- dbpath =/usr/local/mongodb/data/db -- port 27017 -- logpath =/usr/local/mongodb/data/log/ mongodb. log -- fork -- smallfiles -- logappend &
8. Connect to the mongoDB client. If the following information is displayed, the startup is successful.
./Mongodb/bin/mongo
MongoDB shell version: 2.6.7
Connecting to: test
9. Shut down mongodb at script startup
# Start-mongod.sh
/Usr/apps/mongodb/bin/mongod -- dbpath =/usr/apps/mongodb/data/db -- port 27017 -- logpath =/usr/apps/mongodb/data/log/ mongodb. log -- fork -- smallfiles -- logappend &
Put the written script (start-mongod.sh file) under the/etc/profile. d/directory, the system will automatically execute all shell scripts under the directory after the system starts