十一博客 十一博客

Linux主机yum/apt-get速度慢&报错解决方法

in 默认类,技术控,分享控 read (81) 文章转载请注明来源!

简要说明:

这个问题来源于系统的源设置。由于我们并不太信任国内资源,因此全部直接使用美国源。
平时有碰到太多运营商利用DNS,做到私自替换同名文件经历,特别是http的链接尤为严重。

解决方案:

如您觉得系统更新/安装软件速度慢,请替换使用中国内地源地址(阿里或163,二选一)。

阿里源:https://opsx.alibaba.com/mirror
163源:https://mirrors.163.com/

备注:

  1. 如果替换源后发现更新会超时或失败,请编辑源文件,将里面的源地址连接由http改成https
  2. 国内服务器建议使用163源或阿里云源。海外服务器也可以使用阿里云源(阿里源有海外节点)
  3. 查询系统版本号命令:lsb_release -a

CentOS系统:
1、先安装wget命令及备份原文件:

yum install -y wget && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2、下载新的CentOS-Base.repo/etc/yum.repos.d/
备注:海外节点用阿里云,国内节点阿里或163都可以.
CentOS 6:
阿里源:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

163源:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo

CentOS 7:
阿里源:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

163源:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo

3:下载完成后,修改源文件连接为https

编辑/etc/yum.repos.d/CentOS-Base.repo,将里面所有的http修改为https

4:最后清理升级并重新生成缓存

yum clean all && yum makecache

Debian系统:

  1. 先安装

    apt-get update && apt-get install -y apt-transport-https

  2. 编辑 /etc/apt/sources.list , 删除所有默认的源并替换为以下内容(操作前请做好相应备份)

  3. 替换完成后需要清理并刷新源:

    rm -rf /var/lib/apt/lists/* && apt-get update

Debian 10(buster):
阿里源:

deb https://mirrors.aliyun.com/debian/ buster main
deb-src https://mirrors.aliyun.com/debian/ buster main
deb https://mirrors.aliyun.com/debian/ buster-updates main
deb-src https://mirrors.aliyun.com/debian/ buster-updates main
deb https://mirrors.aliyun.com/debian/ buster-backports main
deb-src https://mirrors.aliyun.com/debian/ buster-backports main
deb https://mirrors.aliyun.com/debian-security buster/updates main
deb-src https://mirrors.aliyun.com/debian-buster stretch/updates main

163源:

deb https://mirrors.163.com/debian/ buster main
deb-src https://mirrors.163.com/debian/ buster main
deb https://mirrors.163.com/debian/ buster-updates main
deb-src https://mirrors.163.com/debian/ buster-updates main
deb https://mirrors.163.com/debian/ buster-backports main
deb-src https://mirrors.163.com/debian/ buster-backports main
deb https://mirrors.163.com/debian-security/ buster/updates main
deb-src https://mirrors.163.com/debian-security/ buster/updates main

Debian 9(stretch):
阿里源:

deb https://mirrors.aliyun.com/debian/ stretch main
deb-src https://mirrors.aliyun.com/debian/ stretch main
deb https://mirrors.aliyun.com/debian/ stretch-updates main
deb-src https://mirrors.aliyun.com/debian/ stretch-updates main
deb https://mirrors.aliyun.com/debian/ stretch-backports main
deb-src https://mirrors.aliyun.com/debian/ stretch-backports main
deb https://mirrors.aliyun.com/debian-security stretch/updates main
deb-src https://mirrors.aliyun.com/debian-security stretch/updates main

163源:

deb https://mirrors.163.com/debian/ stretch main
deb-src https://mirrors.163.com/debian/ stretch main
deb https://mirrors.163.com/debian/ stretch-updates main
deb-src https://mirrors.163.com/debian/ stretch-updates main
deb https://mirrors.163.com/debian/ stretch-backports main
deb-src https://mirrors.163.com/debian/ stretch-backports main
deb https://mirrors.163.com/debian-security/ stretch/updates main
deb-src https://mirrors.163.com/debian-security/ stretch/updates main

Debian 8(jessie):
阿里源:

deb https://mirrors.aliyun.com/debian/ jessie main
deb-src https://mirrors.aliyun.com/debian/ jessie main
deb https://mirrors.aliyun.com/debian-security/ jessie/updates main
deb-src https://mirrors.aliyun.com/debian-security/ jessie/updates main

163源:

deb https://mirrors.163.com/debian/ jessie main
deb-src https://mirrors.163.com/debian/ jessie main
deb https://mirrors.163.com/debian-security/ jessie/updates main
deb-src https://mirrors.163.com/debian-security/ jessie/updates main

Debian 7(wheezy):
阿里源:

deb https://mirrors.aliyun.com/debian/ wheezy main
deb-src https://mirrors.aliyun.com/debian/ wheezy main
deb https://mirrors.aliyun.com/debian-security/ wheezy/updates main
deb-src https://mirrors.aliyun.com/debian-security/ wheezy/updates main

163源:

deb https://mirrors.163.com/debian/ wheezy main
deb-src https://mirrors.163.com/debian/ wheezy main
deb https://mirrors.163.com/debian-security/ wheezy/updates main
deb-src https://mirrors.163.com/debian-security/ wheezy/updates main

Ubuntu或其他系统参考:
阿里源:https://opsx.alibaba.com/mirror (找到对应系统,找到操作那列点后面的"帮助")
163源:https://mirrors.163.com/.help/ubuntu.html


教程摘自:解决Linux主机yum/apt-get速度慢&报错

本文基于《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
文章链接:https://blog.67cc.cn/archives/linux-host-yum-or-apt-get-is-slow.html (转载时请注明本文出处及文章链接)

教程分享
发表新评论
❋该站点已苟活
© 2017-2019 十一博客 蜀ICP备15021123号-1
又拍云
PREVIOUS NEXT
雷姆
拉姆