美文网首页
Redis6 安装

Redis6 安装

作者: _大叔_ | 来源:发表于2020-11-17 10:29 被阅读0次

安装

wget https://download.redis.io/releases/redis-6.0.9.tar.gz
tar xzf redis-6.0.9.tar.gz
cd redis-6.0.9
make

如果安装报错,查看gcc版本

gcc -v

centos7默认版本为4.8.5,而redis6.0+需要的gcc版本为5.3及以上,所以升级gcc即可

//升级gcc到9以上
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
//临时将此时的gcc版本改为9
scl enable devtoolset-9 bash
//或永久改变
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile

查看gcc版本

gcc -v

重新 make即可。

redis启动三个警告

tcp-blok积压问题

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

内存设置为0!在内存不足的情况下,后台保存可能会失败,建议设置为1.

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.

操作系统默认的内存页大小是4kB,可以如果使用更大的内存页比如2MB,就可以使用同样多的页表项,管理更大的内存空间,但是对于redis这样的内存数据库,它会导致内存分配的速度变慢,并且导致内存的实际使用率下降,因此redis推荐我们关闭此项

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 madvise > /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 (set to 'madvise' or 'never').
前两个问题解决如下:
vim /etc/sysctl.conf 

加入如下

# redis 设置挤压,可以查看redis.cnf 文件里也有关于tcp-backlog
net.core.somaxconn=2048
# 和tcp-backlog 有关
net.ipv4.tcp_max_syn_backlog = 2048
# 内存设置为0!在内存不足的情况下,后台保存可能会失败
vm.overcommit_memory=1

查看是否添加

sysctl -p
最后一个问题
vim /etc/rc.local 

加入如下

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

让配置生效

source /etc/rc.local 

相关文章

网友评论

      本文标题:Redis6 安装

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