0 921
centos7编译安装redis_图一

1、下载源码
wget http://download.redis.io/releases/redis-4.0.10.tar.gz
tar -xzf redis-4.0.10.tar.gz
cd redis-4.0.10
2、编译安装

make PREFIX=/usr/local/redis install
make install
mkdir /usr/local/redis/etc/
cp redis.conf /usr/local/redis/etc/
cd /usr/local/redis/bin/
ln -s /usr/local/redis/bin/redis-benchmark /usr/bin/redis-benchmark
ln -s /usr/local/redis/bin/redis-server /usr/bin/redis-server
ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis-cli

3、如果有如下警告提醒可以修改

第一个警告:The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
第二个警告: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.
第三个警告: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.

以上警告解决办法

第一个警告
将net.core.somaxconn = 1024添加到/etc/sysctl.conf中,然后执行sysctl -p生效配置。

第二个警告
将vm.overcommit_memory = 1添加到/etc/sysctl.conf中,然后执行sysctl -p生效配置。

第三个警告(本人觉得可以忽略,如果你想处理就按下面这个命令执行)
将echo never > /sys/kernel/mm/transparent_hugepage/enabled添加到/etc/rc.local中,然后执行source /etc/rc.local生效配置。

4、测试一下

# 客户端启动
/usr/local/redis/bin/redis-cli 
127.0.0.1:6379> set testa helloworld
OK
127.0.0.1:6379> get testa
"helloworld"
127.0.0.1:6379> exit

5、如果你想后台启动redis

vim /usr/local/redis/etc/redis.conf
把daemonize设置为yes
6、如果你想把启动文件放到 /etc/init.d/ 目录下

cd 你下载源码redis源码包里
cp utils/redis_init_script /etc/init.d/redis
别忘了 修改一下 /etc/init.d/redis

比如 EXEC = 你的启动程序(/usr/bin/redis-server)

CLIEXEC = 你的启动程序(/usr/bin/redis-cli)



[分类]
[来源] http://erlangyun.com/p/id/270.html
[声明] 本站资源来自用户分享,如损害你的权益请联系客服QQ:120074275给予处理。