配置 yum repo 以仅从我公司的内部网络安装软件包

Configuring yum repo to install packages only from my company internal network

我正在尝试在我的 centos7 机器上配置我的 yum 存储库以仅从我的内部存储库安装软件包。为此,我做了以下更改:

  1. 将所有当前的 repo 配置移动到不同的位置:

    sudo mv /etc/yum.repos.d/*.repo ~/backup_yum_repos/

  2. 在 /etc/yum 下创建一个新文件 Mycompany-internals.repo。repos.d

  3. 添加了以下内容:

[Mycompany-internals]
name=Mycompany-internals
baseurl=http://linux-repo.my-company.com/abc-2021q2-sr/CentOS-$releasever-$basearch/RPMS.all/
baseurl=http://linux-repo.my-company.com/epel/abc-2021q2-sr/epel/epel
baseurl=http://linux-repo.my-company.com/epel/abc-2021q2-sr/epel/epel-debuginfo/
baseurl=http://linux-repo.my-company.com/epel/abc-2021q2-sr/epel/epel-source/
baseurl=https://linux-repo.my-company.com/utilities/avamar/CentOS$releasever/
baseurl=https://linux-repo.my-company.com/utilities/splunk/v8/
baseurl=http://linux-repo.my-company.com/utilities/perforce/perforce
baseurl=http://linux-repo.my-company.com/utilities/docker/docker/
enabled=1
gpgcheck=0


现在,我希望使用上述注册表正常安装 yum。

但是当我 运行 yum install docker (例如)时,它失败并显示错误:

Loaded plugins: changelog, fastestmirror, langpacks, priorities
Loading mirror speeds from cached hostfile
My-company-internal                                                                                                              | 2.5 kB  00:00:00     
My-Company-internal/primary_db                                                                                                   |  42 kB  00:00:00     
No package docker available.
Error: Nothing to do

你的 yum 是哪个版本?,有一个错误,yum 会识别第一个 URL 并忽略其余部分,这已在 yum-3.4.3-159.el7 版本中修复。

您多次使用 baseurl= 语句,这是错误的,下面引用了 yum.conf 手册页:

              baseurl Must be a URL to the directory where the yum repository's `repodata' directory lives. Can be an http://, ftp://  or
              file:// URL. You can specify multiple URLs in one baseurl statement. The best way to do this is like this:
              [repositoryid]
              name=Some name for this repository
              baseurl=url://server1/path/to/repository/
                      url://server2/path/to/repository/
                      url://server3/path/to/repository/

              If  you  list  more than one baseurl= statement in a repository you will find yum will ignore the earlier ones and probably
              act bizarrely. Don't do this, you've been warned.