修改 centos 源为清华源
<p>首先备份 CentOS-Base.repo</p><div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;">sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak</pre>
</div>
<p> </p>
<p>使用 su 进入 root 用户,再执行</p>
<div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;">vim /etc/yum.repos.d/CentOS-Base.repo
</pre>
</div>
<p> </p>
<p>向 CentOS-Base.repo 添加下面代码</p>
<div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;"># 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.
#
#
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&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
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
</pre>
</div>
<p> </p>
<p>最后执行下面命令更新缓存,这里需要联网</p>
<div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;">sudo yum makecache</pre>
</div><br><br>
来源:https://www.cnblogs.com/cqkitcode/p/12652846.html
頁:
[1]