centos7更改國內源


1、個人安裝環境

1.1 CentOS Linux release 7.7.1908 (Core)

2、更改目的

有時候CentOS默認的yum源不一定是國內鏡像,導致yum在線安裝及更新速度不是很理想。這時候需要將yum源設置為國內鏡像站點。

國內主要開源的開源鏡像站點應該是網易和阿里雲了。具體使用哪個可以根據PING命令獲取time,選擇time較小源

 

[root@localhost yum.repos.d]# ping 163.com
PING 63.com (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.099 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.097 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.101 ms

 

 

[root@localhost yum.repos.d]# ping aliyun.com
PING aliyun.com (106.11.172.51) 56(84) bytes of data.
64 bytes from 106.11.172.51 (106.11.172.51): icmp_seq=1 ttl=128 time=17.7 ms
64 bytes from 106.11.172.51 (106.11.172.51): icmp_seq=2 ttl=128 time=17.4 ms
64 bytes from 106.11.172.51 (106.11.172.51): icmp_seq=3 ttl=128 time=15.6 ms

 

3、安裝步驟

3.1 備份源文件

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

 3.2 下載更改源

  • CentOS5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
  • CentOS6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
  • CentOS7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

根據centos版本下載對應的新源,這里以CentOS7為例

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

 如果wget命令不生效,說明還沒有安裝wget工具,輸入yum -y install wget 回車進行安裝,或者使用

curl -O http://mirrors.aliyun.com/repo/Centos-7.repo

 3.3 清空yum緩存並生存cache文件

yum clean all
yum makecache

 3.4 嘗試更新系統

yum -y update

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM