欢迎阅读!

潇湘夜雨

当前位置: 主页 > 数据库 >

sentinel开机启动脚本

时间:2017-05-16 20:01来源:潇湘夜雨 作者:华嵩阳 点击:
1、编写sentinel的启动脚本 [root@master ~]# vim /etc/init.d/sentinel #!/bin/sh # # redis start up the redis server daemon # # chkconfig: 345 98 98 # description: redis service in /etc/init.d/redis # chkconfig --add redis or chkconfig
 
1、编写sentinel的启动脚本
[root@master ~]# vim /etc/init.d/sentinel
 
#!/bin/sh
#
# redis start up the redis server daemon
#
# chkconfig: 345 98 98
# description: redis service in /etc/init.d/redis 
#            chkconfig --add redis or chkconfig --list redis 
#            service redis start  or  service redis stop
# processname: redis-sentinel
# config: /etc/redis.conf
# 注意不同位置要修改变量
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=26379
EXEC=/usr/local/redis/bin/redis-sentinel
REDIS_CLI=/usr/local/redis/bin/redis-cli
 
PIDFILE=/var/run/sentinel.pid #修改pid文件名
CONF="/usr/local/redis/sentinel.conf" #修改配置文件名
 
case "$1" in
status)
ps -ef|grep redis|grep  26379
;;
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
if [ "$?"="0" ]
then
 echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
while [ -x ${PIDFILE} ]
 do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
 restart|force-reload)
${0} stop
${0} start
;;
 *)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2
exit 1
 
esac
 
2、添加到系统服务
[root@localhost ~]# chkconfig --add sentinel
 
[root@localhost ~]#  ll /etc/rc.d/rc3.d/ |grep sentinel # 查看本级下所有服务的启动顺序;
lrwxrwxrwx  1 root root 18 5月  16 16:32 S98sentinel -> ../init.d/sentinel
 
$ ln -s /etc/rc.d/init.d/apache /etc/rc.d/rc3.d/S60apache   
  S  是start的简写、代表启动;
  K  是kill的简写、代表关闭;
  98 数字代表启动的顺序。60以后通常是比较保险的数字,因为别的服务都启动了;
 
(责任编辑:liangzh)
织梦二维码生成器
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
推荐内容