Linux下的软件安装总是每次都有不一样的问题
记录一下执行过程

时效性: 2021年

版本疑云

在 CentOS7上用 yum 搜索 redis, 通常情况下是找不到想要的结果的:

[root@34fd69572161 /]# yum update
[root@34fd69572161 /]# yum search all redis
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirrors.dgut.edu.cn
 * extras: mirrors.cn99.com
 * updates: mirrors.dgut.edu.cn
============================================ Matched: redis =================================================
pcp-pmda-redis.x86_64 : Performance Co-Pilot (PCP) metrics for Redis
centos-logos.noarch : CentOS-related icons and pictures

网上有使用 yum install epel-release添加 Fedora 的 epel 仓库的, 先说结论: **不可行, 是过期攻略. **

如下:

[root@f873fc89b235 /]# yum install epel-release
[root@f873fc89b235 /]# yum update
[root@f873fc89b235 /]# yum info redis
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirrors.dgut.edu.cn
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.cn99.com
 * updates: mirrors.dgut.edu.cn
Available Packages
Name        : redis
Arch        : x86_64
Version     : 3.2.12
Release     : 2.el7
Size        : 544 k
Repo        : epel/x86_64
Summary     : A persistent key-value database
URL         : http://redis.io
License     : BSD
Description : Redis is an advanced key-value store.
...

有 redis 了, 不过是非常旧的版本3.2.12, 所以这个仓库应该是没有人维护了, 故该方法不可行

正解如下

使用 remi 仓库

官网地址: Remi’s RPM repository (remirepo.net)

在页面中找到如下部分, 右键 remi-release-8.rpm 复制链接地址即可得到仓库地址

image-20211003174250075

然后执行如下命令 (命令中的网址即上面复制的仓库地址)

yum install https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm -y

yum update -y

使用这个仓库时在 yum 后加上参数 --enablerepo=remi 即可

结果如下:

[root@34fd69572161 /]# yum --enablerepo=remi info redis
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirrors.dgut.edu.cn
 * epel: mirrors.bfsu.edu.cn
 * extras: mirrors.cn99.com
 * remi: mirrors.tuna.tsinghua.edu.cn
 * remi-safe: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.dgut.edu.cn
Available Packages
Name        : redis
Arch        : x86_64
Version     : 6.2.5
Release     : 1.el7.remi
Size        : 1.2 M
Repo        : remi
Summary     : A persistent key-value database
URL         : http://redis.io
License     : BSD
Description : Redis is an advanced key-value store.

执行安装

yum --enablerepo=remi install redis -y

启动服务:

[root@34fd69572161 /]# redis-server
442:C 03 Oct 2021 09:52:11.141 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
442:C 03 Oct 2021 09:52:11.141 # Redis version=6.2.5, bits=64, commit=00000000, modified=0, pid=442, just started
442:C 03 Oct 2021 09:52:11.141 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
442:M 03 Oct 2021 09:52:11.142 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 6.2.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 442
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

442:M 03 Oct 2021 09:52:11.143 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
442:M 03 Oct 2021 09:52:11.143 # Server initialized
......

成功