• 【Linux】提升yum下载速度


    前言

    使用yum update -y(慎用)升级完环境后,发现yum下载python3安装包时贼慢,接下来更换yum让下载速度重回巅峰。

    update和upgrade,区别如下,

    yum -y update:升级所有包同时,也升级软件和系统内核;
    yum -y upgrade:只升级所有包,不升级软件和系统内核,软件和内核保持原样。

    一、备份默认yum源

    mkdir /opt/centos-yum.bak 
    mv /etc/yum.repos.d/* /opt/centos-yum.bak/
    
    • 1
    • 2

    二、更换yum源

    查看系统版本

    cat /etc/redhat-release  
    
    • 1

    示例:

    [root@sanxingtongxue bin]# cat /etc/redhat-release  
    CentOS Linux release 8.5.2111
    
    • 1
    • 2

    阿里云开源镜像站

    http://mirrors.aliyun.com/repo

    网易

    CentOS7 :http://mirrors.163.com/.help/CentOS7-Base-163.repo

    repo文件下载

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

    这里使用阿里云开源镜像站。
    Centos-8.repo对应版本下载,如CentOS 7 改为Centos-7.repo。
    示例:

    [root@sanxingtongxue bin]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
    --2022-08-15 19:36:10--  http://mirrors.aliyun.com/repo/Centos-8.repo
    Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 220.181.158.239, 220.181.158.244, 220.181.158.248, ...
    Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|220.181.158.239|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 2590 (2.5K) [application/octet-stream]
    Saving to: '/etc/yum.repos.d/CentOS-Base.repo'
    
    /etc/yum.repos.d/CentOS-Base.repo                                   100%[=================================================================================================================================================================>]   2.53K  --.-KB/s    in 0s      
    
    2022-08-15 19:36:10 (467 MB/s) - '/etc/yum.repos.d/CentOS-Base.repo' saved [2590/2590]
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    三、缓存更新

    yum clean all 
    yum makecache
    
    • 1
    • 2
    [root@sanxingtongxue bin]# yum clean all
    /usr/lib/python3.6/site-packages/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
      from cryptography import x509
    
    503 files removed
    [root@sanxingtongxue bin]# yum makecache     
    /usr/lib/python3.6/site-packages/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
      from cryptography import x509
    
    CentOS-8 - Base - mirrors.aliyun.com                                                                                                                                                                                                           16 MB/s | 4.6 MB     00:00    
    CentOS-8 - Extras - mirrors.aliyun.com                                                                                                                                                                                                         72 kB/s |  10 kB     00:00    
    CentOS-8 - AppStream - mirrors.aliyun.com                                                                                                                                                                                                      22 MB/s | 8.4 MB     00:00    
    Metadata cache created.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    小拓展

    yum( Yellow dog Updater, Modified)是一个在 Fedora 和 RedHat 以及 SUSE 中的 Shell 前端软件包管理器。
    基于 RPM 包管理,能够从指定的服务器自动下载 RPM 包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。

    yum 提供了查找、安装、删除某一个、一组甚至全部软件包的命令,而且命令简洁而又好记。

    yum 语法

    yum [options] [command] [package ...]
    
        options:可选,选项包括-h(帮助),-y(当安装过程提示选择全部为 "yes"),-q(不显示安装的过程)等等。
        command:要进行的操作。
        package:安装的包名。
    
    • 1
    • 2
    • 3
    • 4
    • 5

    yum常用命令

    1. 列出所有可更新的软件清单命令:yum check-update
    
    2. 更新所有软件命令:yum update
    
    3. 仅安装指定的软件命令:yum install 
    
    4. 仅更新指定的软件命令:yum update 
    
    5. 列出所有可安裝的软件清单命令:yum list
    
    6. 删除软件包命令:yum remove 
    
    7. 查找软件包命令:yum search 
    8. 清除缓存命令:
    yum clean packages: 清除缓存目录下的软件包
    yum clean headers: 清除缓存目录下的 headers
    yum clean oldheaders: 清除缓存目录下旧的 headers
    yum clean, yum clean all (= yum clean packages; yum clean oldheaders) :清除缓存目录下的软件包及旧的 headers
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    在这里插入图片描述
    点赞 收藏 关注

  • 相关阅读:
    Linux设备树由来
    令人欣慰、阿里把 Spring 微服务架构设计整理成了 500 多页文档,真香
    逆变器是什么?超全详解智能光伏逆变器的原理及市场前景
    UNet - 数据加载 Dataset
    1688API 接入说明,Onebound数据
    动态规划——背包问题
    【已解决】QT设置setMouseTracking不响应mouseMove
    Kylin (四) --------- Kylin 4.0 查询引擎
    看完这篇 教你玩转渗透测试靶机Vulnhub——DriftingBlues-9
    【Linux】:Linux中Shell命令及其运行原理/权限的理解
  • 原文地址:https://blog.csdn.net/qq_35764295/article/details/126353395