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-i686-1.6.5.tgz under/usr/local/
3. Unzip TAR-ZXVF mongodb-linux-i686-1.6.5.tgz
Rename MV Mongodb-linux-i686-1.6.5.tgz 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 logs
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:1.6.5 connecting to:test > Db.foo.save ({a:1}) > Db.foo.find () {"_id": ObjectId ("4d292a457e289d5d90dc6f33"), "a": 1}
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/log--logappend
8. Connect to the MongoDB client, the following message appears to start successfully./mongodbbin/mongo MongoDB shell version:1.6.5 connecting to:test >
9, script start off MongoDB
# # Start-mongod.shMongodir=/usr/local/mongodbMONGOD=$MONGODIR/bin/mongodMONGO= $MONGODIR/bin/mongodbdir=$ Mongodir/data/dblogpath= $MONGODIR/log/mongodb.log # Mongod would print its PID, so store it in Out.tmp, then # print it using awk to MONGOD.P Id $MONGOD--dbpath $DBDIR--fork--logpath $LOGPATH--logappend > Out.tmpawk "NR = = 2 {print $} ' < out.tmp > mongod.pidsleep 3 $MONGO < on Start.js## in Onstart.jsuse admin;db.runcommand ( "logRotate" ); ## stop-mongod.shkill-15 ' cat $mongod. Pid
MongoDB is installed and configured under Linux