Linux_配置本地YUM源(RHEL8)


【RHEL8】

Linux—RHEL8配置本地YUM 源,按照之前傳統的配置本地YUM的方法肯定不行,在RHEL8版本的軟件源發生了變化,在RHEL8版本的軟件倉庫分成了兩部分:【AppStream】和【BaseOS】,所以我們在配置YUM 源的適合需要配置連個部分;具體來看操作吧!

一、配置RHEL8本地源

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
enabled=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 軟件包名

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM