CentOS7安装初始默认没有任何yum 源,以挂载本地DVD到/mnt/cdrom,将系统yum源连接到/mnt/cdrom为例。
# 用yum-config-manager生成一个源文件模版
[root@server0 yum.repos.d]# yum-config-manager --add-repo=cdrom
Loaded plugins: langpacks, product-id
adding repo from: cdrom
[cdrom]
name=added from: cdrom
baseurl=cdrom
enabled=1
# 将生成的模版编辑如下
[root@server0 yum.repos.d]# cat cdrom.repo
[cdrom]
name=DVD Media
baseurl=file:///mnt/cdrom
enabled=1
# 挂载CDROM
[root@server0 yum.repos.d]# mount /dev/cdrom /mnt/cdrom/
mount: /dev/sr0 is write-protected, mounting read-only
# 导入RPM-GPG-KEY
[root@server0 yum.repos.d]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-xxxx
# 查看
[root@server0 ~]# yum repolist
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id repo name status
cdrom DVD Media 4,305
repolist: 4,305