标签:done oca 配置 mod 用户 crash image mic 调用
环境:多实例环境,需指定端口进行启停服务
编写脚本:
#!bin/sh
#调用函数功能
#这是redis的启动、停止、重启脚本
REDISPORT=$1
#redis的pid
EXEC=/usr/local/redis4/bin/redis-server
CONF="/etc/redis/${REDISPORT}.conf"
CLIEXEC=/usr/local/redis4/bin/redis-cli
#redis的PID文件位置,需要修改
PIDFILE=/var/run/redis_${REDISPORT}.pid
#redis的配置文件位置,需将${REDISPORT}修改为文件名
start(){
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
}
stop(){
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
}
restart(){
stop
start
if [ $? = 0 ];then
echo "重启成功....."
fi
}
case "$2" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "使用方法:sh 脚本名 端口 参数 {start|stop|start}"
esac
根据启动脚本,将修改好的配置文件复制到指定目录下,用root用户进行操作:
mkdir
/etc/redis
cp
redis_6379.conf
/etc/redis/6379
.conf
将启动脚本复制到/etc/init.d目录下,本例将启动脚本命名为redisd
赋权:chmod 755 redisd
使用:
service redisd 6379 restart
标签:done oca 配置 mod 用户 crash image mic 调用
原文地址:https://www.cnblogs.com/any-way/p/11599634.html