Redis 启动警告解决方法
第一个问题: Increased maximum number of open files to 10032 (it was originally set to 1024). ?
原因分析:即进程能打开的最大文件描述符太小了。系统默认设置的值一般是 1024 。
解决方法:
1.系统级别,即?linux 内核能分配的最大文件描述符数量(参考:mit_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?指的是进程申请的内存大小。当参数值为 0?时,如果一次性申请的内存大小超过了系统总内存,有可能被拒绝。当参数值为 0?时,有可能会导致?redis?执行 bgsave?操作保存 rdb?文件失败。(参考:/?p=102)。
解决方法:
# vi /etc/sysctl.conf
vm.overcommit_memory = 1
# sysctl -p
查看方法:
# cat /proc/sys/vm/overcommit_memory
# sysctl vm.overcommit_memory
第四个问题:
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.
原因分析:Transparent Huge Pages (THP)?开启后会使 redis?时延变大和造成内存使用问题(参考:https://redis.io/topics/latency)。
解决方法(CentOS 6.X):
echo never > /sys/kernel/mm/transparent_hugepage/enabled
# vim /etc/rc.local
echo never > /sys/kernel/mm/transparent_hugepage/enabled
解决方法(CentOS 7.X):
# vim?/etc/systemd/system/disable-transparent-huge-pages.service
[Unit]
Description=Disable Transparent Huge Pages (THP)
DefaultDependencies=no
After=sysinit.target local-fs.target
[Service]
Type=oneshot
ExecStart=/bin/sh -c 'echo never | tee /sys/kernel/mm/transparent_hugepage/enabled > /dev/null'
[Install]
WantedBy=basic.target
# systemctl enable disable-transparent-huge-pages
# systemctl start disable-transparent-huge-pages
查看方法:
# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]