redis 启动3个警告分析

1月 29, 2019 |

# 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的pending队列(linux2.6之后,表示完成3次握手,可以被accept方法返回的套接字)长度不能设置为期望的511,因为系统级的/proc/sys/net/core/somaxconn 文件中已经将其设置为128了。生效的值为listen()的backlog参数和/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.

执行snapshot备份的时候,redis fork一个新的进程来执行快照,fork采用的内存策略是copy-on-write,也就是只有更新了才会拷贝,否则父子进程内存共享,如果数据为3G,而当前只有2G的可用内存,那么overcommit_memory=0会导致fork失败,因为这时要确保系统有3G的可用内存,而overcommit_memory=1时采用乐观策略,先fork,只有真正出现内存不足才会失败。
设置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.

red hat 官方也是推荐数据库禁用huge page。因为默认一个内存页是4k,数据库这类高可靠性的应用,数据有一点变动都需要刷到磁盘保存,而使用大内存页,那么一次需要修改的扇区就更多了。另一个问题,数据库应用内存分配基本以小的对象为主,如果每个大内存页只释放了部分空间,那么整个内存页都没法回收再使用了。jemallo分配器对大内存页尤其不友好。甚至会导致cpu飙高,RSS明显比实际的数据集大,所以最好是将其关闭

Posted in: redis

Comments are closed.