开发者社区> 问答> 正文

解决方案 :"1月11日ECS Linux系统安装源(yum/deb/apt等)服务暂停与升级"

妙正灰 2018-01-09 17:23:10 9350
这里就是重点来了,如何解决本次的软件源暂时无法使用的问题呢? 那就是提前换一个可以使用的软件源。
这里需要用到代码编辑器和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 文件,写入清华源的内容:

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

然后运行 :


yum makecache
更新软件源缓存即可。
等问题修复,将该文件删除并将 CentOS-Base.repo.old 重新命名回来并更新缓存即可。
其他 CentOS 版本可以参考: https://mirror.tuna.tsinghua.edu.cn/help/centos/



Debian、Ubuntu


修改 /etc/apt/sources.list 文件,重命名为 /etc/apt/sources.list.old
然后重新创建 /etc/apt/sources.list 文件,内容为:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/OS/ CODE-proposed main restricted universe multiverse
# 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 的清华源替换方式:


# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse


等问题修复,将该文件删除并将 /etc/apt/sources.list.old 重新命名回来并更新缓存即可。
使用阿里云提供的默认软件源的话,走的是 ECS 的内网速度更加的快而且走的公网也更加安全可靠。
分享到
取消 提交回答
全部回答(4)
  • 服务器云
    2018-08-13 11:35:22
    Re解决方案 :1月11日ECS Linux系统安装源(yum/deb/apt等)服务暂停与升
    您的无私奉献精神值得我们学习!向您致敬!           

    0 0
  • 妙正灰
    2018-01-22 13:00:22
    回 2楼(火星123) 的帖子
    多谢支持
    0 0
  • 火星123
    2018-01-22 12:26:59
    Re解决方案 :1月11日ECS Linux系统安装源(yum/deb/apt等)服务暂停与升
    您的无私奉献精神值得我们学习!向您致敬!

    -------------------------

    Re解决方案 :1月11日ECS Linux系统安装源(yum/deb/apt等)服务暂停与升
    您的无私奉献精神值得我们学习!向您致敬!
    0 0
  • 洵云
    2018-01-10 09:33:33
    您的无私奉献精神值得我们学习!向您致敬!
    0 0
添加回答
+ 订阅

时时分享云计算技术内容,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。

推荐文章