“Yum”的版本间的差异

来自姬鸿昌的知识库
跳到导航 跳到搜索
 
(未显示同一用户的6个中间版本)
第66行: 第66行:
  
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
 +
 +
=== 显示已配置的软件存储库 ===
 +
<syntaxhighlight lang="shell-session">
 +
[root@iZ8vbcjkeqbrdmmbt23vboZ ~]# yum repolist
 +
Loaded plugins: fastestmirror
 +
Loading mirror speeds from cached hostfile
 +
base                                                                                                                                                                                                                | 3.6 kB  00:00:00   
 +
docker-ce-stable                                                                                                                                                                                                    | 3.5 kB  00:00:00   
 +
epel                                                                                                                                                                                                                | 4.7 kB  00:00:00   
 +
extras                                                                                                                                                                                                              | 2.9 kB  00:00:00   
 +
updates                                                                                                                                                                                                              | 2.9 kB  00:00:00   
 +
(1/4): epel/x86_64/updateinfo                                                                                                                                                                                        | 1.0 MB  00:00:00   
 +
(2/4): epel/x86_64/primary_db                                                                                                                                                                                        | 7.0 MB  00:00:00   
 +
(3/4): updates/7/x86_64/primary_db                                                                                                                                                                                  |  17 MB  00:00:00   
 +
(4/4): docker-ce-stable/7/x86_64/primary_db                                                                                                                                                                          |  80 kB  00:00:00   
 +
repo id                                                                                                repo name                                                                                                                    status
 +
base/7/x86_64                                                                                          CentOS-7                                                                                                                      10,072
 +
docker-ce-stable/7/x86_64                                                                              Docker CE Stable - x86_64                                                                                                        164
 +
epel/x86_64                                                                                            Extra Packages for Enterprise Linux 7 - x86_64                                                                                13,758
 +
extras/7/x86_64                                                                                        CentOS-7                                                                                                                        512
 +
updates/7/x86_64                                                                                        CentOS-7                                                                                                                      4,135
 +
repolist: 28,641
 +
[root@iZ8vbcjkeqbrdmmbt23vboZ ~]#
 +
 +
</syntaxhighlight>
 +
 +
 +
=== [[yum配置源]] ===
  
  
第94行: 第124行:
  
  
=== 安装 epel-release ===
+
=== [[Yum 安装 epel-release|安装 epel-release]] ===
EPEL(Extra Packages for Enterprise Linux)是基于 Fedora 的一个项目,为“红帽系”的操作系统提供额外的软件包,适用于 RHEL、CentOS 和 Scientific Linux.
 
 
 
在 CentOS 下使用 yum 在安装包的时后往往会发生找不到 rpm 的情况,官方的 rpm repository 提供的 rpm 包也不够丰富,很多时候需要自己编译很痛苦,而 EPEL 恰恰可以解决这两方面的问题。
 
 
 
EPEL 的全称叫 Extra Packages for Enterprise Linux 。
 
  
EPEL是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。
 
  
装上了 EPEL之后,就相当于添加了一个第三方源。<syntaxhighlight lang="shell-session">
+
=== 显示有关一个包或一组包的详细信息 ===
[root@bogon docker_zk]# yum list installed|grep epel-release
+
<syntaxhighlight lang="shell-session">
[root@bogon docker_zk]# yum list |grep epel-release
+
[root@bogon docker_zk]# yum info docker-compose
epel-release.noarch                      7-11                        extras 
 
[root@bogon docker_zk]# yum repolist
 
 
Loaded plugins: fastestmirror
 
Loaded plugins: fastestmirror
 
Loading mirror speeds from cached hostfile
 
Loading mirror speeds from cached hostfile
 
  * base: mirrors.bfsu.edu.cn
 
  * base: mirrors.bfsu.edu.cn
 +
* epel: mirrors.bfsu.edu.cn
 
  * extras: mirrors.huaweicloud.com
 
  * extras: mirrors.huaweicloud.com
 
  * updates: mirrors.bfsu.edu.cn
 
  * updates: mirrors.bfsu.edu.cn
