Centos挂载yum源
1、查看centos安装后的yum源
[root@localhost ~]# ll /etc/yum.repos.d/
2、把默认Yum源备份(可选)
[root@localhost ~]# mkdir /opt/centos-yum.bak
[root@localhost ~]# mv /etc/yum.repos.d/* /opt/centos-yum.bak/
3、将iso镜像上传到虚机上放到该目录下
[root@localhost ~]#mkdir /mnt/iso
4、然后挂载:
[root@localhost ~]#mkdir /mnt/cdrom
[root@localhost ~]# mount -t iso9660 /mnt/iso/CentOS-7-x86_64-DVD-2207-02.iso /mnt/cdrom
5、编写repo文件并指向镜像的挂载目录
[root@localhost ~]#vi /etc/yum.repos.d/local.repo
6、添加下面的内容:
[local]
name=local
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=0
7、清除缓存
[root@localhost ~]#yum clean all
[root@localhost ~]#yum makecache //把Yum源缓存到本地,加快软件的搜索好安装速度
[root@localhost ~]#yum list // 列出了yum包
8、查看yum仓库列表
[root@localhost ~]#yum repolist