Redis 启动报警解决办法

redis 安装好启动后,报警如下:

# Server started, Redis version 3.0.7
# 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.
* The server is now ready to accept connections on port 6379

警告1解决办法:

# echo "vm.overcommit_memory=1" >> /etc/sysctl.conf
# sysctl -p

警告2解决办法:

# echo never > /sys/kernel/mm/transparent_hugepage/enabled

为了防止重启失效,请将其写到开机启动中

# echo "echo never > /sys/kernel/mm/transparent_hugepage/enabled" >> /etc/rc.local

重启redis报警解除