| 
                        副标题[/!--empirenews.page--]
                           
在基于 RPM 的系统上,例如 RHEL、CentOS 等,我们中的许多人使用 yum 包管理器来管理软件的安装、删除、更新、搜索等。 
Linux 发行版的大部分软件都来自发行版官方仓库。官方仓库包含大量免费和开源的应用和软件。它很容易安装和使用。 
由于一些限制和专有问题,基于 RPM 的发行版在其官方仓库中没有提供某些包。另外,出于稳定性考虑,它不会提供最新版本的核心包。 
为了克服这种情况,我们需要安装或启用需要的第三方仓库。对于基于 RPM 的系统,有许多第三方仓库可用,但所建议使用的仓库很少,因为这些不会替换大量的基础包。 
这可以在基于 RPM 的系统上完成,比如 RHEL, CentOS, OEL, Fedora 等。 
    - Fedora 系统使用 
dnf config-manager [options] [section …] 
    - 其它基于 RPM 的系统使用 
yum-config-manager [options] [section …] 
 
如何列出启用的仓库
只需运行以下命令即可检查系统上启用的仓库列表。 
对于 CentOS/RHEL/OLE 系统: 
# yum repolistLoaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfilerepo id                                                       repo name                                                                 statusbase                                                          CentOS-6 - Base                                                           6,706extras                                                        CentOS-6 - Extras                                                            53updates                                                       CentOS-6 - Updates                                                        1,255repolist: 8,014
  
对于 Fedora 系统: 
# dnf repolist
  
如何在系统中添加一个新仓库
每个仓库通常都提供自己的 .repo 文件。要将此类仓库添加到系统中,使用 root 用户运行以下命令。在我们的例子中将添加 EPEL 仓库 和 IUS 社区仓库,见下文。 
但是没有 .repo 文件可用于这些仓库。因此,我们使用以下方法进行安装。 
对于 EPEL 仓库,因为它可以从 CentOS 额外仓库获得,所以运行以下命令来安装它。 
# yum install epel-release -y
  
对于 IUS 社区仓库,运行以下 bash 脚本来安装。 
# curl 'https://setup.ius.io/' -o setup-ius.sh# sh setup-ius.sh
  
如果你有 .repo 文件,在 RHEL/CentOS/OEL 中,只需运行以下命令来添加一个仓库。 
# yum-config-manager --add-repo http://www.example.com/example.repo-  
 Loaded plugins: product-id, refresh-packagekit, subscription-manageradding repo from: http://www.example.com/example.repograbbing file http://www.example.com/example.repo to /etc/yum.repos.d/example.repoexample.repo                                             |  413 B     00:00repo saved to /etc/yum.repos.d/example.repo
  
对于 Fedora 系统,运行以下命令来添加一个仓库: 
# dnf config-manager --add-repo http://www.example.com/example.repoadding repo from: http://www.example.com/example.repo
  
如果在添加这些仓库之后运行 yum repolist 命令,你就可以看到新添加的仓库了。Yes,我看到了。 
注意:每当运行 yum repolist 命令时,该命令会自动从相应的仓库获取更新,并将缓存保存在本地系统中。 
# yum repolist-  
 Loaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfileepel/metalink                                                                                                          | 6.1 kB     00:00* epel: epel.mirror.constant.com* ius: ius.mirror.constant.comius                                                                                                                    | 2.3 kB     00:00repo id                                     repo name                                                                                   statusbase                                        CentOS-6 - Base                                                                              6,706epel                                        Extra Packages for Enterprise Linux 6 - x86_64                                              12,505extras                                      CentOS-6 - Extras                                                                               53ius                                         IUS Community Packages for Enterprise Linux 6 - x86_64                                         390updates                                     CentOS-6 - Updates                                                                           1,255repolist: 20,909
  
                                                (编辑:泰州站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |