另附上csdn上该版本的资源:
http://download.csdn.net/detail/wantianwen/6677973
使用root安装
su
将该下载包拷贝到/opt
cp redis-2.6.14.tar.gz /opt
cd /opt
tar zxvf redis-2.6.14.tar.gz
cd redis-2.6.14
make && make install
ls /usr/local/bin/redis*
/usr/local/bin/redis-benchmark
/usr/local/bin/redis-cli
/usr/local/bin/redis-check-aof
/usr/local/bin/redis-server
/usr/local/bin/redis-check-dump
cp redis.conf /etc/
然后编辑redis.conf配置文件(/etc/redis.conf),按需求做出适当调整,比如:
vi /etc/redis.conf
daemonize yes #默认为on。yes为转为守护进程,否则启动时会每隔5秒输出一行监控信息
save 900 1 #900秒内如果有一个key发生变化时,则将数据写入进镜像
maxmemory 256000000 #分配256M内存
vi /etc/sysconfig/iptables#加入一行,需要具备其修改权限
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT
/etc/init.d/iptables restart
查看防火墙状态:
/etc/init.d/iptables status
ufw allow 6379
查看防火墙状态
ufw status
6379 ALLOW Anywhere
mkdir -p /var/log/redis/log
/usr/local/bin/redis-server /etc/redis.conf 1>/var/log/redis/infolog.log 2>/var/log/redis/errlog.log &
加入自启动:
vi /etc/rc.local#加入
/usr/local/bin/redis-server /etc/redis.conf 1>/var/log/redis/infolog.log 2>/var/log/redis/errlog.log &
redis-cli
redis 127.0.0.1:6379> set redisKey value
OK
redis 127.0.0.1:6379> get redisKey
"value"
redis 127.0.0.1:6379> del redisKey
(integer) 1
redis 127.0.0.1:6379> exists key
(integer) 0
清除所有数
六、遇到问题
我用java操作redis时,报过这样的错误:
(error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
解决:
redis-cli
config set stop-writes-on-bgsave-error no
推荐:http://www.laikanxia.com