解决方案 :"1月11日ECS Linux系统安装源(yum/deb/apt等)服务暂停与升级"|云服务器 ECS - 开发者论坛

131 阅读2分钟
原文链接: click.aliyun.com
这里就是重点来了,如何解决本次的软件源暂时无法使用的问题呢? 那就是提前换一个可以使用的软件源。 
这里需要用到代码编辑器和SFTP软件,如果没有安装,建议参考:【云计算的1024种玩法】ECS和轻量应用服务器的远程控制入门 
 
RHEL、CentoS 
 
修改 /etc/yum.repos.d/ 目录下的文件,例如:CentOS-Base.repo 、epel.repo 等,这里以修改 CentOS 7 本身的软件源文件 CentOS-Base.repo 为例: 
CentOS-Base.repo 修改为 CentOS-Base.repo.old 
然后创建一个新的 CentOS-Base.repo 文件,写入清华源的内容: 
 
复制代码
  1. # CentOS-Base.repo
  2. #
  3. # The mirror system uses the connecting IP address of the client and the
  4. # update status of each mirror to pick mirrors that are updated to and
  5. # geographically close to the client.  You should use this for CentOS updates
  6. # unless you are manually picking other mirrors.
  7. #
  8. # If the mirrorlist= does not work for you, as a fall back you can try the
  9. # remarked out baseurl= line instead.
  10. #
  11. #
  12. [base]
  13. name=CentOS-$releasever - Base
  14. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
  15. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
  16. gpgcheck=1
  17. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  18. #released updates
  19. [updates]
  20. name=CentOS-$releasever - Updates
  21. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
  22. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
  23. gpgcheck=1
  24. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  25. #additional packages that may be useful
  26. [extras]
  27. name=CentOS-$releasever - Extras
  28. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
  29. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
  30. gpgcheck=1
  31. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  32. #additional packages that extend functionality of existing packages
  33. [centosplus]
  34. name=CentOS-$releasever - Plus
  35. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
  36. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
  37. gpgcheck=1
  38. enabled=0
  39. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 
然后运行 : 
 
 
复制代码
  1. yum makecache
 
更新软件源缓存即可。 
等问题修复,将该文件删除并将 CentOS-Base.repo.old 重新命名回来并更新缓存即可。 
其他 CentOS 版本可以参考:mirror.tuna.tsinghua.edu.cn/help/centos… 
 
 
 
Debian、Ubuntu 
 
 
修改 /etc/apt/sources.list 文件,重命名为 /etc/apt/sources.list.old 
然后重新创建 /etc/apt/sources.list 文件,内容为: 
复制代码
  1. # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
  2. deb https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE main restricted universe multiverse
  3. # deb-src https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE main restricted universe multiverse
  4. deb https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-updates main restricted universe multiverse
  5. # deb-src https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-updates main restricted universe multiverse
  6. deb https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-backports main restricted universe multiverse
  7. # deb-src https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-backports main restricted universe multiverse
  8. deb https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-security main restricted universe multiverse
  9. # deb-src https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-security main restricted universe multiverse
  10. # 预发布软件源,不建议启用
  11. # deb https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-proposed main restricted universe multiverse
  12. # deb-src https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-proposed main restricted universe multiverse
 
 
: 其中,OS 代表 debian 或者 ubuntu,CODE 代表发型代号,例如 Ubuntu 18.04 是 artful,Debian 9 是 stretch 
展示一下 Ubuntu 16.04 的清华源替换方式: 
 
 
复制代码
  1. # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
  2. deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
  3. # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
  4. deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
  5. # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
  6. deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
  7. # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
  8. deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
  9. # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
  10. # 预发布软件源,不建议启用
  11. # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
  12. # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
 
 
等问题修复,将该文件删除并将 /etc/apt/sources.list.old 重新命名回来并更新缓存即可。 
使用阿里云提供的默认软件源的话,走的是 ECS 的内网速度更加的快而且走的公网也更加安全可靠。