文档

Debian 9/10 EOL如何切换源?

更新时间:

Debian 9/10操作系统版本结束生命周期(EOL)后,Linux社区不再维护该操作系统版本。建议您升级操作系统至Debian 11及以上,如果您的业务过渡期仍需要使用Debian 9/10系统中的一些安装包,请先根据本文操作切换源地址。

背景信息

您可以通过下文的操作步骤,在Debian 9/10操作系统的ECS实例中将源配置按照网络环境不同进行切换。

  • 专有网络VPC类型实例需切换为http://mirrors.cloud.aliyuncs.com/debian-archive/debian源。

  • 经典网络类型实例需切换为http://mirrors.aliyuncs.com/debian-archive/debian源。

重要

本文主要说明ECS实例中的相关操作与配置,如果您的服务器不是ECS实例,需保证服务器具有公网访问能力,请将源地址http://mirrors.cloud.aliyuncs.com替换为http://mirrors.aliyun.com

操作步骤

  1. 登录Debian 9/10系统的ECS实例。

  2. 运行以下命令编辑sources.list文件。

    sudo vim /etc/apt/sources.list
  3. i键进入编辑模式,修改以下内容切换源。

    请根据实例不同的网络类型进行修改,具体内容如下:

    专有网络VPC类型实例

    • Debian 9

      deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch main contrib non-free
      deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch-proposed-updates main non-free contrib
      deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch-backports main non-free contrib
      deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian-security stretch/updates main contrib non-free
      deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch main contrib non-free
      deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch-proposed-updates main contrib non-free
      deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch-backports main contrib non-free
      deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian-security stretch/updates main contrib non-free
    • Debian 10

      deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch main
      deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch-proposed-updates main
      deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch-backports main
      deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian-security stretch/updates main
      deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch main
      deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch-proposed-updates main
      deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch-backports main
      deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian-security stretch/updates main

    经典网络类型实例

    • Debian 9

      deb http://mirrors.aliyuncs.com/debian-archive/debian stretch main contrib non-free
      deb http://mirrors.aliyuncs.com/debian-archive/debian stretch-proposed-updates main non-free contrib
      deb http://mirrors.aliyuncs.com/debian-archive/debian stretch-backports main non-free contrib
      deb http://mirrors.aliyuncs.com/debian-archive/debian-security stretch/updates main contrib non-free
      deb-src http://mirrors.aliyuncs.com/debian-archive/debian stretch main contrib non-free
      deb-src http://mirrors.aliyuncs.com/debian-archive/debian stretch-proposed-updates main contrib non-free
      deb-src http://mirrors.aliyuncs.com/debian-archive/debian stretch-backports main contrib non-free
      deb-src http://mirrors.aliyuncs.com/debian-archive/debian-security stretch/updates main contrib non-free
    • Debian 10

      deb http://mirrors.aliyuncs.com/debian-archive/debian stretch main
      deb http://mirrors.aliyuncs.com/debian-archive/debian stretch-proposed-updates main
      deb http://mirrors.aliyuncs.com/debian-archive/debian stretch-backports main
      deb http://mirrors.aliyuncs.com/debian-archive/debian-security stretch/updates main
      deb-src http://mirrors.aliyuncs.com/debian-archive/debian stretch main
      deb-src http://mirrors.aliyuncs.com/debian-archive/debian stretch-proposed-updates main
      deb-src http://mirrors.aliyuncs.com/debian-archive/debian stretch-backports main
      deb-src http://mirrors.aliyuncs.com/debian-archive/debian-security stretch/updates main
  4. 编辑完成后,按Esc键,并输入:wq保存退出文件。

  5. 运行以下命令更新源缓存。

    sudo apt update

源切换完成后,即可使用sudo apt install命令在实例上安装您所需要的软件包。

相关操作

使用自定义镜像创建新的ECS实例,在启动实例时cloud-init会自动初始化系统的源配置。如果您后续需要通过已切换源的ECS实例创建自定义镜像,并且需要保留已切换的源配置,需要您在创建自定义镜像前,按照以下操作在已切换源的ECS实例中修改cloud-init的配置文件/etc/cloud/cloud.cfg

  1. 运行以下命令编辑/etc/cloud/cloud.cfg文件。

    sudo vim /etc/cloud/cloud.cfg
  2. i进入编辑模式,使用#注释掉cloud_init_modules:下的- source-address模块。

    注释后,文件内的配置信息如下所示:cloudinit

  3. 编辑完成后,按Esc键,并输入:wq保存退出文件。

相关文档

Debian操作系统生命周期信息,请参见操作系统维护周期