The default yum update source of CentOS is obtained from the image list. The system automatically detects a fast update source based on your speed and region and uses this update source. If CentOS is in China but foreign sources are used, or the default source cannot be connected, you need to manually modify and update the source list.
1. Edit the source configuration file
vim /etc/yum.repos.d/CentOS-Base.repo
The default source is as follows:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and
# Update status of each mirror to pick mirrors that are updated to and
# Geographically close to the client.
You shoshould use this for CentOS updates
# Unless you are manually picking other mirrors.
#
# If the specified list = does not work for you, as a fall back you can try
# Remarked out baseurl = line instead.
#
#
[Base]
Name = CentOS-$ releasever-Base
Using list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = OS
# Baseurl = http://developer.centos.org/centos/?releasever/ OS /?basearch/
Gpgcheck = 1
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
# Released updates
[Updates]
Name = CentOS-$ releasever-Updates
Using list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = updates
# Baseurl = http://developer.centos.org/centos/?releasever/updates/?basearch/
Gpgcheck = 1
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
# Packages used/produced in the build but not released
[Addons]
Name = CentOS-$ releasever-Addons
Using list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = addons
# Baseurl = http://developer.centos.org/centos/?releasever/addons/?basearch/
Gpgcheck = 1
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
# Additional packages that may be useful
[Extras]
Name = CentOS-$ releasever-Extras
Using list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = extras
# Baseurl = http://developer.centos.org/centos/?releasever/extras/?basearch/
Gpgcheck = 1
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
# Additional packages that extend functionality of existing packages
[Centosplus]
Name = CentOS-$ releasever-Plus
Using list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = centosplus
# Baseurl = http://developer.centos.org/centos/?releasever/centosplus/?basearch/
Gpgcheck = 1
Enabled = 0
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
# Contrib-packages by Centos Users
[Contrib]
Name = CentOS-$ releasever-Contrib
Using list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = contrib
# Baseurl = http://developer.centos.org/centos/?releasever/contrib/?basearch/
Gpgcheck = 1
Enabled = 0
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
2. Modify the source
If you want to change to the Netease source, replace all the content:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and
# Update status of each mirror to pick mirrors that are updated to and
# Geographically close to the client. You shoshould use this for CentOS updates
# Unless you are manually picking other mirrors.
#
# If the specified list = does not work for you, as a fall back you can try
# Remarked out baseurl = line instead.
#
#
[Base]
Name = CentOS-$ releasever-Base
Baseurl = http://mirrors.163.com/centos/?releasever/ OS /?basearch/
Gpgcheck = 1
Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
[Updates]
Name = CentOS-$ releasever-Updates
Baseurl = http://mirrors.163.com/centos/?releasever/updates/?basearch/
Gpgcheck = 1
Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
[Addons]
Name = CentOS-$ releasever-Addons
Baseurl = http://mirrors.163.com/centos/?releasever/addons/?basearch/
Gpgcheck = 1
Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
[Extras]
Name = CentOS-$ releasever-Extras
Baseurl = http://mirrors.163.com/centos/?releasever/extras/?basearch/
Gpgcheck = 1
Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
[Centosplus]
Name = CentOS-$ releasever-Plus
Baseurl = http://mirrors.163.com/centos/?releasever/centosplus/?basearch/
Gpgcheck = 1
Enabled = 0
Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
Finally, run the following command to update the component.
yum update