一.下载并安装wget curl vim工具
yum -y install wget curl vim
二.备份原repo文件
tar -zcf repo.tar.gz *.repo rm -rf *.repo
三.配置yum仓库源
1.通过wget等命令下载repo文件 1.1 配置网易base源: wget -c -P /etc/yum.repos.d/ http://mirrors.163.com/.help/CentOS7-Base-163.repo
1.2 配置阿里base源: wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
2.手动配置仓库源 2.1 配置nginx仓库
[root@local yum.repos.d]
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
2.2 配置本地仓库
mount /dev/cdrom /mnt
[root@local yum.repos.d]
[local]
name=centos 7 local repo
baseurl=file:///mnt
gpgcheck=0
gpgkey=file:///mnt/RPM-GPG-KEY-CentOS-7
enabled=1
2.3 配置清华base源
[root@local yum.repos.d]
[tsinghua]
name=centos 7 tsinghua repo
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7
enabled=1
3.通过yum-config-manager命令自动配置仓库
yum -y install yum-utils
[root@local yum.repos.d]
Loaded plugins: fastestmirror
adding repo from: http://mirrors.163.com/.help/CentOS7-Base-163.repo
grabbing file http://mirrors.163.com/.help/CentOS7-Base-163.repo to /etc/yum.repos.d/CentOS7-Base-163.repo
repo saved to /etc/yum.repos.d/CentOS7-Base-163.repo
[root@zw yum.repos.d]
Loaded plugins: fastestmirror
adding repo from: https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/
[mirrors.tuna.tsinghua.edu.cn_centos_7_os_x86_64_]
name=added from: https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/
enabled=1
[root@zw yum.repos.d]
> gpgcheck=1
> gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7
> E
[root@zw yum.repos.d]
[mirrors.tuna.tsinghua.edu.cn_centos_7_os_x86_64_]
name=added from: https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7
四、清除原来的缓存,建立新的缓存
清除缓存 yum clean all 建立缓存 yun makecache 显示所有仓库 yum repolist
|