1. Download the Linux version of MongoDB (note the difference between 32-bit and 64-bit): http://www.mongodb.org/downloads
2. Place the downloaded MongoDB installation file mongodb-linux-x86_64-2.6.7.gz under/usr/local/
3. Unzip TAR-ZXVF mongodb-linux-x86_64-2.6.7.gz
Rename MV mongodb-linux-x86_64-2.6.7.gz MongoDB
4, create the database file directory, the default is/data/db, I put the database file directory under the current folder, Mkdir-p data/db, create log directory mkdir data/log create log file Touch Data/log/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
[Email protected] bin]#./mongo
MongoDB Shell version:2.6.7
Connecting To:test
7. Add MongoDB service to random start
Vi/etc/rc.local
Use the VI Editor to open the configuration file and add the following line of code to it
/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, the following message is started successfully
./mongodb/bin/mongo
MongoDB Shell version:2.6.7
Connecting To:test
9, script start off MongoDB
# # 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) into the directory/etc/profile.d/, and the system will automatically execute all shell scripts in that directory when it is started.
Installing MongoDB under Linux and setting up self-booting