All Products
Search
Document Center

Alibaba Cloud Linux:What do I do if the YUM commands cannot be run on an Alibaba Cloud Linux 2 ECS instance that resides in the classic network?

Last Updated:Dec 08, 2023

This topic describes the cause of the following issue and how to resolve the issue: The YUM commands cannot be run on an Alibaba Cloud Linux 2 Elastic Compute Service (ECS) instance that resides in the classic network.

Problem description

After you run the yum update command on an ECS instance that meets the following conditions, an error message indicating that the repository address is invalid is returned.

  • Image: aliyun-2.1903-x64-20G-alibase-20190327.vhd or later

  • Kernel: kernel-4.19.24-9.al7 or later

  • Network type: classic network

Cause

Alibaba Cloud does not support Alibaba Cloud Linux 2 instances that reside in the classic network. Alibaba Cloud Linux 2 instances that reside in the classic network may be unable to connect to the addresses that are specified in the YUM repository files.

Solution

  1. Log on to the ECS instance.

  2. Modify the /etc/yum.repos.d/aliyun-base.repo configuration file. The following sample code provides an example of the modified file content.

    Note

    If the configuration file does not exist, create the file.

    [base]
    name=AliYun-$releasever - Base - mirrors.aliyun.com
    baseurl=http://mirrors.aliyun.com/alinux/$releasever/os/$basearch/
    gpgcheck=1
    gpgkey=http://mirrors.aliyun.com/alinux/RPM-GPG-KEY-ALIYUN
    
    #released updates
    [updates]
    name=AliYun-$releasever - Updates - mirrors.aliyun.com
    baseurl=http://mirrors.aliyun.com/alinux/$releasever/updates/$basearch/
    gpgcheck=1
    gpgkey=http://mirrors.aliyun.com/alinux/RPM-GPG-KEY-ALIYUN
    
    #additional packages that may be useful
    [extras]
    name=AliYun-$releasever - Extras - mirrors.aliyun.com
    baseurl=http://mirrors.aliyun.com/alinux/$releasever/extras/$basearch/
    gpgcheck=1
    gpgkey=http://mirrors.aliyun.com/alinux/RPM-GPG-KEY-ALIYUN
    
    # plus packages provided by Aliyun Linux dev team
    [plus]
    name=AliYun-$releasever - Plus - mirrors.aliyun.com
    baseurl=http://mirrors.aliyun.com/alinux/$releasever/plus/$basearch/
    gpgcheck=1
    gpgkey=http://mirrors.aliyun.com/alinux/RPM-GPG-KEY-ALIYUN
  3. Delete all .repo configuration files except for the /etc/yum.repos.d/aliyun-base.repo configuration file from the /etc/yum.repos.d/ directory. Example: /etc/yum.repos.d/epel.repo.

  4. Optional. To permanently resolve the issue, change the network type of the instance from the classic network to Virtual Private Cloud (VPC). For information about how to change the network type of an instance from the classic network to VPC, see Overview.