### 1.配置网络源
```
[root@centos7 ~]#cd /etc/yum.repos.d
[root@centos7 /etc/yum.repos.d]#mkdir bakrepo
[root@centos7 /etc/yum.repos.d]#mv * bakrepo
[root@centos7 /etc/yum.repos.d]#wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者执行
[root@centos7 /etc/yum.repos.d]#curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@centos7 /etc/yum.repos.d]#ls
bakrepo CentOS-Base.repo
[root@centos7 /etc/yum.repos.d]#yum repolist
已加载插件:fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
源标识 源名称 状态
!base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
!extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 518
!updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 5,061
repolist: 15,651
```
### 2.配置本地仓库yum源仓库
```
[root@centos7 ~]#cd /etc/yum.repos.d
[root@centos7 /etc/yum.repos.d]#vim local.repo
[localrepo]
name=local repo
baseurl=file:///iso
enabled=1
gpgcheck=0
[root@centos7 /etc/yum.repos.d]#cat local.repo
[localrepo]
name=local repo
baseurl=file:///iso
enabled=1
gpgcheck=0
[root@centos7 ~]#mkdir /iso
VMware挂载光盘 介质
[root@centos7 ~]#mount /dev/sr0 /iso
[root@centos7 ~]#df -h | grep iso
[root@centos7 ~]#vim /etc/fstab
/dev/sr0 /iso iso9660 defaults 0 0
[root@centos7 ~]#mount -a
```
### 3.配置阿里云仓库源
```
[root@centos7 ~]#cd /etc/yum.repos.d/
[root@centos7 /etc/yum.repos.d]#ls
bakrepo local.repo
[root@centos7 /etc/yum.repos.d]#cat net.repo
[aliyun]
name=阿里云仓库源
baseurl=https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/
enabled=1
gpgcheck=0
[root@centos7 /etc/yum.repos.d]#yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
aliyun | 3.6 kB 00:00:00
(1/2): aliyun/group_gz | 153 kB 00:00:00
(2/2): aliyun/primary_db | 6.1 MB 00:00:14
源标识 源名称 状态
aliyun 阿里云仓库源 10,072
localrepo local repo 4,070
repolist: 14,142
```
### 4.配置扩展源
```
[root@centos7 /etc/yum.repos.d]#cat epel.repo
[epel]
name=扩展源
baseurl=https://mirrors.aliyun.com/epel/7/x86_64/
enabled=1
gpgcheck=0
[root@centos7 /etc/yum.repos.d]#yum repolist
[root@centos7 /etc/yum.repos.d]#yum install sl
```