translated

This commit is contained in:
geekpi 2022-06-08 08:47:34 +08:00
parent 96e83c35ce
commit 464b27f5b2

View File

@ -7,23 +7,23 @@
[#]: publisher: " "
[#]: url: " "
How to Create Local Yum/DNF Repository on RHEL 9
如何在 RHEL 9 上创建本地 Yum/DNF 仓库
======
Hello techies, recently Red Hat has released its latest operating system RHEL 9. RHEL 9 fulfill all the requirements of hybrid cloud. It can be installed on physical server, virtual machine and inside the container image.
你好,技术人员,最近红帽发布了最新的操作系统 RHEL 9RHEL 9 满足了混合云的所有要求。它可以安装在物理服务器、虚拟机和容器镜像中。
When we dont have subscription and want to install packages for doing the POCs then setting up local yum or dnf repository will be handy.
当我们没有订阅的时候,想安装软件包来做 POC那么设置本地的 yum 或 dnf 仓库将是很方便的。
In this guide, we will cover how to create local yum/dnf repository on RHEL 9 using DVD or ISO file step by step.
在本指南中,我们将介绍如何在 RHEL 9 上使用 DVD 或 ISO 文件一步一步地创建本地 yum/dnf 资源库。
Prerequisites for creating local Yum/DNF repository
创建本地 yum/dnf 资源库的先决条件:
* Minimal Install RHEL 9 system
* Sudo User with admin privileges
* RHEL 9 DVD or ISO file
* 最小化安装 RHEL 9 系统
* 具有管理权限的 sudo 用户
* RHEL 9 DVD 或 ISO 文件
### 1 ) Mount RHEL 9 ISO File or DVD
### 1)挂载 RHEL 9 ISO 文件或 DVD
We are assuming RHEL 9 iso file is already copied into the system. Run following mount command to mount ISO file on /opt/repo folder.
我们假设 RHEL 9 iso 文件已经被复制到系统中。运行下面的挂载命令,将 ISO 文件挂载到 /opt/repo 文件夹。
```
$ sudo mkdir /var/repo
@ -32,15 +32,15 @@ $ sudo mount -o loop rhel-baseos-9.0-x86_64-dvd.iso /var/repo/
![Mount-RHEL9-ISO-File-Command][1]
In case of  dvd, run
如果是 dvd运行
```
$ sudo mount /dev/sr0 /var/repo/
```
### 2) Create Repo File in /etc/yum.repos.d/ Directory
### 2)在 “/etc/yum.repos.d/” 目录中创建仓库文件
Create a repo file with name rhel9-local.repo under the folder /etc/yum.repos.d/ with following content
在 /etc/yum.repos.d/ 目录下创建一个名为 “rhel9-local.repo” 的仓库文件,内容如下:
```
$ sudo vi /etc/yum.repos.d/rhel9-local.repo
@ -61,13 +61,13 @@ baseurl=file:///var/repo//AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
```
Save and close the file.
保存并关闭该文件。
![RHEL8-Local-Repo-File][2]
### 3) Flush Yum/DNF & Subscription Manager Cache
### 3)刷新 yum/dnf 和订阅管理器的缓存
Execute following commands to clean yum or dnf and subscription manager cache.
执行以下命令来清理 yum 或 dnf 和订阅管理器的缓存。
```
$ sudo dnf clean all
@ -76,7 +76,7 @@ $ sudo subscription-manager clean
![DNF-Subscription-Manager-Clean][3]
In the above output, we are getting a warning message This system is not registered with an entitlement. So, to suppress this warning message, edit the file  /etc/yum/pluginconf.d/subscription-manager.conf , change the parameter enabled=1 to enabled=0.
在上面的输出中,我们得到一个警告信息 “This system is not registered with an entitlement”系统没有注册权限。所以为了抑制这个警告信息编辑文件 “/etc/yum/pluginconf.d/subscription-manager.conf”将参数 “enabled=1” 改为 “enabled=0”。
```
$ sudo vi /etc/yum/pluginconf.d/subscription-manager.conf
@ -84,35 +84,35 @@ $ sudo vi /etc/yum/pluginconf.d/subscription-manager.conf
![Disable-Subscription-Parameter-RHEL-9][4]
Save and exit the file.
保存并退出该文件。
### 4) Install Packages using Local Repository
### 4)使用本地仓库安装软件包
Now we are all set to test our local repository. Run beneath command to view configure repository.
现在我们都准备好测试我们的本地仓库了。运行下面的命令来查看配置仓库。
```
$ sudo dnf repolist
```
Output,
输出:
![DNF-Repolist-RHEL-9][5]
Now, try Install packages using dnf command via above configure local repository.
现在,试试用 dnf 命令通过上面配置的本地仓库安装软件包。
```
$ sudo dnf install nfs-utils
```
Output,
输出:
![Install-RPM-Package-via-local-repo-rhel9][6]
![Package-Installation-Completion-RHEL9-DNF-Command][7]
Perfect, above output confirms that nfs-utils package along with its dependencies are installed successfully via locally configured yum or dnf repository.
完美,上述输出证实了 nfs-utils 包及其依赖项已经通过本地配置的 yum 或 dnf 仓库成功安装。
Thats all from this guide. I hope you have found it informative. Kindly do post your queries and feedback in below comments section.
这就是本指南的全部内容。我希望你觉得它有参考价值。请在下面的评论区发表你的疑问和反馈。
--------------------------------------------------------------------------------
@ -120,7 +120,7 @@ via: https://www.linuxtechi.com/create-local-yum-dnf-repository-rhel/
作者:[Pradeep Kumar][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出