安装redis




[root@gaojingbo ~]# wget http://download.redis.io/releases/redis-4.0.11.tar.gz

[root@gaojingbo ~]#  tar xzf redis-4.0.11.tar.gz
[root@gaojingbo ~]# cd redis-4.0.11

[root@gaojingbo redis-4.0.11]# make


[root@gaojingbo redis-4.0.11]# echo $?
0
启动服务
[root@gaojingbo redis-4.0.11]# ./src/redis-server &


[root@gaojingbo redis-4.0.11]# ./src/redis-cli
127.0.0.1:6379> 
设置服务启动脚本
[root@gaojingbo redis-4.0.11]# cd src/
[root@gaojingbo src]# vim /etc/init.d/redis
#!/bin/sh
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_6379.pid
[ $3 ] && IPH=$3 || IPH=`awk '/^bind [0-9].*/{print $2}' /etc/redis/6379.conf`
[ $2 ] && REDISPORT=$2 || REDISPORT=`awk '/^port [0-9]{4,8}/{print $2}' /etc/redis/6379.conf`
CONF="/etc/redis/6379.conf"
REDISPORT=${REDISPORT:-6379}
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 -h $IPH shutdown
            rm -rf $PIDFILE
            while [ -x /proc/${PID} ]
            do
                echo "Waiting for Redis to shutdown ..."
                sleep 1
            done
            echo "Redis stopped"
        fi ;;
    status)
        PID=$(cat $PIDFILE)
        if [ ! ${PID} ]
        then
            echo 'Redis is not running'
        else
            echo "Redis is running ($PID)"
        fi;;
    restart)
        $0 stop
        $0 start ;;
    *)
        echo "Please use start, stop, restart or status as first argument";;
esac 
[root@gaojingbo src]# chmod +x /etc/init.d/redis
[root@gaojingbo src]# mkdir -p /etc/redis
[root@gaojingbo src]# cp /root/redis-4.0.11/redis.conf /etc/redis/6379.conf
[root@gaojingbo src]# chkconfig --add redis
[root@gaojingbo src]# chkconfig  redis on
[root@gaojingbo src]# systemctl restart redis
[root@gaojingbo src]# systemctl status redis
● redis.service - LSB: start and stop redis_6379
   Loaded: loaded (/etc/rc.d/init.d/redis; bad; vendor preset: disabled)
   Active: active (exited) since Tue 2018-09-11 21:01:08 CST; 7s ago
     Docs: man:systemd-sysv-generator(8)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值