Join the 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--fork--port 27017--logpath=/usr/local/mongodb/log/work.log--logappend--auth start service/usr/local/ mongodb/bin/mongod-dbpath=/usr/local/mongodb/data/db--fork--port 27017--logpath=/usr/local/mongodb/log/work.log --logappend--auth Other: MongoDB installed and configured under Linux I use Rehl 6 as its operating carrier. 1. Download the Linux version of MongoDB (note the difference between 32-bit and 64-bit): http://www.mongodb.org/ Downloads2. mongodb-linux-i686-1.6.5.tgz the downloaded MongoDB installation file to/usr/local/3. Unzip TAR-ZXVF mongodb-linux-i686-1.6.5.tgz Rename MV mongodb-linux-i686-1.6.5.tgz mongodb4, create database file directory, default to/data/db, I put the database file directory under the current folder, Mkdir-p data/db, Create log directory mkdir log5. Start the service cd/usr/local/mongodb/bin./mongod-dbpath=: /data/db-logpath=. /log/mongodb.log6, start the client shell test [[email protected] bin]#./mongomongodb Shell version:1.6.5connecting 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--logappend8. Connect to the MongoDB client, the following message appears to start successfully./mongodbbin/mongomongodb Shell Version:1.6.5connecting 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 it S-PID, so-store it in Out.tmp, then# print it using awk to Mongod.pid$mongod--dbpath $DBDIR--fork--logpath $LOGPATH--l Ogappend > Out.tmpawk ' NR = = 2 {print $} ' < out.tmp > Mongod.pidsleep 3$mongo < onstart.js## in ONSTART.JSU Se admin;db.runcommand ("logRotate");
Add MongoDB service to random startup