文章14 | 阅读 4985 | 点赞0
redis连接客户端和服务程序在相同目录中,运行redis-cli即可打开客户端
#在/etc/init.d中创建启动配置文件
touch /etc/init.d/redis6379
#编辑启动文件信息
vi redis6379
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
#
#监听端口
REDISPORT=6379
#服务程序地址
EXEC=/redis/redis-3.2.8/src/redis-server
#客户端程序地址
CLIEXEC=/redis/redis-3.2.8/src/redis-cli
#进程PID地址
PIDFILE=/var/run/redis_${REDISPORT}.pid
#redis配置文件地址
CONF="/redis/conf/${REDISPORT}.conf"
case "$1" in
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
;;
*)
echo "Please use start or stop as first argument"
;;
esac
#将脚本文件和/redis配置权限
chmod -R 777 /redis
chmod +x /etc/init.d/redis6379
查看启动项:
chkconfig --list
增加启动项:
chkconfig redis6379 on
删除启动项:
chkconfig --del redis6379
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/Super_RD/article/details/89713996
内容来源于网络,如有侵权,请联系作者删除!