CentOS7下Redis的安装与配置及报错解决

KarlXu 2017-01-06 11:23:52原创浏览量2784

安装编译Redis

wget http://download.redis.io/releases/redis-3.2.100.tar.gz //下载
tar xzf redis-3.2.100.tar.gz  //解压
cd redis-3.2.100  //切换到解压的文件
make   //编译
make test
cd src  //切换到src目录
./redis-server redis.conf  //启动 启动服务时没有配置文件会警告
Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf'

这里的redis.conf是默认配置文件,如果没有可以在src的上级目录拷贝一份。

出现这个警告是因为在低内存环境下,后台保存可能失败。

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.

直接执行以下命令即可

sysctl vm.overcommit_memory=1

或者在/etc/sysctl.conf文件中加上sysctl vm.overcommit_memory=1 不过要重启服务器

出现这个警告提示是说最大连接数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.

在/etc/sysctl.conf文件加上net.core.somaxconn=1024 然后执行sysctl -p即可

出现

you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix thisissue 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 thesetting after a reboot. Redis must be restarted after THP is disabled.

执行

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

这一步只能临时解决  想永久解决还是要写入/etc/rc.local文件中 并且重启服务器


有问题请Email联系: karlxu0424@gmail.com