Centos 7 安装 Redis6(最新)

7 篇文章 0 订阅
5 篇文章 0 订阅

1、安装准备

#安装 gcc
[root@localhost /]# yum -y install gcc tcl
# 查看 gcc 版本是否在 5.3 以上,centos7.6 默认安装 4.8.5
[root@localhost /]# gcc -v

gcc 版本过低编译 redis6.0 时会报错,所下面升级版本

# 升级到 gcc 9.3:
[root@localhost /]# yum -y install centos-release-scl
[root@localhost /]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
[root@localhost /]# scl enable devtoolset-9 bash
# 需要注意的是 scl 命令启用只是临时的,退出 shell 或重启就会恢复原系统 gcc 版本。
# 如果要长期使用 gcc 9.3的话:
[root@localhost /]# echo -e "\nsource /opt/rh/devtoolset-9/enable" >>/etc/profile

这样退出 shell 重新打开就是新版的 gcc了
以下其他版本同理,修改 devtoolset 版本号即可。

2、开始安装

[root@localhost /]# cd /usr/local/
[root@localhost local]# wget http://download.redis.io/releases/redis-6.0.9.tar.gz
[root@localhost local]# tar -zxvf redis-6.0.9.tar.gz
[root@localhost local]# cd redis-6.0.9
[root@localhost redis-6.0.9]# make
# 编译安装到指定目录下
[root@localhost redis-6.0.9]# make PREFIX=/usr/local/redis install
[root@localhost redis-6.0.9]# cp redis.conf /usr/local/redis/6379.conf

3、登陆测试

[root@localhost redis-6.0.9]# cd /usr/local/redis
[root@localhost redis]# ll
总用量 84
-rw-r--r--. 1 root root 84841 12月 19 22:57 6379.conf
drwxr-xr-x. 2 root root   134 12月 19 22:56 bin
[root@localhost redis]# ./bin/redis-server 6379.conf 
51189:C 19 Dec 2020 22:57:22.206 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
51189:C 19 Dec 2020 22:57:22.206 # Redis version=6.0.9, bits=64, commit=00000000, modified=0, pid=51189, just started
51189:C 19 Dec 2020 22:57:22.206 # Configuration loaded
51189:M 19 Dec 2020 22:57:22.207 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 6.0.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 51189
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

51189:M 19 Dec 2020 22:57:22.208 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
51189:M 19 Dec 2020 22:57:22.208 # Server initialized
51189:M 19 Dec 2020 22:57:22.208 # 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.
51189:M 19 Dec 2020 22:57:22.208 # 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').
51189:M 19 Dec 2020 22:57:22.209 * Ready to accept connections

复制一个连接窗口执行

[root@localhost bin]# cd /usr/local/redis
[root@localhost redis]# ./bin/redis-cli 
127.0.0.1:6379> ping
PONG

安装已经成功,当然这不是结束,其他的配置直接再 6379.conf 修改即可

原文连接

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值