centos7安装redis-5.0.7.tar.gz

Centos7安装Redis5_kangswx的博客-CSDN博客关闭防火墙systemctl stop firewalld安装wgetyum -y install wget下载安装包wget http://download.redis.io/releases/redis-5.0.3.tar.gz解压安装包tar -zxvf redis-5.0.3.tar.gz进入解压后的redis目录cd redis-5.0.3...https://blog.csdn.net/kangswx/article/details/90439798设置开机自启

拷贝utils目录下的redis_init_script到/etc/init.d目录下

        cp ./redis_init_script /etc/init.d/redis

 编辑/etc/init.d/目录下复制过来的redis文件,需要添加的内容

我的整个配置文件内容

#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

# chkconfig: 2345 10 90  
# description: Start and Stop redis 

### BEGIN INIT INFO
# Provides:     redis_6379
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Redis data structure server
# Description:          Redis data structure server. See https://redis.io
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/bin:/root/bin

REDISPORT=6379
EXEC=/app/redis-5.0.7/redis/redis-server
CLIEXEC=/app/redis-5.0.7/redis/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/app/redis-5.0.7/redis/redis.conf"
AUTH="1234"
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
 

保存,退出

给编辑好的配置文件设置权限

        chmod 755 redis

测试一下是否能够通过该配置文件启动成功

        /etc/init.d/redis start

启动成功

设置开机自启动

        chkconfig redis on

reboot重启虚拟机,在可执行文件下使用redis-cli客户端命令测试连接成功

 

遇到的问题

持续更新中...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值