All Products
Search
Document Center

Elastic Compute Service:How do I change CentOS 6 repository addresses?

Last Updated:Mar 26, 2024

CentOS 6 has reached its end of life (EOL) and is no longer maintained by the Linux community. We recommend that you upgrade your operating system to CentOS 7 or later. If you want to continue using specific installation packages of CentOS 6 during the transition period, perform the operations that are described in this topic to change CentOS 6 repository addresses.

Background information

CentOS 6 has reached its EOL on November 30, 2020. In accordance with the community rules of Linux, all content has been removed from the following CentOS 6 repository address: http://mirror.centos.org/centos-6/. All third-party image providers have removed CentOS 6 repositories from their images. Alibaba Cloud repositories at http://mirrors.cloud.aliyuncs.com and http://mirrors.aliyun.com can no longer be synchronized with CentOS 6 repositories. If you continue to use the default CentOS 6 repository configurations on Alibaba Cloud, an error is reported. The following figure shows a sample error.centos 6 error

You can perform the following procedure to change the repository configurations of Elastic Compute Service (ECS) instances that run CentOS 6 based on network environments.

  • YUM repository

    • For ECS instances that reside in virtual private clouds (VPCs), change the YUM repository address to http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/.

    • For ECS instances that reside in the classic network, change the YUM repository address to http://mirrors.aliyuncs.com/centos-vault/6.10/.

  • EPEL repository

    • For ECS instances that reside in VPCs, change the Extra Packages for Enterprise Linux (EPEL) repository address to http://mirrors.cloud.aliyuncs.com/epel-archive/6/.

    • For ECS instances that reside in the classic network, change the EPEL repository address to http://mirrors.aliyuncs.com/epel-archive/6/.

Note

This topic describes how to change CentOS 6 repository addresses for ECS instances. If your server is not an ECS instance, make sure that the server can access the Internet, and then replace http://mirrors.cloud.aliyuncs.com in the preceding repository addresses with http://mirrors.aliyun.com. For example, you can change the address of the YUM repository for CentOS 6 to http://mirrors.aliyun.com/centos-vault/6.10/ and change the address of the EPEL repository for CentOS 6 to http://mirrors.aliyun.com/epel-archive/6/.

Procedure

  1. Connect to an ECS instance that runs CentOS 6.

    For more information, see Connection method overview.

  2. Run the following command to modify the CentOS-Base.repo file:

    vim /etc/yum.repos.d/CentOS-Base.repo 
  3. Press the I key to enter Insert mode, and change the repository addresses.

    Change the repository addresses based on the network type of the instance.

    • Modified content that includes the new repository address for the instance located in a VPC:

      [base]
      name=CentOS-6.10
      enabled=1
      failovermethod=priority
      baseurl=http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/os/$basearch/
      gpgcheck=1
      gpgkey=http://mirrors.cloud.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6
      
      [updates]
      name=CentOS-6.10
      enabled=1
      failovermethod=priority
      baseurl=http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/updates/$basearch/
      gpgcheck=1
      gpgkey=http://mirrors.cloud.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6
      
      [extras]
      name=CentOS-6.10
      enabled=1
      failovermethod=priority
      baseurl=http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/extras/$basearch/
      gpgcheck=1
      gpgkey=http://mirrors.cloud.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6
    • Modified content that includes the new repository address for the instance located in the classic network:

      [base]
      name=CentOS-6.10
      enabled=1
      failovermethod=priority
      baseurl=http://mirrors.aliyuncs.com/centos-vault/6.10/os/$basearch/
      gpgcheck=1
      gpgkey=http://mirrors.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6
      
      [updates]
      name=CentOS-6.10
      enabled=1
      failovermethod=priority
      baseurl=http://mirrors.aliyuncs.com/centos-vault/6.10/updates/$basearch/
      gpgcheck=1
      gpgkey=http://mirrors.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6
      
      [extras]
      name=CentOS-6.10
      enabled=1
      failovermethod=priority
      baseurl=http://mirrors.aliyuncs.com/centos-vault/6.10/extras/$basearch/
      gpgcheck=1
      gpgkey=http://mirrors.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6

    After you modify the file, press the Esc key to exit Insert mode and enter :wq to save and exit the file.

  4. Run the following command to modify the epel.repo file:

    vim /etc/yum.repos.d/epel.repo
  5. Press the I key to enter Insert mode, and change the repository addresses.

    Change the repository addresses based on the network type of the instance.

    • Modified content that includes the new repository address for the instance located in a VPC:

      [epel]
      name=Extra Packages for Enterprise Linux 6 - $basearch
      enabled=1
      failovermethod=priority
      baseurl=http://mirrors.cloud.aliyuncs.com/epel-archive/6/$basearch
      gpgcheck=0
      gpgkey=http://mirrors.cloud.aliyuncs.com/epel-archive/RPM-GPG-KEY-EPEL-6
    • Modified content that includes the new repository address for the instance located in the classic network

      [epel]
      name=Extra Packages for Enterprise Linux 6 - $basearch
      enabled=1
      failovermethod=priority
      baseurl=http://mirrors.aliyuncs.com/epel-archive/6/$basearch
      gpgcheck=0
      gpgkey=http://mirrors.aliyuncs.com/epel-archive/RPM-GPG-KEY-EPEL-6

    After you modify the file, press the Esc key to exit Insert mode and enter :wq to save and exit the file.

What to do next

After you change the YUM and EPEL repository addresses, you can run the apt install command to install the software packages that you need on the instance.

After an instance is created from a custom image, cloud-init initializes the repository configurations of the instance on instance startup. If you want to create a custom image based on the instance for which the repository addresses are changed and want to retain the new repository configurations, perform the following steps to modify the cloud-init configuration file /etc/cloud/cloud.cfg on the instance before you create the custom image:

  1. Run the following command to modify the /etc/cloud/cloud.cfg file:

    vim /etc/cloud/cloud.cfg
  2. Press the I key to enter Insert mode, and use # to comment out the - source-address module under cloud_init_modules:.

    The following figure shows the configuration information in the file.cloudinit

  3. After you modify the file, press the Esc key to exit Insert mode and enter :wq to save and exit the file.