常用的镜像源有如:
- 163镜像源:http://mirrors.163.com/
- 阿里镜像源:https://opsx.alibaba.com/mirror
- 清华镜像源:https://mirrors.tuna.tsinghua.edu.cn/
安装公网yum源(安装163镜像源)
-
确定liunx有wget(一般迷你版的Centos没有wget需要手动下载)
# yum -y install wget
-
备份yum源(如果镜像源用不了可以删除使用自带的yum源)
# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
-
下载对应的版本的yum源到/etc/yum.repo/目录下
centos6版本如下:# cd /etc/yum.repo # wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
centos7版本如下:
# cd /etc/yum.repo # wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
-
清空缓存,创建yum仓库
# yum clean all #清空yum缓存 # yum makecache #构建元数据
搞定!