Linux Redis自动启动,Redis开机启动,Linux Redis设置开机启动

21 篇文章 0 订阅
13 篇文章 0 订阅

Linux Redis自动启动,Redis开机启动,Linux Redis设置开机启动

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

©Copyright 蕃薯耀 2017年7月21日

http://fanshuyao.iteye.com/

 

Linux Redis安装,Linux如何安装Redis见:

http://fanshuyao.iteye.com/blog/2386231

 

一、新建、编写开机自启动脚本(redis-auto为新建的文件)

vi /etc/init.d/redis-auto

 

二、在文件redis-auto加入如下内容:(注意Redis具体的安装路径,你的可能不一样)

2017-07-26修正参数名不一致的问题。

#!/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
REDISPATH=/home/java/run/redis-3.2.9/bin
EXEC=${REDISPATH}/redis-server
CLIEXEC=${REDISPATH}/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="${REDISPATH}/redis.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

 

三、保存退出

:wq

四、设置文件redis-auto的权限,让Linux可以执行

cd /etc/init.d/

chmod 755 redis-auto

 

五、启动Redis服务测试,此处启动用的是第二步设置的启动脚本

/etc/init.d/redis-auto start

 如果看到Redis启动的小盒子就表示成功。

不过你可以进一步打开redis-cli客户端进行测试

 

六、设置开机自启动,即:

chkconfig redis-auto on

 

七、经过测试,Linux系统在重新启动时,Redis的数据会自动丢失,解决方案见:

 

Linux Redis 重启数据丢失解决方案,Linux重启后Redis数据丢失解决方案

http://fanshuyao.iteye.com/blog/2386429

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

©Copyright 蕃薯耀 2017年7月21日

http://fanshuyao.iteye.com/

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值