下载解压
1 | wget http://download.redis.io/releases/redis-3.2.9.tar.gz |
编译安装
1 | cd /usr/src/redis-3.2.9/ |
配置
1 | echo "PATH=$PATH:/data/redis/bin" >> /etc/profile |
启动警告错误
用这个脚本管理之前,需要先配置下面的内核参数,否则Redis脚本在重启或停止redis时,将会报错,并且不能自动在停止服务前同步数据到磁盘上:
1 | #WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. |
默认监听的端口是本地,如果要远程连接要修改配置1
2```
bind 0.0.0.0
修改之后重启服务1
/etc/init.d/redis_6379 restart
测试
$ redis-cli
redis 127.0.0.1:6379> ping
PONG
redis 127.0.0.1:6379> set foo bar
redis 127.0.0.1:6379> get foo
bar