Linux配置本地YUM源(RHEL8)

【RHEL8.1】

Linux—RHEL8配置本地YUM 源,按照之前传统的配置本地YUM的方法肯定不行,在RHEL8版本的软件源发生了变化,在RHEL8版本的软件仓库分成了两部分:【AppStream】和【BaseOS】,所以我们在配置YUM 源的适合需要配置连个部分;具体来看操作吧!

1、开启RHEL8的虚拟机

[root@localhost ~]# cat /etc/system-release

Red Hat Enterprise Linux release 8.1 (Ootpa)

 //首先确认一下,自己装的是RHEL8系统

2、确认自己的镜像是否连接

 3、将本地的镜像源挂载到 /mnt上(/mnt是系统的临时挂载目录)

[root@localhost ~]# mount /dev/sr0 /mnt/

mount: /mnt: WARNING: device write-protected, mounted read-only.

[root@localhost ~]# df -h

文件系统               容量  已用  可用 已用% 挂载点
devtmpfs               966M     0  966M    0% /dev
tmpfs                  983M     0  983M    0% /dev/shm
tmpfs                  983M  8.7M  974M    1% /run
tmpfs                  983M     0  983M    0% /sys/fs/cgroup
/dev/mapper/rhel-root   50G  2.0G   49G    4% /
/dev/nvme0n1p1        1014M  156M  859M   16% /boot
/dev/mapper/rhel-home   67G  511M   67G    1% /home
tmpfs                  197M     0  197M    0% /run/user/0
/dev/sr0               7.4G  7.4G     0  100% /mnt
 //出现最后一行的信息,说明已经挂载成功

4、在 /etc/fstab 文件写入开机自动挂载

[root@localhost ~]# echo '/dev/sr0 /mnt iso9660 defaults 0 0' >> /etc/fstab 
[root@localhost ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Tue Jul 28 00:28:19 2020
#
# 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=a9a8d47d-f331-4287-9d14-c9bb5598c1a4 /boot                   xfs     defaults        0 0
/dev/mapper/rhel-home   /home                   xfs     defaults        0 0
/dev/mapper/rhel-swap   swap                    swap    defaults        0 0
/dev/sr0 /mnt iso9660 defaults 0 0
 //最后一行就是刚刚写入的开机自动挂载命令
 

5、编辑本地软件仓库源

[root@localhost ~]# ls /mnt/

AppStream  BaseOS  EFI  EULA  extra_files.json  GPL  images  isolinux  media.repo  RPM-GPG-KEY-redhat-beta  RPM-GPG-KEY-redhat-release  TRANS.TBL

 //刚刚将RHEL8的镜像挂载到/mnt下,现在就回看到里面有AppStream和BaseOS这两个目录

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vim dvd.repo 
[root@localhost yum.repos.d]# cat dvd.repo 

[BaseOS]

name=BaseOS

baseurl=file:///mnt/BaseOS

gpgcheck=0

enbaled=1

[AppStream]

name=AppStream

baseurl=file:///mnt/AppStream

gpgcheck=0

enabled=1

 //file:后面的文件名一定要跟/mnt下面的文件名一样

6、清理缓存、建立元数据

[root@localhost yum.repos.d]# 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.

12 文件已删除


[root@localhost yum.repos.d]# 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.

BaseOS                                                                                                                                                       62 MB/s | 2.2 MB     00:00   

AppStream                                                                                                                                                    88 MB/s | 5.6 MB     00:00   

上次元数据过期检查:0:00:01 前,执行于 2020年07月28日 星期二 15时25分49秒。

元数据缓存已建立。

7、查看仓库

[root@localhost yum.repos.d]# 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.

上次元数据过期检查:0:00:59 前,执行于 2020年07月28日 星期二 15时25分49秒。

仓库标识                                                                                仓库名称                                                                                 状态

AppStream                                                                               AppStream                                                                                启用: 4,820

BaseOS                                                                                  BaseOS                                                                                   启用: 1,661

8、RHEL8版本,安装软件可以用YUM,也可以用dnf (注:yum 是 dnf 的一个软连接,yum和 dnf 在RHEL8中都可以使用)

yum install -y 软件包名

dnf install -y 软件包名

yum remove -y 软件包名

dnf remove -y 软件包名

yum update -y 软件包名

dnf update -y 软件包名

  • 4
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值