Mongodb 启动关闭脚本并设置开机自动启动Mongodb
配置文件内容:
[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@yoon 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! 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 pay for:
# this script assumes all options are 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 $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 ~]# chkconfig mongod on
[root@yoon ~]# chkconfig mongod --list
mongod 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Mongodb 启动关闭脚本并设置开机自动启动Mongodb的更多相关文章
- Linux Redis自动启动,Redis开机启动,Linux Redis设置开机启动
Linux Redis自动启动,Redis开机启动,Linux Redis设置开机启动 >>>>>>>>>>>>>> ...
- CentOS 7.6 RPM 方式安装Oracle19c 后 使用 systemd 的方式设置开机自动启动Oracle数据库
1. 方法简介: 使用systemd 来进行 oracle数据库的启动和关闭操作. 使用的脚本为 lsnrctl和dbstart 2. 修改事项. 需要先修改一下 oracle 的启动脚本配置: vi ...
- CentOS设置开机自动启动某服务
CentOS设置开机自动启动某服务 这里以启动sshd服务为例: 查看sshd是否已经是系统服务: # chkconfig --list |grep sshd 会显示: sshd ...
- centos下安装memcached并设置开机自动启动-两种方法
方法一: 安装memcachedyum install memcached 启动服务并初始化service memcached start -p 11211 -l 127.0.0.1 -d 设置mem ...
- VMware ESXi 6.7服务器设置开机自动启动虚拟机
VMware ESXi 6.7服务器设置开机自动启动虚拟机,具体操作步骤如下 1.登陆到VMware ESXi 6.7 web 界面 2.导航器-->主机-->管理 将自动启动修改为 ...
- linux系统下查看svn服务是否启动,重启及设置开机重启
Linux系统中svn服务是否启动,重启及设置开机启动 安装完svn服务器后虽然好用但是因为经常重启Linux服务器,每次重启完就要去手动启动svn服务器,很是麻烦,于是在网上找了一些方法后,自己 ...
- linux可运行的shell脚本与设置开机服务启动(自己总结)
完整的ln命令参考:http://www.runoob.com/linux/linux-comm-ln.html ln :创建连接文件 - 默认创建的是硬连接,好比复制 ,但是两个文件会同步 命令:l ...
- 原 Debian设置开机自动启动与关闭
发表于1年前(2013-01-08 13:01) 阅读(2380) | 评论(0) 2人收藏此文章, 我要收藏 赞0 开机自动启动 update-rc.d chkconfig 熟悉debian系统 ...
- [转] ubuntu16.04添加系统 service, 并设置开机自动启动
转:https://www.jianshu.com/p/1958878646bd 1. 创建pfly.service文件 2. 执行 systemctl daemon-reload 3. 执行 sy ...
随机推荐
- 服务端Linux机器日志查看命令
常用查看命令 ps -ef | grep java 查看当前机器运行程序: tail -100f /... 查看日志,实时的 less /- 按页查看日志,空格翻页,q退出 cat /.. | gre ...
- 优动漫PAINT核心功能介绍
优动漫PAINT是一款功能强大的动漫绘图软件,适用于个人和专业团队创作,分为个人版和EX版.搭载了绘制漫画和插画所需的所有功能——丰富的笔工具.超强的笔压感应和手颤修正功能,可分别满足画师对于插画.漫 ...
- Linux终端 Tab 补全命令
1. vi编辑器打开 /etc/bash.bashrc文件 vi /etc/bash.bashrc 2.找到文件中的下列代码 3.将注释符号#去掉,即改成 4.最后 source一下 /etc/bas ...
- UWP添加数字证书导出安装包本地安装
先生成一个简单的HelloWorld应用程序 <Page x:Class="HelloWorld.MainPage" xmlns="http://schemas.m ...
- JQuery课堂学习笔记
第1课 JQuery技术简介 <%@ page language="java" import="java.util.*" pageEncoding=&qu ...
- [1] first day
一.几个工具包 [1]pandas(数据分析工具) https://zhuanlan.zhihu.com/p/33230331 https://zhuanlan.zhihu.com/p/2501351 ...
- 51nod-活动安排问题之二
有若干个活动,第i个开始时间和结束时间是[Si,fi),活动之间不能交叠,要把活动都安排完,至少需要几个教室? 分析:能否按照之一问题的解法,每个教室安排尽可能多的活动,即按结束时间排序,再贪心选择不 ...
- Dict字典的操作
字典的操作 1.字典新增键值对 已存在内容的字典新增 alient_0 = {"color":"green",position:10} alient_0[&qu ...
- ExtJs之Ext.Template
<!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv ...
- POJ 2470 Ambiguous permutations(简单题 理解题意)
[题目简述]:事实上就是依据题目描写叙述:A permutation of the integers 1 to n is an ordering of these integers. So the n ...