Featured image of post Changing the Yum Update Source in CentOS to Domestic Mirrors

Changing the Yum Update Source in CentOS to Domestic Mirrors

After installing CentOS, the default update source is the official one, which tends to be very slow in China. Here are several domestic mirrors that significantly improve download speeds after switching. Preparation...

After installing CentOS, the default update source is the official one, which tends to be slow in China. Below are several domestic mirrors that significantly improve download speeds after switching.

Note: If you are logged in as a non-root user, remember to add sudo before the commands, for instance, sudo yum -y update.

Preparation

If you have just completed the installation of your new system, make sure to first install curl or wget by executing the following command:

1
yum -y install wget curl

Backup and Update Source

Backup

The Yum source for CentOS 7 and 8 is located at /etc/yum.repos.d/CentOS-Base.repo. First, let’s create a backup:

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

Update

Now, let’s update the source to Aliyun (Alibaba Cloud):

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

If you find Aliyun’s source not working well, you can switch to other domestic mirrors. More sources are listed below.

Clear Cache

To clear all Yum cache from the system, use:

1
yum clean all

Next, rebuild the Yum cache:

1
yum makecache

Update the System

Finally, run the command to update the system:

1
yum -y update

At this point, the update is complete.

Changing the Yum Update Source in CentOS

After switching the source, download speeds are noticeably faster.

Collection of Common Domestic Mirrors:

Based on comprehensive testing, the Tsinghua University mirror is exceptionally fast. Tsinghua University is indeed impressive! (●’◑’●)

Licensed under CC BY-NC-SA 4.0