centos8实现光盘本地yum仓

实现光盘本地yum仓需要配一个服务端和一个客户端

[root@centos8 ~]# df   #查看光盘是否挂载
Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs          910180       0    910180   0% /dev
tmpfs             924716       0    924716   0% /dev/shm
tmpfs             924716   18132    906584   2% /run
tmpfs             924716       0    924716   0% /sys/fs/cgroup
/dev/nvme0n1p2 104806400 4636776 100169624   5% /
/dev/nvme0n1p3  52403200  398576  52004624   1% /data
/dev/nvme0n1p1    999320  131444    799064  15% /boot
tmpfs             184940      20    184920   1% /run/user/42
tmpfs             184940    3496    181444   2% /run/user/0
/dev/sr0         6967726 6967726         0 100% /run/media/root/CentOS-8-BaseOS-x86_64    #光盘已挂载

[root@centos8 ~]# cd /etc/yum.repos.d/    #yum的客户端配置文件
[root@centos8 yum.repos.d]# ls
CentOS-AppStream.repo   CentOS-Debuginfo.repo  CentOS-PowerTools.repo
CentOS-Base.repo        CentOS-Extras.repo     CentOS-Sources.repo
CentOS-centosplus.repo  CentOS-fasttrack.repo  CentOS-Vault.repo
CentOS-CR.repo          CentOS-Media.repo

[root@centos8 yum.repos.d]# cat CentOS-Base.repo    
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[BaseOS]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/   #这里指向的都是互联网的链接
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[root@centos8 yum.repos.d]# mkdir bak
[root@centos8 yum.repos.d]# mv *.repo bak  #把多余的配置文件移走做备份
[root@centos8 yum.repos.d]# ls
bak
[root@centos8 yum.repos.d]# pwd
/etc/yum.repos.d
#光盘不能直接当yum源必须找到repodata元数据的所在目录  centos8有两个仓
[root@centos8 yum.repos.d]# ls /run/media/root/CentOS-8-BaseOS-x86_64  
AppStream  BaseOS  EFI  images  isolinux  media.repo  TRANS.TBL
[root@centos8 yum.repos.d]# ls /run/media/root/CentOS-8-BaseOS-x86_64/AppStream
Packages  repodata
[root@centos8 yum.repos.d]#  ls /run/media/root/CentOS-8-BaseOS-x86_64/BaseOS
Packages  repodata
[root@centos8 yum.repos.d]# vim test.repo  #文件名后缀必须是repo
[BaseOS]     #仓库标记
name=cdrom BaseOS  
baseurl=file:///run/media/root/CentOS-8-BaseOS-x86_64/BaseOS   #本地yum源对应的路径
gpgcheck=0  #不检查key
enable=1    #不禁用 默认为1  0为禁用

[Appstream]
name=cdrom Appstream
baseurl=file:///run/media/root/CentOS-8-BaseOS-x86_64/AppStream
gpgcheck=0
enable=1

[root@centos8 yum.repos.d]#  yum repolist  #检测本地源是否成功
Last metadata expiration check: 0:18:59 ago on Mon 16 Mar 2020 03:26:41 PM CST.
repo id                           repo name                                status
Appstream                         cdrom Appstream                          4,681
BaseOS                            cdrom BaseOS                             1,655


[root@centos8 ~]# dnf install gcc   #安装gcc 本地yum可以使用
在这里插入代码片

你可能感兴趣的:(linux)