Cent OS 7 Linux 安装 redis redis-3.2.0.tar.gz

bash-4.2$ su
密码:
[root@dbserver latte]# mkdir /usr/local/redis
[root@dbserver latte]# cd /usr/local/src
[root@dbserver src]# wget http://download.redis.io/releases/redis-3.2.0.tar.gz
--2016-05-19 07:39:57--  http://download.redis.io/releases/redis-3.2.0.tar.gz
正在解析主机 download.redis.io (download.redis.io)... 109.74.203.151
正在连接 download.redis.io (download.redis.io)|109.74.203.151|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1525900 (1.5M) [application/x-gzip]
正在保存至: “redis-3.2.0.tar.gz”

100%[=====================================================================>] 1,525,900    219KB/s 用时 6.8s  

2016-05-19 07:40:05 (219 KB/s) - 已保存 “redis-3.2.0.tar.gz” [1525900/1525900])

[root@dbserver src]# ls
redis-3.2.0.tar.gz
[root@dbserver src]# tar xzf redis-3.2.0.tar.gz
[root@dbserver src]# ln -s redis-3.2.0 redis
[root@dbserver src]# cd redis
[root@dbserver redis]# make PREFIX=/usr/local/redis install
[root@dbserver redis]# cd /usr/local/bin
[root@dbserver bin]# ls
redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli  redis-sentinel  redis-server
[root@dbserver bin]# cp /usr/local/src/redis/utils/redis_init_script /etc/rc.d/init.d/redis
[root@dbserver bin]# chkconfig --add redis
服务 redis 不支持 chkconfig
[root@dbserver bin]# vim /etc/rc.d/init.d/redis
#!/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
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli

#PIDFILE=/var/run/redis_${REDISPORT}.pid
PIDFILE=/var/run/redis.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 -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
[root@dbserver bin]# mkdir /etc/redis
[root@dbserver bin]# cp /usr/local/src/redis/redis.conf  /etc/redis/6379.conf
[root@dbserver bin]# chkconfig --add redis
[root@dbserver bin]# chkconfig --list

注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
      如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
      欲查看对特定 target 启用的服务请执行
      'systemctl list-dependencies [target]'。

jexec           0:关    1:开    2:开    3:开    4:开    5:开    6:关
mysql           0:关    1:关    2:开    3:开    4:开    5:开    6:关
netconsole      0:关    1:关    2:关    3:关    4:关    5:关    6:关
network         0:关    1:关    2:开    3:开    4:开    5:开    6:关
redis           0:关    1:关    2:开    3:开    4:开    5:开    6:关
redis_6379      0:关    1:关    2:开    3:开    4:开    5:开    6:关

[root@dbserver bin]# chkconfig redis_6379 off
[root@dbserver bin]# service redis start
[root@dbserver bin]# PATH="$PATH:/usr/local/redis/bin"
[root@dbserver bin]# echo $PATH
[root@dbserver bin]# redis-server
[root@dbserver bin]# ps -ef|grep redis
root     10804  5373  0 08:17 pts/1    00:00:00 redis-server *:6379
root     10906     1  0 08:20 pts/1    00:00:00 /usr/local/redis/bin/redis-server 127.0.0.1:6379
root     10932  5373  0 08:21 pts/1    00:00:00 grep --color=auto redis
[root@dbserver bin]# redis-cli
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379>

猜你喜欢

转载自xiongjiajia.iteye.com/blog/2299180