以前查看redis启动日志时发现redis启动时有几条报警,之前在解决这些问题时没做记录,以至于今天安装redis后还要问度娘怎么解决,这次就记录一下方便下次查找。
警告1:
828:M 30 May 19:20:29.837 # You requested maxclients of 10000 requiring at least 10032 max file descriptors. 828:M 30 May 19:20:29.838 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted. 828:M 30 May 19:20:29.838 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
这个问题根据redis的提示是解决不了的,
解决方法:
第一步: 修改redis.cnf配置文件,默认在/etc/redis/redis.cnf
,配置maxclients 为10000(默认就是10000)
第二步: 修改redis.service文件,默认在/etc/systemd/system/redis.service
在Group下面添加 LimitNOFILE=65536
第三步:执行下面重启命令使配置生效
sudo systemctl daemon-reload
sudo systemctl restart redis.service
警告2
The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
解决方法:
将net.core.somaxconn = 1024
添加到/etc/sysctl.conf
中,然后执行sudo sysctl -p
生效配置。
警告3
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.
解决方法:
将vm.overcommit_memory = 1
添加到/etc/sysctl.conf
中,然后执行sudo sysctl -p
生效配置
警告4
you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix thisissue 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 thesetting after a reboot. Redis must be restarted after THP is disabled
解决方法:
将echo never > /sys/kernel/mm/transparent_hugepage/enabled
添加到/etc/rc.local
中,然后执行source /etc/rc.local
生效配置,注意要放在exit 0
前面