Cent OS 7 Linux 安装 redis redis-3.2.0.tar.gz
bash-4.2$ su
密码:
[[email protected] latte]# mkdir /usr/local/redis
[[email protected] latte]# cd /usr/local/src
[[email protected] 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])
[[email protected] src]# ls
redis-3.2.0.tar.gz
[[email protected] src]# tar xzf redis-3.2.0.tar.gz
[[email protected] src]# ln -s redis-3.2.0 redis
[[email protected] src]# cd redis
[[email protected] redis]# make PREFIX=/usr/local/redis install
[[email protected] redis]# cd /usr/local/bin
[[email protected] bin]# ls
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
[[email protected] bin]# cp /usr/local/src/redis/utils/redis_init_script /etc/rc.d/init.d/redis
[[email protected] bin]# chkconfig --add redis
服务 redis 不支持 chkconfig
[[email protected] 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
[[email protected] bin]# mkdir /etc/redis
[[email protected] bin]# cp /usr/local/src/redis/redis.conf /etc/redis/6379.conf
[[email protected] bin]# chkconfig --add redis
[[email protected] 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:关
[[email protected] bin]# chkconfig redis_6379 off
[[email protected] bin]# service redis start
[[email protected] bin]# PATH="$PATH:/usr/local/redis/bin"
[[email protected] bin]# echo $PATH
[[email protected] bin]# redis-server
[[email protected] 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
[[email protected] 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>