Posted at

MongoDBの自動起動設定

More than 1 year has passed since last update.


起動・停止スクリプト

vi /etc/init.d/mongodb

#!/bin/bash

#
# chkconfig: 2345 99 14
# description: mongodb.

CONFIG_PATH="/etc/mongodb/conf/mongodb.conf"
PIDFILE_PATH="/var/run/mongodb"
TYPE="MongoDB of Shard"

case "$1" in
start)
echo "$TYPE Start"
mkdir -p $PIDFILE_PATH
/usr/bin/mongod -f $CONFIG_PATH
;;
stop)
echo "$TYPE Stop"
/usr/bin/mongod --shutdown -f $CONFIG_PATH
;;
restart)
echo "$TYPE Restart"
/usr/bin/mongod --shutdown -f $CONFIG_PATH
/usr/bin/mongod -f $CONFIG_PATH
;;

*)
echo $"Usage: HOGE {start|stop|restart}"
esac


自動起動設定

chmod u+x /etc/init.d/mongodb

chkconfig --add /etc/init.d/mongodb
chkconfig mongodb on