repo id                                                                                                              repo name                                                                                                      status
+
Installed Packages
base/7/x86_64                                                                                                        CentOS-7 - Base                                                                                                10,072
+
Name        : docker-compose
docker-ce-stable/7/x86_64                                                                                            Docker CE Stable - x86_64                                                                                          164
+
Arch        : noarch
extras/7/x86_64                                                                                                      CentOS-7 - Extras                                                                                                  512
+
Version    : 1.18.0
mysql-connectors-community/x86_64                                                                                    MySQL Connectors Community                                                                                        199
+
Release    : 4.el7
mysql-tools-community/x86_64                                                                                          MySQL Tools Community                                                                                              92
+
Size        : 1.1 M
mysql56-community/x86_64                                                                                              MySQL 5.6 Community Server                                                                                        581
+
Repo        : installed
updates/7/x86_64                                                                                                      CentOS-7 - Updates                                                                                              4,135
+
From repo   : epel
repolist: 15,755
+
Summary    : Multi-container orchestration for Docker
[root@bogon docker_zk]# yum -y install epel-release
+
URL        : https://github.com/docker/compose
 +
License    : ASL 2.0
 +
Description : Compose is a tool for defining and running multi-container Docker
 +
            : applications. With Compose, you use a Compose file to configure your
 +
            : application's services. Then, using a single command, you create and
 +
            : start all the services from your configuration.
 +
            :
 +
            : Compose is great for development, testing, and staging environments,
 +
            : as well as CI workflows.
 +
            :
 +
            : Using Compose is basically a three-step process.
 +
            :
 +
            : 1. Define your app's environment with a Dockerfile so it can be
 +
            :    reproduced anywhere.
 +
            : 2. Define the services that make up your app in docker-compose.yml so
 +
            :    they can be run together in an isolated environment:
 +
            : 3. Lastly, run docker-compose up and Compose will start and run your
 +
            :   entire app.
 +
 
 +
[root@bogon docker_zk]#
 +
 
 +
</syntaxhighlight>
 +
 
 +
 
 +
=== 检查哪个包提供了命令 ===
 +
<syntaxhighlight lang="shell-session">
 +
[root@iZ8vbcjkeqbrdmmbt23vboZ yum.repos.d]# yum whatprovides lsb_release
 
Loaded plugins: fastestmirror
 
Loaded plugins: fastestmirror
 
Loading mirror speeds from cached hostfile
 
Loading mirror speeds from cached hostfile
  * base: mirrors.bfsu.edu.cn
+
  * base: mirrors.cloud.aliyuncs.com
  * extras: mirrors.huaweicloud.com
+
  * extras: mirrors.cloud.aliyuncs.com
  * updates: mirrors.bfsu.edu.cn
+
  * updates: mirrors.cloud.aliyuncs.com
Resolving Dependencies
+
redhat-lsb-core-4.1-27.el7.centos.1.i686 : LSB Core module support
--> Running transaction check
+
Repo        : base
---> Package epel-release.noarch 0:7-11 will be installed
+
Matched from:
--> Finished Dependency Resolution
+
Filename    : /usr/bin/lsb_release
 +
 
 +
 
 +
 
 +
redhat-lsb-core-4.1-27.el7.centos.1.x86_64 : LSB Core module support
 +
Repo        : base
 +
Matched from:
 +
Filename    : /usr/bin/lsb_release
 +
 
  
Dependencies Resolved
 
  
============================================================================================================================================================================================================================================
+
redhat-lsb-core-4.1-27.el7.centos.1.x86_64 : LSB Core module support
Package                                                      Arch                                                    Version                                                Repository                                              Size
+
Repo        : @base
============================================================================================================================================================================================================================================
+
Matched from:
Installing:
+
Filename    : /usr/bin/lsb_release
epel-release                                                  noarch                                                  7-11                                                  extras                                                  15 k
 
  
Transaction Summary
 
============================================================================================================================================================================================================================================
 
Install  1 Package
 
  
Total download size: 15 k
 
Installed size: 24 k
 
Downloading packages:
 
epel-release-7-11.noarch.rpm                                                                                                                                                                                        |  15 kB  00:00:00   
 
Running transaction check
 
Running transaction test
 
Transaction test succeeded
 
