4.创建新的repo文件
[base]
name=CentOS-7 - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7 - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7 - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
5.使用yum makecache刷新生成缓存
[root@linuxidc ~]# yum makecache
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/12): base/x86_64/group_gz | 166 kB 00:00:06
(2/12): base/x86_64/primary_db | 5.9 MB 00:00:02
(3/12): base/x86_64/filelists_db | 6.9 MB 00:00:08
(4/12): base/x86_64/other_db | 2.5 MB 00:00:01
(5/12): extras/x86_64/prestodelta | 68 kB 00:00:06
(6/12): extras/x86_64/primary_db | 173 kB 00:00:00
(7/12): extras/x86_64/other_db | 110 kB 00:00:00
(8/12): extras/x86_64/filelists_db | 588 kB 00:00:06
(9/12): updates/x86_64/prestodelta | 409 kB 00:00:06
(10/12): updates/x86_64/filelists_db | 2.4 MB 00:00:07
(11/12): updates/x86_64/other_db | 381 kB 00:00:00
(12/12): updates/x86_64/primary_db | 4.3 MB 00:00:01
Metadata Cache Created
6.epel扩展源
首先从CentOS Extras这个源(tuna也有镜像)里安装epel-release:
yum install epel-release -y