CentOS6.8使用yum安装有时候没有比较新的版本,所以手动安装,下面记录一下步骤。
下载最新版本
以3.2.8为例,附上地址:redis-3.2.8.tar.gzhttp://download.redis.io/releases/redis-3.2.8.tar.gz
1、 下载Redis3.2.8安装包
wget -C http://download.redis.io/releases/redis-3.2.8.tar.gz
2、解压、编译、安装redis-3.2.8
tar -zxvf redis-3.2.8.tar.gz -C /usr/src/ cd /usr/src/redis-3.2.8/ make && make install
3、创建redis相关目录:
mkdir -p /home/redis/bin mkdir -p /home/redis/log mkdir -p /home/redis/pid mkdir -p /home/redis/db
4、将可执行文件复制到自己的安装目录:/home/redis/
ln -s /usr/local/bin/redis-* /home/redis/bin/
5、复制配置文件到自己的安装目录:/home/redis/
cp /usr/src/redis-3.2.8/redis.conf /home/redis/
6、进入自己的安装目录,编辑redis.conf配置文件
cd /home/redis/ vim /home/redis/redis.conf
# bind 127.0.0.1
protected-mode no
daemonize yes
pidfile /home/redis/pid/redis.pid logfile /home/redis/log/redis.log dir /home/redis/db其他配置就默认即可,有需要再自行修改.
7、创建redis服务启动脚本,并赋予权限
vim /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. PATH=/home/redis/bin:/sbin:/usr/bin:/bin REDISPORT=6379 EXEC=/home/redis/bin/redis-server CLIEXEC=/home/redis/bin/redis-cli PIDFILE=/home/redis/pid/redis.pid CONF="/home/redis/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
8、设置权限,添加redis服务开机启动:
chmod a+x /etc/init.d/redis
9、启动redis服务:
service redis start ps -ef | grep redis netstat -anptu | grep 6379
10、测试OK
redis-cli set key1 hello get key1 quit
(防火墙启用6379端口:
iptables -A INPUT -p tcp --dport 6379 -j ACCEPT)
http://www.cnblogs.com/jimmy-lin/p/6426925.html
http://www.cnblogs.com/ahjx1628/p/6496529.html
原文链接:https://www.f2er.com/centos/376636.html