替换默认源
替换源:
默认的源是国外的源,国外的源有可能打开比较慢有可能打不开所以要替换源。
国内很多厂商做了镜像我们现在使用163的源。
/.help/centos.html
1.首先备份repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.查看到备份的repo
cd /etc/yum.repos.d/ll
3.安装CentOS 7 下载对应版本的 repo 放入到 /etc/yum.repos.d/CentOS-Base.repo
curl /.help/CentOS7-Base-163.repo -o CentOS7-Base-163.repo
4.运行下面命令生成缓存
yum clean all yum makecache
5.测试
yum -y update
修改yum源为阿里
1. 备份本地yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
2.获取阿里yum源配置文件
配置文件地址:https://mirrors.tuna./help/centos/
将以下内容写入 /etc/yum.repos.d/CentOS-Base.repo
配置文件内容如下:
# CentOS-Base.repo## The mirror system uses the connecting IP address of the client and the# update status of each mirror to pick mirrors that are updated to and# geographically close to the client. You should use this for CentOS updates# unless you are manually picking other mirrors.## If the mirrorlist= does not work for you, as a fall back you can try the# remarked out baseurl= line instead.##[base]name=CentOS-$releasever - Basebaseurl=https://mirrors.tuna./centos/$releasever/os/$basearch/#mirrorlist=/?release=$releasever&arch=$basearch&repo=osgpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#released updates[updates]name=CentOS-$releasever - Updatesbaseurl=https://mirrors.tuna./centos/$releasever/updates/$basearch/#mirrorlist=/?release=$releasever&arch=$basearch&repo=updatesgpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#additional packages that may be useful[extras]name=CentOS-$releasever - Extrasbaseurl=https://mirrors.tuna./centos/$releasever/extras/$basearch/#mirrorlist=/?release=$releasever&arch=$basearch&repo=extrasgpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#additional packages that extend functionality of existing packages[centosplus]name=CentOS-$releasever - Plusbaseurl=https://mirrors.tuna./centos/$releasever/centosplus/$basearch/#mirrorlist=/?release=$releasever&arch=$basearch&repo=centosplusgpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
3.更新cache
yum clean allyum makecache
4.测试
yum -y update