CentOS7中安装Redis

    最近公司想将redis数据库运用在项目中,于是在自己电脑的虚拟机上试安装了一下。虚拟机上安装的是CentOS7系统,首先在redis官网下载安装包,redis版本号小数点后数字为偶数的版本是稳定版,奇数版本是测试版或非稳定版。也可以使用wget命令:


编译后在redis源代码目录的src文件夹中可以找到一些可执行程序,在编译后执行make install命令来将这些可执行程序复制到/usr/local/bin目录中,以后执行程序时就不用输入完整路径了。这边我make install时报了一个usr无权限的错误,于是su到root用户(记得要取得root的密码),接着make install就可以了。redis安装成功,运行之前最好make test一下测试redis是否编译正确,我在make test时有蹦出来个问题:You need tcl 8.5 or newer in order to run the Redis test。这是系统中安装的tcl语言版本低了,

需要8.5以上版本,于是wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz下载tcl包,解压安装tar xzvf tcl8.6.1-src.tar.gz,进入

到安装目录的unix文件夹./configure运行,之后编译make、make install,新版的tcl安装就好了。回到redis,make test,显示测试编译无异常。

直接启动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

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.

解决:

针对这两个问题,都要修改/etc/sysctl.conf文件,在文件末尾加入以下两句:

net.core.somaxconn= 1024
vm.overcommit_memory = 1

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 your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

解决:root用户执行echo never > /sys/kernel/mm/transparent_hugepage/enabled,进入etc/rc.local中添加

echo never > /sys/kernel/mm/transparent_hugepage/enabled,执行reboot命令,这里注意rc.local文件需要有执行权限,

否则修改会不奏效,这一点在rc.local文件的注释中写了。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值