MongoDB startup script

Source: Internet
Author: User
Tags mongodb server

[Email protected] local]# Cat/etc/init.d/mongod

#!/bin/sh

# # chkconfig:2345 65 38

Source/etc/profile

Config=/usr/local/mongodb/mongod.cnf

Program=/usr/local/mongodb/bin/mongod

Mongopid= ' Ps-ef | grep ' Mongod--config ' | Grep-v grep | awk ' {print $} '

Test-x $PROGRAM | | Exit 0

Case "$" in

Start

echo "Starting MongoDB Server ..."

$PROGRAM--config $CONFIG &

;;

Stop

echo "Stopping MongoDB Server ..."

if [!-Z "$MONGOPID"]; Then

Kill-15 $MONGOPID

Fi

;;

Status

If [-Z "$MONGOPID"]; Then

echo "MongoDB is not running!"

Else

echo "MongoDB is running! ("$MONGOPID") "

Fi

;;

Restart

echo "shutting down MongoDB Server ..."

if [!-Z "$MONGOPID"]; Then

Kill-15 $MONGOPID

Fi

echo "Starting MongoDB ..."

$PROGRAM--config $CONFIG &

;;

*)

Log_success_msg "Usage:/etc/init.d/mongod {Start|stop|status|restart}"

Exit 1

Esac

Exit 0


MongoDB configuration file:

[Email protected] local]# CAT/USR/LOCAL/MONGODB/MONGOD.CNF

Logpath=/usr/local/mongodb/logs/log

Logappend = True

#fork and run in background

Fork = True

#port = 27017

Dbpath=/usr/local/mongodb/data

#location of Pidfile

Pidfilepath=/usr/local/mongodb/mongod.pid

Auth = True


This article is from the "10931853" blog, please be sure to keep this source http://wujianwei.blog.51cto.com/10931853/1962577

MongoDB startup script

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.