CentOS7系统配置国内yum源和epel源

CentOS7系统配置国内yum源和epel源

CentOS默认yum源是国外的, 速度无法保证,用起来很不爽,今天我们把默认源换成国内的163源,163是目前国内最好用的源,速度是相当快的,还有一些比较好的源,比如阿里源。

 

安装yum源

首先我们把CentOS7配置为可以上外网的环境

 

安装wget

  -bash: wget: command not found

  yum -y install wget

 

进入yum源配置文件   cd /etc/yum.repos.d

 

备份一下当前的源,以防出错后可以还原回来

  mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

 

下载阿里或网易源  

  wget http://mirrors.aliyun.com/repo/Centos-7.repo 

  或者

  curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

 

  wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

 

CentOS 5

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

CentOS 6

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

CentOS 7

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

  或者手动下载repo文件并上传到/etc/yum.repos.d/目录

网易开源镜像站

阿里开源镜像站

 

把下载下来文件 Centos-7或CentOS7-Base-163.repo设置成为默认源

  mv Centos-7.repo CentOS-Base.repo

  mv CentOS7-Base-163.repo CentOS-Base.repo

 

清理一下旧包

  yum clean all    #清除系统所有的yum缓存

 

生成缓存即可用源

  yum makecache  # 生成yum缓存

 

发到各节点
scp CentOS-Base.repo master1:/etc/yum.repos.d/

 

安装epel源

# yum list | grep epel-release

# yum install -y epel-release

# ls

# epel源安装成功,比原来多了一个epel.repo和epel-testing.repo文件

 

 

使用阿里开源镜像提供的epel源

#下载阿里开源镜像的epel源文件

# wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo   

# 下载网易开源镜像的epel源文件

# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo 

 

再次清除系统yum缓存,并重新生成新的yum缓存

# yum clean all

# yum makecache

 

 

查看系统可用的yum源和所有的yum源

# yum repolist enabled

# yum repolist all

 

posted on 2019-09-21 15:52  <Hbw>  阅读(1077)  评论(0编辑  收藏  举报