Running transaction
 
  Installing : epel-release-7-11.noarch                                                                                                                                                                                                1/1
 
  Verifying  : epel-release-7-11.noarch                                                                                                                                                                                                1/1
 
  
Installed:
+
[root@iZ8vbcjkeqbrdmmbt23vboZ yum.repos.d]#
  epel-release.noarch 0:7-11                                                                                                                                                                                                               
 
  
Complete!
 
[root@bogon docker_zk]# yum list installed|grep epel-release
 
epel-release.noarch            7-11                          @extras         
 
[root@bogon docker_zk]# yum repolist
 
Loaded plugins: fastestmirror
 
Loading mirror speeds from cached hostfile
 
epel/x86_64/metalink                                                                                                                                                                                                | 6.5 kB  00:00:00   
 
* base: mirrors.bfsu.edu.cn
 
* epel: mirrors.bfsu.edu.cn
 
* extras: mirrors.huaweicloud.com
 
* updates: mirrors.bfsu.edu.cn
 
epel                                                                                                                                                                                                                | 4.7 kB  00:00:00   
 
(1/3): epel/x86_64/updateinfo                                                                                                                                                                                        | 1.0 MB  00:00:00   
 
(2/3): epel/x86_64/group_gz                                                                                                                                                                                          |  97 kB  00:00:00   
 
(3/3): epel/x86_64/primary_db                                                                                                                                                                                        | 7.0 MB  00:00:00   
 
repo id                                                                                                    repo name                                                                                                                status
 
base/7/x86_64                                                                                              CentOS-7 - Base                                                                                                          10,072
 
docker-ce-stable/7/x86_64                                                                                  Docker CE Stable - x86_64                                                                                                    164
 
epel/x86_64                                                                                                Extra Packages for Enterprise Linux 7 - x86_64                                                                            13,758
 
extras/7/x86_64                                                                                            CentOS-7 - Extras                                                                                                            512
 
mysql-connectors-community/x86_64                                                                          MySQL Connectors Community                                                                                                  199
 
mysql-tools-community/x86_64                                                                                MySQL Tools Community                                                                                                        92
 
mysql56-community/x86_64                                                                                    MySQL 5.6 Community Server                                                                                                  581
 
updates/7/x86_64                                                                                            CentOS-7 - Updates                                                                                                        4,135
 
repolist: 29,513
 
[root@bogon docker_zk]#
 
 
</syntaxhighlight>
 
</syntaxhighlight>

2022年8月16日 (二) 22:07的最新版本

简介

Yum(全称为 Yellow dog Updater, Modified)是一个在 FedoraRedHat 以及 CentOS 中的 Shell 前端软件包管理器。

基于 RPM 包管理,能够从指定的服务器自动下载 RPM 包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。


显示配置的软件存储库

[root@localhost docker_zk]# yum repolist
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.bfsu.edu.cn
repo id                                            repo name                                  status
!base/7/x86_64                                     CentOS-7 - Base                            10,072
!extras/7/x86_64                                   CentOS-7 - Extras                             500
!mysql-connectors-community/x86_64                 MySQL Connectors Community                    221
!mysql-tools-community/x86_64                      MySQL Tools Community                         135
!mysql56-community/x86_64                          MySQL 5.6 Community Server                    581
!updates/7/x86_64                                  CentOS-7 - Updates                          2,943
repolist: 14,452
[root@localhost docker_zk]#


查看已安装

[root@bogon docker_zk]# yum list installed
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.bfsu.edu.cn
Installed Packages
NetworkManager.x86_64                                                        1:1.18.8-2.el7_9                                                        @updates          
NetworkManager-libnm.x86_64                                                  1:1.18.8-2.el7_9                                                        @updates 
......
[root@bogon docker_zk]#


确认是否安装

[root@localhost docker_zk]# yum list installed|grep wget
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
wget.x86_64                          1.14-18.el7_6.1                @base
[root@localhost docker_zk]# yum list installed|grep yum-utils
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
[root@localhost docker_zk]#


安装 yum-utils

yum-utils 包含可以添加 yum 镜像的 yum-config-manager

[root@localhost docker_zk]# yum install -y yum-utils
......
[root@localhost docker_zk]# yum list installed|grep yum-utils
yum-utils.noarch                     1.1.31-54.el7_8                @base
[root@localhost docker_zk]#


