Mongodb 启动关闭脚本并设置…
来源:互联网 发布:杜兰特vs科比数据 编辑:程序博客网 时间:2024/05/22 17:31
配置文件内容:
[root@yoon etc]# cat 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
脚本如下:
[root@yoon~]# cd /etc/init.d/
[root@yooninit.d]# vi mongod
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 80 15
# description: Mongo is a scalable, document-orienteddatabase.
# 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 readingit
if [ $(id -u) != "0" ]; then
echo "Permission Denied!Please use root to run again!"
exit 1
fi
test -d /export/mongodb || (mkdir -p/export/mongodb ; chown mongod:mongod/export/mongodb)
# NOTE: if you change any OPTIONS here, you get what you payfor:
# this script assumes all options are in the configfile.
CONFIGFILE="/export/mongodb/etc/mongod.conf"
SYSCONFIG="/etc/sysconfig/mongod"
export PATH=$PATH:/export/mongodb/bin/
DBPATH=`awk -F= '/^dbpath/{print $2}'"$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 "$1" 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=1
esac
exit $RETVAL
==========================================
[root@yoon~]# service mongod start
[root@yoon~]# service mongod stop
===============================================
设置开机自动启动Mongodb
[root@yoon ~]# chkconfig --add mongod
[root@yoon ~]# chkconfigmongod on
[root@yoon ~]# chkconfig mongod --list
mongod 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@yoon etc]# cat
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
脚本如下:
[root@yoon
[root@yoon
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 80 15
# description: Mongo is a scalable, document-orienteddatabase.
# 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 readingit
if [ $(id -u) != "0" ]; then
fi
test -d /export/mongodb || (mkdir -p
# NOTE: if you change any OPTIONS here, you get what you payfor:
# this script assumes all options are in the configfile.
CONFIGFILE="/export/mongodb/etc/mongod.conf"
SYSCONFIG="/etc/sysconfig/mongod"
export PATH=$PATH:/export/mongodb/bin/
DBPATH=`awk -F= '/^dbpath/{print $2}'"$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() {
}
start()
{
#
#
#
#
#
#
#
daemon --user "$MONGO_USER" "numactl --interleave=all" $mongod$OPTIONS
#
}
stop()
{
}
restart () {
}
ulimit -n 12000
RETVAL=0
case "$1" in
esac
exit $RETVAL
==========================================
[root@yoon~]# service mongod start
[root@yoon~]# service mongod stop
===============================================
设置开机自动启动Mongodb
[root@yoon ~]# chkconfig --add mongod
[root@yoon ~]# chkconfig
[root@yoon ~]# chkconfig mongod --list
mongod
0 0
- Mongodb 启动关闭脚本并设置…
- MySQL 多实例启动和关闭脚本
- Windows下安装-MongoDB-并设置MongoDB随机启动服务~
- Linux启动关闭mongodb
- mongodb启动与关闭
- mongodb启动和关闭
- mongodb---启动、关闭
- MongoDB 启动和关闭
- 设置的crontab脚本无法启动、关闭tomcat解决
- 设置的crontab脚本无法启动、关闭tomcat解决
- Linux 启动脚本 完全注释 1 -- 整…
- tomcat 启动脚本
- MongoDB 自动启动脚本
- mongodb自启动脚本
- MongoDB 自动启动脚本
- MongoDB启动脚本~~
- mongodb 启动脚本
- mongodb,memcached 启动脚本
- 通过keepalived实现 MySQL&nb…
- MySQL在ROW模式下通过binlog提取SQ…
- MySQL显示连接的数据库名
- WARNING: /sys/kernel/mm/tra…
- Android Bitmap太大导致ImageView不显示的问题
- Mongodb 启动关闭脚本并设置…
- Xamarin开发Android之VisualStudio设置
- 分布式日志系统
- 2016年01月07日
- 虚拟机和物理机配互信出现无法连接
- 安装Mongodb3.0.6单实例
- MySQL Online DDL …
- 源码编译安装MySQL 5.7.9
- Query execution was&nb…