解决redis启动的警告日志问题
(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun)
redis启动时,出现警告日志
原因是redis缓存的数据过多,没有提前做好数据过期策略,导致超过物理机的实际内存。
需要修改计算机内存策略
(1)警告描述,不能设置tcp的堆积为511
因为/proc/sys/net/core/somaxconn的值为128太低。
报错:
WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
分析:
然后了解到/proc/sys/net/core/somaxconn为linux的内核参数,即linux每端扣可以监听的最大tcp数量。
解决方案:
修改linux系统参数,在里面增加net.core.somaxconn配置,注意:直接修改/proc/sys/net/core/somaxconn内,系统重启后会还原。
永久解决:vim /etc/sysctl.conf
net.ipv4.conf.default.accept_source_route = 1
立即生效:sysctl -p
(2)一台机器如果内存用完,在进行bgsave时,可能会报错
错误信息大概如下:
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.
分析:
当执行redis的bgsave命令时,redis会fork一个进程把redis中的内存数据写入磁盘。
这样的好处是,copy on write,有效的节省了内存占用。
但是,bgsave时,如果有数据变更,一样需要申请内存。
当申请内存时,如果发现内存不够,可能就会报上面的错误
vim /etc/sysctl.conf
net.core.somaxconn= 1024 sysctl vm.overcommit_memory=1 vm.overcommit_memory = 1
立即生效:sysctl -p
(3)使用的是透明大页,可能导致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文件中
if test -f /sys/kernel/mm/redhat_transparent_hugepage/enabled; then echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled fi
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持程序员之家。
相关文章
RediSearch加RedisJSON大于Elasticsearch的搜索存储引擎
这篇文章主要为大家介绍了RediSearch加RedisJSON大于Elasticsearch的王炸使用详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2022-07-07Spring?Boot实战解决高并发数据入库之?Redis?缓存+MySQL?批量入库问题
这篇文章主要介绍了Spring?Boot实战解决高并发数据入库之?Redis?缓存+MySQL?批量入库问题,本文通过图文实例相结合给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2022-02-02
最新评论