显示已配置的软件存储库

[root@iZ8vbcjkeqbrdmmbt23vboZ ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                                                                                                                                                                                                 | 3.6 kB  00:00:00     
docker-ce-stable                                                                                                                                                                                                     | 3.5 kB  00:00:00     
epel                                                                                                                                                                                                                 | 4.7 kB  00:00:00     
extras                                                                                                                                                                                                               | 2.9 kB  00:00:00     
updates                                                                                                                                                                                                              | 2.9 kB  00:00:00     
(1/4): epel/x86_64/updateinfo                                                                                                                                                                                        | 1.0 MB  00:00:00     
(2/4): epel/x86_64/primary_db                                                                                                                                                                                        | 7.0 MB  00:00:00     
(3/4): updates/7/x86_64/primary_db                                                                                                                                                                                   |  17 MB  00:00:00     
(4/4): docker-ce-stable/7/x86_64/primary_db                                                                                                                                                                          |  80 kB  00:00:00     
repo id                                                                                                 repo name                                                                                                                     status
base/7/x86_64                                                                                           CentOS-7                                                                                                                      10,072
docker-ce-stable/7/x86_64                                                                               Docker CE Stable - x86_64                                                                                                        164
epel/x86_64                                                                                             Extra Packages for Enterprise Linux 7 - x86_64                                                                                13,758
extras/7/x86_64                                                                                         CentOS-7                                                                                                                         512
updates/7/x86_64                                                                                        CentOS-7                                                                                                                       4,135
repolist: 28,641
[root@iZ8vbcjkeqbrdmmbt23vboZ ~]#


yum配置源

yum 添加镜像

这里以 docker 镜像为例

[root@localhost docker_zk]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@localhost docker_zk]#


yum makecache

添加镜像或缓存过期时需要进行此操作

用于下载当前启用的 yum 存储库的所有元数据并使其可用。

如果参数“fast”被传递,那么我们只是尝试确保 repos 是最新的(很像“yum clean expire-cache”)。

[root@localhost docker_zk]# yum makecache fast
 ...
[root@localhost docker_zk]#


安装 epel-release

显示有关一个包或一组包的详细信息

[root@bogon docker_zk]# yum info docker-compose
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * epel: mirrors.bfsu.edu.cn
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.bfsu.edu.cn
Installed Packages
Name        : docker-compose
Arch        : noarch
Version     : 1.18.0
Release     : 4.el7
Size        : 1.1 M
Repo        : installed
From repo   : epel
Summary     : Multi-container orchestration for Docker
URL         : https://github.com/docker/compose
License     : ASL 2.0
Description : Compose is a tool for defining and running multi-container Docker
            : applications. With Compose, you use a Compose file to configure your
            : application's services. Then, using a single command, you create and
            : start all the services from your configuration.
            : 
            : Compose is great for development, testing, and staging environments,
            : as well as CI workflows.
            : 
            : Using Compose is basically a three-step process.
            : 
            : 1. Define your app's environment with a Dockerfile so it can be
            :    reproduced anywhere.
            : 2. Define the services that make up your app in docker-compose.yml so
            :    they can be run together in an isolated environment:
            : 3. Lastly, run docker-compose up and Compose will start and run your
            :    entire app.

[root@bogon docker_zk]#


检查哪个包提供了命令

[root@iZ8vbcjkeqbrdmmbt23vboZ yum.repos.d]# yum whatprovides lsb_release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cloud.aliyuncs.com
 * extras: mirrors.cloud.aliyuncs.com
 * updates: mirrors.cloud.aliyuncs.com
redhat-lsb-core-4.1-27.el7.centos.1.i686 : LSB Core module support
Repo        : base
Matched from:
Filename    : /usr/bin/lsb_release



redhat-lsb-core-4.1-27.el7.centos.1.x86_64 : LSB Core module support
Repo        : base
Matched from:
Filename    : /usr/bin/lsb_release



redhat-lsb-core-4.1-27.el7.centos.1.x86_64 : LSB Core module support
Repo        : @base
Matched from:
Filename    : /usr/bin/lsb_release



[root@iZ8vbcjkeqbrdmmbt23vboZ yum.repos.d]#