MongoDB is installed under Linux

Source: Internet
Author: User
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   &nbsp 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.