探花小李 發表於 2019-8-11 12:55:00

CentOS yum 源修改

<h2 id="修改-centos-默认-yum-源为-mirrors163com">修改 CentOS 默认 yum 源为 mirrors.163.com</h2>
<ol>
<li>首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo</li>
</ol>
<pre><code class="language-shell"># mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
</code></pre>
<ol start="2">
<li>进入yum源配置文件所在的文件夹</li>
</ol>
<pre><code class="language-shell"># cd /etc/yum.repos.d/
</code></pre>
<ol start="3">
<li>下载163的yum源配置文件到上面那个文件夹内</li>
</ol>
<pre><code class="language-shell">```# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo`
</code></pre>
<ol start="4">
<li>运行yum makecache生成缓存</li>
</ol>
<pre><code class="language-shell"># yum makecache
</code></pre>
<ol start="5">
<li>这时候再更新系统就会看到以下mirrors.163.com信息</li>
</ol>
<pre><code class="language-shell"># yum -y update
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程Loading mirror speeds from cached hostfile

* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
</code></pre>
<h2 id="修改-centos-默认-yum-源为-mirrorsaliyuncom">修改 CentOS 默认 yum 源为 mirrors.aliyun.com</h2>
<ol>
<li>首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo</li>
</ol>
<pre><code class="language-shell"># mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
</code></pre>
<ol start="2">
<li>下载ailiyun的yum源配置文件到/etc/yum.repos.d/</li>
</ol>
<pre><code class="language-shell"># CentOS7
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# CentOS6
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
</code></pre>
<ol start="3">
<li>运行yum makecache生成缓存</li>
</ol>
<pre><code class="language-shell"># yum makecache
</code></pre>
<ol start="4">
<li>这时候再更新系统就会看到以下mirrors.aliyun.com信息</li>
</ol>
<pre><code class="language-shel"># yum -y update
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
</code></pre>


</div>
<div id="MySignature" role="contentinfo">
    <br/>
本作品地址: https://www.cnblogs.com/lshare/p/11334642.html,作者: 東籬老農,採用知識共享署名 4.0 國際許可協議進行許可。
<br><br><br>
来源:https://www.cnblogs.com/lshare/p/11334642.html
頁: [1]
查看完整版本: CentOS yum 源修改