Installing Mongodb3.0.6 Single Instance

Source: Internet
Author: User

[[Email protected] ~] #mkdir-P/export/data

[[Email protected] ~] #mkdir-P/export/log

[[email protected] export] #tar-XVF mongodb-linux-x86_64-3.0.6.tgz

[[email protected] export] #mv mongodb-linux-x86_64-3.0.6 MongoDB

[[email protected] log] #touch Mongodb.log

[[email protected] MongoDB] #mkdir etc

[email protected] etc] #touch mongodb.pid

[Email protected] etc]# VI mongod.conf
Logpath=/export/log/mongodb.log
Logappend=true
Fork = True
dbpath=/export/data/db
Pidfilepath =/export/mongodb/etc/mongodb.pid
Rest = True
Httpinterface = True
Port = 27017

[[email protected] export] #numactl--interleave=all/export/mongodb/bin/mongod--config/export/mongodb/etc/ Mongod.conf

To set the MongoDB startup command:
[[email protected] export] #groupadd MongoDB

[[email protected] export] #useradd-M mongodb-g MongoDB

The script is as follows:
[Email protected] ~]# cd/etc/init.d/

[Email protected] init.d]# VI Mongod

#!/bin/bash


# Mongod-startup Script for Mongod


# chkconfig:35 80 15
# Description:mongo is a scalable, document-oriented database.
# Processname:mongod
#config:/export/mongodb/etc/mongod.conf
# Pidfile:/export/mongodb/etc/mongodb.pid


Source/etc/rc.d/init.d/functions


# things from mongod.conf get there by Mongod reading it


If [$ (id-u)! = "0"]; Then
echo "Permission denied! Use the ROOT to run again! "
Exit 1
Fi


test-d/export/mongodb | | (Mkdir-p/export/mongodb; Chown mongod:mongod/export/mongodb)


# note:if You the change any OPTIONS here and you get the "What do pay for:
# This script assumes all options is in the config file.
Configfile= "/export/mongodb/etc/mongod.conf"
Sysconfig= "/etc/sysconfig/mongod"


Export path= $PATH:/export/mongodb/bin/


Dbpath= ' awk-f= '/^dbpath/{print ' "$CONFIGFILE"
options= "--config $CONFIGFILE"
Mongod=${mongod-/export/mongodb/bin/mongod}
echo "DB path is:" $DBPATH
Echo $mongod
Mongo_user=mongodb
Mongo_group=mongodb


[-F "$SYSCONFIG"] && source "$SYSCONFIG"


Super () {
su-$MONGO _user-c "path= $PATH:/export/mongodb/bin/; $*"
}


Start ()
{
Echo-n $ "Starting Mongod:"
# echo-n "$MONGO _user" "Numactl--interleave=all"
# daemon--user "$MONGO _user" "Numactl--interleave=all" $mongod $OPTIONS
# daemon--user "$MONGO _user" $mongod $OPTIONS
#
# su-$MONGO _user-c "$mongod $OPTIONS"-m-p
# su-$MONGO _user
# $mongod $OPTIONS
Daemon--user "$MONGO _user" "Numactl--interleave=all" $mongod $OPTIONS
# Super $mongod $OPTIONS
Echo $mongod $options
Retval=$?
Echo
[$RETVAL-eq 0] && Touch/var/lock/subsys/mongod
}


Stop ()
{
Echo-n $ "Stopping Mongod:"
Killproc-p "$DBPATH"/mongod.lock-d 300/export/mongodb/bin/mongod
Retval=$?
Echo
[$RETVAL-eq 0] && rm-f/var/lock/subsys/mongod
}


Restart () {
Stop
Start
}


Ulimit-n 12000
Retval=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: $ {Start|stop|status|restart|reload|force-reload|condrestart}"
Retval=1
Esac


Exit $RETVAL

==========================================
[[Email protected] ~]# service Mongod start

[[Email protected] ~]# service Mongod stop

===============================================
Set Boot auto Start MongoDB
[Email protected] ~]# chkconfig--add Mongod

[Email protected] ~]# chkconfig Mongod on

[Email protected] ~]# chkconfig mongod--list
Mongod 0:off1:off2:on3:on4:on5:on6:off

Installing Mongodb3.0.6 Single Instance

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.