Linux 更换更新源,解决 update 慢问题

无论我们使用哪一家 Linux 服务器,使用前首先需要做的就是更新软件,无论是 CentOS还是 Ubuntu 或者其他系统,都需要这么做一下,以确保系统安全,由于种种原因,实际更新过程中,有时 update 速度特别慢,为解决 update 下载慢问题,可以通过将默认源替换为镜像源来解决。

1、Ubuntu

以阿里云源为例(其他源参考官方 wiki):

Ubuntu 14.04

# cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份
# vim /etc/apt/sources.list #清空并添加以下内容
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
# apt update

Ubuntu 16.04

# cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份
# vim /etc/apt/sources.list #清空并添加以下内容
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
# apt update

PS:一条命令快速替换法:

ubuntu16.source.png

2、CentOS

以阿里云源为例:

CentOS 6

# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
# yum clean all && yum makecache

CentOS 7

# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# yum clean all && yum makecache

3、第三方源

epel

以 CentOS 为例:

# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# wget -O /etc/yum.repos.d/epel-testing.repo http://mirrors.aliyun.com/repo/epel-testing.repo
# yum clean all && yum makecache

参考链接:
1、《Ubuntu 14.04 更换阿里云源
2、《解决Debian系统apt-get更新官方源失败 替换163源的方法
3、《模板:16.04source


ArmxMod for Typecho
个性化、自适应、功能强大的响应式主题

推广

 继续浏览关于 linuxcentosubuntu教程更新源 的文章

 本文最后更新于 2017/10/30 16:33:14,可能因经年累月而与现状有所差异

 引用转载请注明: VirCloud's Blog > 系统 > Linux 更换更新源,解决 update 慢问题