操作系统:Centos 7.7
Redis 版本:5.0.7
shell> wget http://download.redis.io/releases/redis-5.0.7.tar.gz
shell> tar xzf redis-5.0.7.tar.gz
shell> cd redis-5.0.7
shell> make
shell> src/redis-server redis.conf
WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
意思是:TCP backlog设置值,511没有成功,因为 /proc/sys/net/core/somaxconn这个设置的是更小的128.
临时解决方法:(即下次启动还需要修改此值)
echo 511 > /proc/sys/net/core/somaxconn
永久解决方法:(即以后启动还需要修改此值)
将其写入/etc/rc.local文件中。
shell> vim /etc/rc.local
# 添加echo 511 > /proc/sys/net/core/somaxconn
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.
意思是:overcommit_memory参数设置为0!在内存不足的情况下,后台程序save可能失败。建议在文件 /etc/sysctl.conf 中将overcommit_memory修改为1。
临时解决方法:echo “vm.overcommit_memory=1” > /etc/sysctl.conf
永久解决方法:将其写入/etc/sysctl.conf文件中。
shell> vim /etc/sysctl.conf
#文件末尾添加vm.overcommit_memory = 1
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.
意思是:你使用的是透明大页,可能导致redis延迟和内存使用问题。执行 echo never > /sys/kernel/mm/transparent_hugepage/enabled 修复该问题。
临时解决方法:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
永久解决方法:
将其写入/etc/rc.local文件中。
shell> vim /etc/rc.local
#文件末尾添加echo never > /sys/kernel/mm/transparent_hugepage/enabled
# 执行如下命令,这个是重点。不执行,可能无法生效
shell> chmod +x /etc/rc.d/rc.local
# 重启
shell> reboot
设置后台运行
#编辑redis.conf
shell> vim redis.conf
#修改 daemonize 为 yes
#指定配置文件启动
shell> src/redis-server redis.conf
这里的方式为检查redis端口,然后杀掉进程
shell> lsof -i tcp:6379
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
redis-ser 3907 root 6u IPv4 28505 0t0 TCP localhost:6379 (LISTEN)
shell> kill -9 3907
参考与引用:
https://redis.io/download
https://www.linuxidc.com/Linux/2016-11/137515.htm
https://blog.51cto.com/sf1314/2156127