虚拟机 RHEL8 配置软件仓库

1. 进入 /etc/yum.repos.d/ 目录中,并创建rhel8.repo文件,使用vim可直接创建并打开编辑文件

文件名称可随意,但后缀必须为 .repo

[root@rhel8 ~]# cd /etc/yum.repos.d/
[root@rhel8 yum.repos.d]# vim rhel8.repo

2. 打开rhel8.repo文件后,输入如下内容保存退出 (“仓库名称”那一部分为扩展知识

[BaseOS]
name=BaseOS
baseurl=file:///mnt/cdrom/BaseOS     #注释:/mnt/cdrom为镜像文件挂载目录,此目录也可为其他目录
enabled=1
gpgcheck=0

[AppStream]
name=AppStream
baseurl=file:///mnt/cdrom/AppStream  #注释:/mnt/cdrom为镜像文件挂载目录,此目录也可为其他目录
enabled=1
gpgcheck=0
仓库名称:具有唯一性的标识名称,不应与其他软件仓库发生冲突。

描述信息(name):可以是一些介绍性的词,易于识别软件仓库的用处。

仓库位置(baseurl):软件包的获取方式,可以使用FTP或HTTP下载,也可以是本地的文件(需要在后面添加file参数)。

是否启用(enabled):设置此源是否可用;1为可用,0为禁用。

是否校验(gpgcheck):设置此源是否校验文件;1为校验,0为不校验。

公钥位置(gpgkey):若上面的参数开启了校验功能,则此处为公钥文件位置。若没有开启,则省略不写。

3. 创建一个给镜像文件挂载的目录,

 (这里是选择挂载到/mnt/cdrom,大家也可创建其他目录进行挂载

[root@rhel8 yum.repos.d]# mkdir -p /mnt/cdrom

4. 查看当前系统挂载情况,查找镜像文件的 filesystem 名称,我这里的是 /dev/sr0

 (零不是字母O

[root@rhel8 ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/sr0               6.7G  6.7G     0 100% /run/media/root/RHEL-8-0-0-BaseOS-x86_64

5. 将 /dev/sr0 挂载到上面创建好的挂载目录下面

[root@rhel8 mnt]# mount /dev/sr0 /mnt/cdrom
mount: /mnt/cdrom: WARNING: device write-protected, mounted read-only.

6. 挂载好后,将挂载信息写入到 /etc/fstab 中实现永久挂载,

    挂载对象是镜像文件,格式为iso9660

[root@rhel8 mnt]# vim /etc/fstab


#
# /etc/fstab
# Created by anaconda on Tue Feb 22 07:44:26 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rhel-root   /                       xfs     defaults        0 0
UUID=a16afe73-176d-4b4e-8c4c-6a7c676ebc15 /boot                   xfs     defaults        0 0
/dev/mapper/rhel-home   /home                   xfs     defaults        0 0
/dev/mapper/rhel-swap   swap                    swap    defaults        0 0
/dev/sda1               /mnt/sda1               xfs     defaults        0 0 

/dev/sr0                /mnt/cdrom              iso9660 defaults        0 0

 7.执行这三个命令yum clean all ,yum makecache, yum repolist all,激活配置

[root@rhel8 mnt]# yum clean all
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
0 files removed

[root@rhel8 mnt]# yum makecache
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
AppStream                                                                                     131 MB/s | 5.3 MB     00:00    
BaseOS                                                                                        119 MB/s | 2.2 MB     00:00    
Metadata cache created.

[root@rhel8 mnt]# yum repolist all
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:02:37 ago on Sun 27 Feb 2022 02:23:11 PM CST.
repo id                                                 repo name                                               status
AppStream                                               AppStream                                               enabled: 4,672
BaseOS                                                  BaseOS                                                  enabled: 1,658

8. 使用 yum 或 dnf 命令来安装Web服务,软件包名称为 httpd 来验证下,

最后出现 Complete! 代表配置正确

[root@rhel8 mnt]# dnf install -y httpd
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:14:04 ago on Sun 27 Feb 2022 02:23:11 PM CST.
Dependencies resolved.
==============================================================================================================================
 Package                        Arch               Version                                        Repository             Size
==============================================================================================================================
Installing:
 httpd                          x86_64             2.4.37-10.module+el8+2764+7127e69e             AppStream             1.4 M
Installing dependencies:
 apr                            x86_64             1.6.3-9.el8                                    AppStream             125 k
 apr-util                       x86_64             1.6.1-6.el8                                    AppStream             105 k
 httpd-filesystem               noarch             2.4.37-10.module+el8+2764+7127e69e             AppStream              34 k
 httpd-tools                    x86_64             2.4.37-10.module+el8+2764+7127e69e             AppStream             101 k
 mod_http2                      x86_64             1.11.3-1.module+el8+2443+605475b7              AppStream             156 k
 redhat-logos-httpd             noarch             80.7-1.el8                                     BaseOS                 25 k
Installing weak dependencies:
 apr-util-bdb                   x86_64             1.6.1-6.el8                                    AppStream              25 k
 apr-util-openssl               x86_64             1.6.1-6.el8                                    AppStream              27 k

Transaction Summary
==============================================================================================================================
Install  9 Packages

Total size: 2.0 M
Installed size: 5.4 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                      1/1 
  Installing       : apr-1.6.3-9.el8.x86_64                                                                               1/9 
  Running scriptlet: apr-1.6.3-9.el8.x86_64                                                                               1/9 
  Installing       : apr-util-bdb-1.6.1-6.el8.x86_64                                                                      2/9 
  Installing       : apr-util-openssl-1.6.1-6.el8.x86_64                                                                  3/9 
  Installing       : apr-util-1.6.1-6.el8.x86_64                                                                          4/9 
  Running scriptlet: apr-util-1.6.1-6.el8.x86_64                                                                          4/9 
  Installing       : httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86_64                                                5/9 
  Installing       : redhat-logos-httpd-80.7-1.el8.noarch                                                                 6/9 
  Running scriptlet: httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch                                           7/9 
  Installing       : httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch                                           7/9 
  Installing       : mod_http2-1.11.3-1.module+el8+2443+605475b7.x86_64                                                   8/9 
  Installing       : httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64                                                      9/9 
  Running scriptlet: httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64                                                      9/9 
  Verifying        : apr-1.6.3-9.el8.x86_64                                                                               1/9 
  Verifying        : apr-util-1.6.1-6.el8.x86_64                                                                          2/9 
  Verifying        : apr-util-bdb-1.6.1-6.el8.x86_64                                                                      3/9 
  Verifying        : apr-util-openssl-1.6.1-6.el8.x86_64                                                                  4/9 
  Verifying        : httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64                                                      5/9 
  Verifying        : httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch                                           6/9 
  Verifying        : httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86_64                                                7/9 
  Verifying        : mod_http2-1.11.3-1.module+el8+2443+605475b7.x86_64                                                   8/9 
  Verifying        : redhat-logos-httpd-80.7-1.el8.noarch                                                                 9/9 
Installed products updated.

Installed:
  httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64             apr-util-bdb-1.6.1-6.el8.x86_64                                 
  apr-util-openssl-1.6.1-6.el8.x86_64                         apr-1.6.3-9.el8.x86_64                                          
  apr-util-1.6.1-6.el8.x86_64                                 httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch      
  httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86_64       mod_http2-1.11.3-1.module+el8+2443+605475b7.x86_64              
  redhat-logos-httpd-80.7-1.el8.noarch                       

Complete!

  • 5
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值