阅读模式:

contos7安装redis4.0

查看:4268  回复:0  类型:  来源:php自学网  标签 redis centos

contos7中安装redis4.0。

一、下载redis包,解压,编译安装

wget 
tar xzf redis-4.0.11.tar.gz
cd redis-4.0.11
make

二、重命名和移动目录

cd ..
cp redis-4.0.11 /usr/local/
mv redis-4.0.11 redis

三、启动redis

cd /usr/local/redis/src/
#cp redis-server redis-cli /usr/bin/ 
./redis-server

四、配置centos内核等参数解决redis启动报错

    报错1:

            The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

        解决:

vim /etc/sysctl.conf
#添加代码
net.core.somaxconn= 1024
#配置生效
sysctl -p

    报错2:

        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.

        解决:

vim /etc/sysctl.conf
#增加代码
vm.overcommit_memory = 1
#配置生效
sysctl -p

    报错3:

        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 y

        解决:

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

五、守护进程运行

vim /usr/local/redis/redis.conf
#修改daemonize
daemonize yes

六、外网访问redis

    修改配置文件redis.conf ,注释bind 127.0.0.1 ,取消保护模式 protected-mode 设置 no,开启外网访问后需要设置密码,#requirepass foobared去掉注释,foobared改为自己的密码。

bind 127.0.0.1
protected-mode no
requirepass 123456

redis开机启动脚本参考:http://zixuephp.net/article-268.html

分享到:
0 0

发布评论:


登录:
  表情:
提交