Redhat 8.6(已注册)开启其他仓库

列出所有可用仓库

首先,使用 subscription-manager repos --list​ 命令列出所有可用的仓库,包括已启用和未启用的。这将给你一个完整的仓库列表及其状态。

sudo subscription-manager repos --list

image-20240227180916-y3qjn9t.png

对于 RHEL 8 服务器:

$ sudo subscription-manager repos --enable=rhel-8-for-x86_64-highavailability-rpms

使用 subscription-manager 启用仓库

如果你已经下载了仓库配置文件,你可以使用 subscription-manager 命令来启用它。例如

sudo subscription-manager repos --enable=rhel-8-for-x86_64-highavailability-rpms
请注意,仓库的确切名称可能会有所不同,你需要使用正确的仓库 ID 或名称。

image-20240227180822-0y7ez0l.png

验证仓库是否已启用

再次运行 subscription-manager repos --list-enabled​ 来验证 HighAvailability​ 仓库是否已出现在已启用的仓库列表中。

image-20240227180951-zauq4s0.png

安装其他仓库

PowerTools

CentOS和RHEL实际上是不同的,尽管其中一个是另一个的“克隆”。所讨论的存储库的规范名称在redhat下实际上是CodeReady Linux。因此,在CentOS中它有一个不同的名称PowerTools。

由于您使用的是RHEL,您应该启用CodeReady Linux存储库:

subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms

查看是否开启

image-20240227182038-93ow7zv.png

同步整个仓库到本地

安装 RepoSync
RepoSync 是包含在 yum-utils​ 包中的,因此首先您需要安装 yum-utils​ 包。在 RHEL 系统中,您可以使用以下命令来安装:

sudo yum install -y yum-utils

确定 YUM 仓库
使用 yum repolist​ 命令来查看系统中已配置的 YUM 仓库及其 ID。

yum repolist

对于 RHEL 8 或类似的系统,如果您想要下载特定仓库中的所有软件包,您应该使用 dnf download​ 命令,如下所示:

dnf download --repoid=codeready-builder-for-rhel-8-x86_64-rpms --destdir=/root/codeready/

这里的 --repoid​ 参数是用来指定仓库 ID 的,--destdir​ 参数用来指定下载的目标目录。

如果您确实想要使用 reposync​,并且您的系统安装了 yum-utils​ 包,那么您应该使用以下命令:

reposync --repoid=codeready-builder-for-rhel-8-x86_64-rpms --destdir=/root/codeready/

请确保 codeready-builder-for-rhel-8-x86_64-rpms​ 是实际存在的仓库 ID,并且您有足够的权限在 /root/codeready/​ 目录下写入文件。

后台下载

使用 nohup &在后台运行 reposync​:
使用 nohup​ 命令可以在您退出 shell 会话后继续运行程序。&​ 符号用于将命令放到后台执行

使用 nohup​ 运行命令会在当前用户的家目录中创建一个名为 nohup.out​ 的文件,用于保存程序的输出。如果下载过程中产生大量输出,这可能会填满磁盘空间。您可以将输出重定向到一个特定的文件,以避免这个问题:

nohup reposync --repoid=codeready-builder-for-rhel-8-x86_64-rpms --destdir=/root/codeready/ > /root/codeready/reposync.log 2>&1 &

在这个例子中,输出被重定向到了 /root/codeready/reposync.log​ 文件。

  1. 查看后台任务
    您可以使用 jobs​ 命令来查看在后台运行的任务。但是因为您使用了 nohup​,这个任务不会出现在 jobs​ 的列表中。不过,您可以在服务器上使用 ps​ 命令来查看它。

    ps -ef | grep reposync
    

    这条命令将显示所有包含 reposync​ 的进程,您应该能够看到您的 reposync​ 命令正在运行。

  2. 关闭 SSH 会话
    一旦您确认 reposync​ 正在后台运行,您可以安全地关闭 SSH 会话。

    exit
    
  3. 检查下载进度
    即使 SSH 会话已经关闭,您仍然可以通过 SSH 重新连接到服务器,并使用适当的命令来检查 reposync​ 的下载进度。例如,您可以查看 /root/codeready/​ 目录下的文件来确定下载是否仍在进行。

启动epel仓库https://docs.fedoraproject.org/en-US/epel/

subscription-manager repos --enable codeready-builder-for-rhel-8-$(arch)-rpms
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

image-20240228120239-n6n9no9.png
nohup reposync --repoid=rhel-8-for-x86_64-highavailability-rpmss --destdir=/root/ha/ > /root/ha/reposync.log 2>&1 &

nohup reposync --repoid=rhel-8-for-x86_64-appstream-rpms --destdir=/root/appstream/ > /root/appstream/reposync.log 2>&1 &