centos下为redis添加service
来源:互联网 发布:共享文件夹监控软件 编辑:程序博客网 时间:2024/06/04 23:24
为了方便地重启redis服务 以下为配置service快速启动或停止redis服务的步骤
第一步:首先 进入redis安装目录中的utils中
第二步:将其中的redis_init_script文件复制到/etc/init.d下
第三步:进入/etc/init.d 将redis_init_script更名为redis
第四步:命令:mv redis_init_script redis
第五步:编辑redis
vim /etc/init.d/redis
进入后编辑这些为你的redis安装目录
修改后的如下
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/var/www/redis-stable/src/redis-server
CLIEXEC=/var/www/redis-stable/src/redis-cli
PIDFILE=/var/redis/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${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 -a "root" -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -a "root" -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Restarting Redis server..."
done
$EXEC $CONF
PIDFILE=/var/redis/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${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 -a "root" -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -a "root" -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Restarting Redis server..."
done
$EXEC $CONF
echo "Redis restart success!"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
结束:这样就可以在用service redis stop、service redis start对redis进行快速启动停止了。
- centos下为redis添加service
- windows下为redis添加实例
- centos 下为PHP添加svn扩展
- centos 下为php添加mongodb扩展
- centos下为php添加gd扩展
- centos下为php添加pdo_mysql扩展
- centos 7.2 下为erlang添加protobuffs
- centos下安装redis并且注册为服务
- 在Linux下为PHP添加nosql--redis扩展模块
- CentOS下为xxx用户添加sudo 权限
- CentOS下安装redis
- CentOS下安装Redis
- centos下安装redis
- centos下安装redis
- centos下安装redis
- CentOS 下安装 Redis
- centos下安装redis
- centos下redis安装
- 在JAVAWeb开发中遇到的问题汇总
- Android6.0通讯录权限问题
- 块状数组+归并树学习 poj2104+hdu2665
- Python获取系统音量
- VARIANT、COleVariant 和_variant_t
- centos下为redis添加service
- 网站敏感词过滤的实现(附敏感词库)
- 转载:彻底解决 error: Unable to find vcvarsall.bat
- Error:com.android.builder.internal.aapt.AaptException: Failed to crunch file D:\my\Android-VideoStre
- Redis常用数据类型介绍、使用场景及其操作命令
- Qt5+mysql windows
- emWin 2天速成实例教程012_基于STM32单片机的全键盘中文汉字拼音输入法
- es6 map,set与数组和对象的比较(十)
- error LNK2026: 模块对于 SAFESEH 映像是不安全的