This is a creation in Article, where the information may have evolved or changed.
MongoDB Linux Installation
Download
Cd/usr/local/src
wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.4.9.tgz
TAR-XZVF mongodb-linux-i686-2.4.9.tgz
MV mongodb-linux-i686-2.4.9. /mongodb
chmod 755/usr/local/mongodb/bin//-R
ln-s/usr/local/mongodb/bin/mongo/usr/bin/mongo
ln-s/usr/local/mongodb/bin/mongod/usr/bin/mongod
Create a Directory
create some database directory log directories. Running the PID directory
mkdir-p/var/mongodb/data/
mkdir-p/var/mongodb/logs/
chmod +w/var/mongodb/data/-R
chmod +w/var/mongodb/logs/-R
chown-r Mongod:mongod/var/mongodb
mkdir-p/var/run/mongodb
chmod +w/var/run/mongodb-r
chown-r Mongod:mongod/var/run/mongodb
Add user
Groupadd Mongod
Useradd-s/sbin/nologin-d/var/mongodb/-G Mongod Mongod
Write config file
Vi/etc/mongod.conf
# Start MongoDB as a daemon on port 8908 port = 8908fork = true # daemonize It!journal = true #rest = Truelogappend = Tru Eauth = True DBPath =/var/mongodb/data/logpath =/var/mongodb/logs/mongod.logpidfilepath =/var/run/mongodb/mongod.pid
To add a service startup script
Vi/etc/init.d/mongod
#!/bin/bash # mongod - startup script for mongod # chkconfig: 35 85 15# description: mongo is a scalable, document-oriented database.# processname: mongod# config: /etc/mongod.conf# pidfile: /var/ Run/mongo/mongod.pid . /etc/rc.d/init.d/functions # things from mongod.conf get there by mongod reading it # NOTE: if you Change any options here, you get what you pay for:# this script assumes all options are in the config file. Configfile= "/etc/mongod.conf" options= " -f $CONFIGFILE" sysconfig= "/etc/sysconfig/mongod" # fixme: 1.9.x has a --shutdown flag that parses the config File and# shuts down the&nBsp;correct running pid, but that ' S unavailable in 1.8# for now. This can go away when this script stops supporting 1.8.dbpath= ' awk -f= '/^dbpath=/{print $2} ' "$CONFIGFILE" ' pidfile= ' awk -f= '/^ dbpath\s=\s/{print $2} ' "$CONFIGFILE" ' Mongod=${mongod-/usr/bin/mongod} mongo_user=mongodmongo_ group=mongod if [ -f "$SYSCONFIG" ]; then . "$ SYSCONFIG "fi # handle numa access to cpus (SERVER-3574) # this verifies the existence of numactl as well as testing that the command worksnumactl_args= "--interleave=all" if which numactl >/dev/null 2 >/dev/null && numactl $NUMACTL _args ls / >/dev/null 2>/dev /nullthen   Numactl= "numactl $NUMACTL _args" else numactl= "" Fi start () { echo -n $ "starting mongod: " daemon --user "$MONGO _user" $NUMACTL $mongod $OPTIONS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod} stop () { echo -n $ " stopping mongod: " killproc -p " $PIDFILE " -d 300 /usr/bin/mongod RETVAL=$? echo [ $RETVAL  -EQ 0 ] && RM -f /var/lock/subsys/mongod} restart () { stop start} ulimit -n 12000RETVAL=0 case "$" in start) start ;; stop) stop ;; Restart|reload|force-reload) restart ;; condrestart) [ -f /var/lock/subsys/mongod ] && restart | | : ;; status) status $mongod RETVAL=$? ;; *) echo "usage: $0 {start|stop|status|restart|reload| Force-reload|condrestart} " RETVAL=1esac exit $RETVAL
service mongod start //start service
chkconfig mongod on //set boot start