---恢复内容开始---
环境:centOS6.5
安装包:redis-3.0.0.tar.gz
将redis-3.0.0.tar.gz放到/usr/local
一、安装
1进入/usr/local下进行解压
cd /usr/local
tar -zvf redis-3.0.0.tar.gz
2进入解压目录进行编译安装
cd /usr/local/redis-3.0.0
make
make PREFIX=/usr/local/redis install
# 安装到指定目录下如/usr/local/redis
3拷贝redis配置文件到安装路径下
cp /usr/local/redis-3.0.0/redis.conf /usr/local/redis/bin
#redis.conf是redis的配置文件,redis.conf在redis源码目录。注意修改port作为redis进程的端口,port默认6379
3如果想要修改redis密码或者开启后台启动可以进入配置文件redis.con下进行修改
vi /usr/local/redis/bin/redis.conf
搜索文件内容/daemonize 按回车键后,点击n查找下一个
把daemonize修改成daemonize yes(开启后台启动)
搜索文件内容requirepass按回车键,点击n查找下一个
把requirepass前边的#去掉,在requirepass后面加上密码,
如:requirepass 111111
:wq #保存并退出
4启动redis(前端和后端)
#进入安装目录bin下
./redis.server #前端启动
./redis.server ./redis.conf #后端启动
Redis前端启动后有警告问题(可解决可不解决)
解决方法
一,警告一WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
出现这个警告可以临时解决,方案上面已经写了
执行这条命令
echo never > /sys/kernel/mm/transparent_hugepage/enabled'
如果要永久的话就需要写入到/etc/rc.local里面
二,警告二WARNING The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128
和
警告三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.
在/etc/sysctl.con文件里添加两句
vi /etc/sysctl.con
net.core.somaxconn= 1024
vm.overcommit_memory = 1
就行了
如果Tomcat启动后,后台报
container-292 o.s.d.r.l.RedisMessageListenerContainer:Cobbection failure occurred.Restaring subscription task after 5000ms
那么问题可能是redis配置文件忘记修改密码而导致的
解决:Redis配置文件requirepass 密码