美文网首页
Centos8 yum安装 Redis5

Centos8 yum安装 Redis5

作者: 我爱张智容 | 来源:发表于2020-12-11 15:33 被阅读0次

安装:

//安装依赖
yum -y install gcc  tcl 

//安装redis  centos 8 默认安装就是redis 5.0 
yum install redis 

配置

// 默认配置文件位置: /etc/redis.conf
bind 127.0.0.1   # 绑定的IP 
port 6379          # 绑定端口 
daemonize yes  # 是否守护进程运行
pidfile /var/run/redis_6379.pid  # pid 文件位置 
logfile /data/logs/redis/redis.log  # 日志文件位置 
dbfilename dump.rdb                # rdb持久化数据库名称
dir /data/db/redis                       # 持久化数据库保存位置 
requirepass passwd                 # 客户端链接redis需要密码
# maxmemory 2048MB            # 限制redis 最大使用内存

systemctl 管理服务

[root@prod default]# vim /lib/systemd/system/redis.service 
[Unit]
Description=Redis persistent key-value database
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/redis-server /etc/redis.conf
ExecStop=/usr/libexec/redis-shutdown -a passwd
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target

然后启动,并查日志

systemctl start redis  
ps -ef |grep redis  

查日志并解决问题

查看启动日志发现 如下错误, 但是都给出了解决方案 
20374:M 11 Dec 2020 14:52:06.418 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
20374:M 11 Dec 2020 14:52:06.418 # Server initialized
20374:M 11 Dec 2020 14:52:06.418 # 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.
20374:M 11 Dec 2020 14:52:06.418 # 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.

//问题1 : 
echo 1024 > /proc/sys/net/core/somaxconn
vim  /etc/sysctl.conf
添加: net.core.somaxconn= 1024 
执行: sysctl -p  

//问题2 : 
vim  /etc/sysctl.conf
添加:vm.overcommit_memory = 1
执行: sysctl -p  

//问题3 :
echo never > /sys/kernel/mm/transparent_hugepage/enabled

最后重启下redis,完毕!

相关文章

网友评论

      本文标题:Centos8 yum安装 Redis5

      本文链接:https://www.haomeiwen.com/subject/wbmjgktx.html