1、启动警告
CentOS 7下安装的Redis,按照默认配置启动总是提示:
4300:M 21 May 05:13:52.870 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
4300:M 21 May 05:13:52.870 # Server started, Redis version 3.2.12
4300:M 21 May 05:13:52.870 # 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.
4300:M 21 May 05:13:52.870 # 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 511 > /proc/sys/net/core/somaxconn
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1
echo never > /sys/kernel/mm/transparent_hugepage/enabled
并在/etc/rc.local文件最后添加:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
重新启动Redis Server,警告解除。
2、无法保存内存镜像
Redis可通过RDB或者AOF的方式持久化数据到硬盘上。最近修改了保存目录,缺报错无法保存了。
4394:M 21 May 05:38:50.014 * 10 changes in 300 seconds. Saving...
4394:M 21 May 05:38:50.014 * Background saving started by pid 4464
4464:C 21 May 05:38:50.014 # Failed opening the RDB file dump.rdb (in server root dir /data/xncd/redis) for saving: Permission denied
首先查看下Redis的运行账号:
查看Redis运行账号
再看看设置保存目录的权限:
ll /data/xncd
果然发现目录的属主为root:root,执行以下指令,设置属主为redis即可:
chown -R redis /data/xncd/redis
网友评论