1. 程式人生 > 其它 >centos7 修改yum源為國內源

centos7 修改yum源為國內源

技術標籤:centos

 
[[email protected] ~]# vim  /etc/yum.repos.d/CentOS-Base.repo
  1 # CentOS-Base.repo
  2 #
  3 # The mirror system uses the connecting IP address of the client and the
  4 # update status of each mirror to pick mirrors that are updated to and
  5 # geographically close to the client.  You should use this for CentOS updates
  6 # unless you are manually picking other mirrors.
  7 #
  8 # If the mirrorlist= does not work for you, as a fall back you can try the
  9 # remarked out baseurl= line instead.
 10 #
 11 #
 12
 13 [base]
 14 name=CentOS-$releasever - Base
 15 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
 16 #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
 17 gpgcheck=1
 18 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 19.............


[[email protected] ~]# wget -O  /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2021-01-21 14:07:04--  http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 183.203.69.190, 120.201.132.240, 221.180.194.82, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|183.203.69.190|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

100%[============================================================================================================================>] 2,523       --.-K/s   in 0s

2021-01-21 14:07:04 (106 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]

[[email protected] ~]# vim  /etc/yum.repos.d/CentOS-Base.repo
  1 # CentOS-Base.repo
  2 #
  3 # The mirror system uses the connecting IP address of the client and the
  4 # update status of each mirror to pick mirrors that are updated to and
  5 # geographically close to the client.  You should use this for CentOS updates
  6 # unless you are manually picking other mirrors.
  7 #
  8 # If the mirrorlist= does not work for you, as a fall back you can try the
  9 # remarked out baseurl= line instead.
 10 #
 11 #
 12
 13 [base]
 14 name=CentOS-$releasever - Base - mirrors.aliyun.com
 15 failovermethod=priority
 16 baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
 17         http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
 18         http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
 19 gpgcheck=1
 20 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
...

生成快取

[[email protected] ~]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                                           | 3.6 kB  00:00:00
extras                                                                                                                                         | 2.9 kB  00:00:00
updates                                                                                                                                        | 2.9 kB  00:00:00
(1/6): extras/7/x86_64/filelists_db                                                                                                            | 224 kB  00:00:00
(2/6): updates/7/x86_64/filelists_db                                                                                                           | 2.7 MB  00:00:01
(3/6): base/7/x86_64/filelists_db                                                                                                              | 7.2 MB  00:00:03
base/7/x86_64/other_db         FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/ecaab5cc3b9c10fefe6be2ecbf6f9fcb437231dac3e82cab8d9d2cf70e99644d-other.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/ecaab5cc3b9c10fefe6be2ecbf6f9fcb437231dac3e82cab8d9d2cf70e99644d-other.sqlite.bz2: (28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
extras/7/x86_64/other_db       FAILED
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/2e9fd48ed164af0d6a80c2a07dc67c09d733ea94fbde75f81cc7076405c90124-other.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/2e9fd48ed164af0d6a80c2a07dc67c09d733ea94fbde75f81cc7076405c90124-other.sqlite.bz2: (28, 'Connection timed out after 30003 milliseconds')
Trying other mirror.
updates/7/x86_64/other_db      FAILED
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/28188dc48c3200232ddb60e26ad96a5fdbf61f7d4dece0794a88fe5dcb25b419-other.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/28188dc48c3200232ddb60e26ad96a5fdbf61f7d4dece0794a88fe5dcb25b419-other.sqlite.bz2: (28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
(4/6): base/7/x86_64/other_db                                                                                                                  | 2.6 MB  00:00:00
(5/6): extras/7/x86_64/other_db                                                                                                                | 134 kB  00:00:00
(6/6): updates/7/x86_64/other_db                                                                                                               | 336 kB  00:00:00
Metadata Cache Created

參考:https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b112dJLen