How Can I Replace a CentOS 6 Image Source?
Symptom
The CentOS community ended the maintenance support (EOL) for CentOS 6 on November 30, 2020. The CentOS community does not provide security patch update or image source support for CentOS 6. The CentOS 6 image source has been removed from the source address http://mirror.centos.org/centos-6/ and third-party images.
When you use yum to update or download a CentOS 6 software package on HUAWEI CLOUD, an error message will be displayed.
Solution
- Method 1: (Recommended) Upgrade CentOS 6 to CentOS 7 to obtain security patches and software packages from the CentOS community.
- Method 2: If you still need to use CentOS 6 for a certain period of time, follow the operations described in this section to change the default image source to a CentOS 6 image source archived in the CentOS community.
Procedure
This section uses CentOS 6.10 as an example to describe how to replace an image source. If you use another CentOS 6 version, change the version to the one you are using.
- Log in to the ECS.
- Run the following command to edit the CentOS-Base.repo file:
vim /etc/yum.repos.d/CentOS-Base.repo
Press i to enter editing mode and replace the content in the CentOS-Base.repo file with the following content (change the version to the one you are using):
[base] name=CentOS-6.10 -Base -vault.centos.org failovermethod=priority baseurl=http://vault.centos.org/6.10/os/$basearch/ gpgcheck=1 gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-6.10 -Updates -vault.centos.org failovermethod=priority baseurl=http://vault.centos.org/6.10/updates/$basearch/ gpgcheck=1 gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-6.10 -Extras -vault.centos.org failovermethod=priority baseurl=http://vault.centos.org/6.10/extras/$basearch/ gpgcheck=1 gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-6.10 -Plus -vault.centos.org failovermethod=priority baseurl=http://vault.centos.org/6.10/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6 #contrib -packages by Centos Users [contrib] name=CentOS-6.10 -Contrib -vault.centos.org failovermethod=priority baseurl=http://vault.centos.org/6.10/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
- After the editing is complete, press Esc to exit editing mode and enter :wq! to save the modification and exit.
If it is slow to access the vault provided by the CentOS community, replace vault.centos.org to speed up the access.
Select one of the following image sources:
- Open-source software images of Tsinghua University: http://mirrors.tuna.tsinghua.edu.cn/centos-vault
Run the following command to replace the image source:
sed -i 's#vault.centos.org#mirrors.tuna.tsinghua.edu.cn/centos-vault#g' /etc/yum.repos.d/CentOS-Base.repo
- Open-source software images of Nanjing University: http://mirrors.nju.edu.cn/centos-vault
Run the following command to replace the image source:
sed -i 's#vault.centos.org#mirrors.nju.edu.cn/centos-vault#g' /etc/yum.repos.d/CentOS-Base.repo
- Open-source software images of Beijing Foreign Studies University: http://mirrors.bfsu.edu.cn/centos-vault
Run the following command to replace the image source:
sed -i 's#vault.centos.org#mirrors.bfsu.edu.cn/centos-vault#g' /etc/yum.repos.d/CentOS-Base.repo
- Open-source software images of Tsinghua University: http://mirrors.tuna.tsinghua.edu.cn/centos-vault
- Run the following command to create a new cache:
Then, you can run the yum install command to install and update the software package.
The new image source uses the archived image source from the CentOS community. Ensure that your ECS has an EIP bound and that outbound traffic from TCP port 80 is allowed in security group rules so that you can run the yum install command to install and update the software package.
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.