在EC2上解决Ubuntu 16.04的overcommit_memory和Transparent Huge页面上的Redis警告

时间:2016-12-17 22:04:01

标签: ubuntu amazon-ec2 redis sysctl huge-pages

在新的Ubuntu 16.04 EC2实例上,警告显示如下:

QFileSystemWatcher *

如何永久消除它们?

2 个答案:

答案 0 :(得分:5)

与警告建议一样,只需将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. 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. 行添加到vm.overcommit_memory=1的底部,就像/etc/sysctl.conf一样。

但权限不允许您按照警告的建议编辑THP,所以改为

sudo vi /etc/sysctl.conf

并将命令sudo apt install hugepages 添加到.bashrc的底部,类似sudo hugeadm --thp-never

然后只需sudo vi ~/.bashrc,然后下次在运行sudo reboot中进行SSH并且警告消失了!

答案 1 :(得分:1)

使用 Linux 和 Ubuntu,我在运行 redis-server 之前这样做了,而且它似乎有效...

sudo add-apt-repository ppa:redislabs/redis
sudo apt-get update
sudo apt-get install redis

https://redis.io/download