1.查看yum源的配置文件
[root@mysql1 ~]# cd /etc/yum.repos.d/
[root@mysql1 yum.repos.d]# ll
total 36
-rw-r–r--. 1 root root 1664 Dec 9 2015 CentOS-Base.repo
-rw-r–r--. 1 root root 1309 Dec 9 2015 CentOS-CR.repo
-rw-r–r--. 1 root root 649 Dec 9 2015 CentOS-Debuginfo.repo
-rw-r–r--. 1 root root 290 Dec 9 2015 CentOS-fasttrack.repo
-rw-r–r--. 1 root root 630 Dec 9 2015 CentOS-Media.repo
-rw-r–r--. 1 root root 1331 Dec 9 2015 CentOS-Sources.repo
-rw-r–r--. 1 root root 1952 Dec 9 2015 CentOS-Vault.repo
-rw-r–r--. 1 root root 951 Oct 2 2017 epel.repo
-rw-r–r--. 1 root root 1050 Oct 2 2017 epel-testing.repo
2.清空yum源的配置文件
**[root@mysql1 yum.repos.d]#**rm -rf ***
[root@mysql1 yum.repos.d]# ll
total 0
3.配置yum源的配置文件
[root@mysql1 yum.repos.d]# vi local.repo
[root@mysql1 yum.repos.d]# cat local.repo
[centos]
name=centos
baseurl=file:///opt/centos(配置对应本地文件)
gpgcheck=0
enabled=1
[root@mysql1 yum.repos.d]# ll
total 4
-rw-r–r--. 1 root root 69 Mar 25 15:01 local.repo
4.创建目录并挂载目录
[root@mysql1 yum.repos.d]# cd
[root@mysql1 ~]# mkdir /opt/centos
[root@mysql1 ~]# mount CentOS-7-x86_64-DVD-1511.iso /opt/centos
mount: /dev/loop0 is write-protected, mounting read-only
5.查看当前可用yum源
[root@mysql1 ~]# yum repolist
Loaded plugins: fastestmirror
centos | 3.6 kB 00:00
(1/2): centos/group_gz | 155 kB 00:00
(2/2): centos/primary_db | 2.8 MB 00:00
Loading mirror speeds from cached hostfile
repo id repo name status
centos centos 3,723
repolist: 3,723