#!/bin/sh
#chkconfig: 2345 80 90?
# Simple Redis init.d script conceived to work on Linux systems?
# as it does use of the /proc filesystem.?
REDISPORT=6379? ? ? ? ? ? ? ? ? ? ? ? ? #端口號(hào)嵌削,這是默認(rèn)的乘客,如果你安裝的時(shí)候不是默認(rèn)端口號(hào)篱昔,則需要修改
REDISPATH=/usr/local/redis/bin? ? ? ? ? ? ? ? #redis-server啟動(dòng)腳本的所在目錄,你如果忘了可以用find / -name redis-server 或whereis redis-server找到
EXEC=${REDISPATH}/redis-server? ? ? ? ? ?
CLIEXEC=${REDISPATH}/redis-cli?
PIDFILE=/var/run/redis_${REDISPORT}.pid? #在redis.conf中可找到該路徑
CONF="/usr/local/redis/etc/redis.conf"? ? ? ? ? #redis.conf的位置, 如果不和redis-server在同一目錄要修改成你的redis.conf所在目錄
SlCONF="/usr/local/redis/etc/sentinel.conf --sentinel"
case "$1" in?
? start)?
? ? if [ -f $PIDFILE ]?
? ? then?
? ? ? ? echo "$PIDFILE exists, process is already running or crashed"?
? ? else?
? ? ? ? echo "Starting Redis server..."?
? ? ? ? $EXEC $CONF;?
$EXEC $SlCONF
? ? fi?
? ? ;;?
? stop)?
? ? if [ ! -f $PIDFILE ]?
? ? then?
? ? ? ? echo "$PIDFILE does not exist, process is not running"?
? ? else?
? ? ? ? PID=$(cat $PIDFILE)?
? ? ? ? echo "Stopping ..."?
? ? ? ? $CLIEXEC -a '123456' -p $REDISPORT shutdown?
? ? ? ? while [ -x /proc/${PID} ]?
? ? ? ? do?
? ? ? ? ? echo "Waiting for Redis to shutdown ..."?
? ? ? ? ? sleep 1?
? ? ? ? done?
? ? ? ? echo "Redis stopped"?
? ? fi?
? ? ;;?
? *)?
? ? echo "Please use start or stop as first argument"?
? ? ;;?
esac
注意:更新完腳本后要執(zhí)行:systemctl daemon-reload劫灶,不然不生效