日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

解决Yum下载慢 的问题

發布時間:2025/3/20 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 解决Yum下载慢 的问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

CentOS配置本地Yum源、阿里云Yum源、163Yum源、并配置Yum源的優先級

參考鏈接:http://www.linuxidc.com/Linux/2018-01/150690.htm

作者:kangvcar

?

? ? ?YUM或Yellowdog Updater Modified是管理rpm包的前端工具。 它用于通過命令行界面或使用圖形模式來安裝,刪除,更新和收集有關rpm軟件包的信息。 使用YUM的主要優點是,它解決了rpm包的所有依賴關系,并將它們與包一起安裝。

?

?YUM常用命令:

?安裝一個軟件包 ? ? ? ? ? ? ? ? ? ? ? ? ? ? yum install httpd

刪除一個包 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? yum remove httpd

更新軟件包 ? ? ? ? ? ? ? ? ? yum update httpd

?

列出所有安裝的軟件包 ? ? ? ? ? ? ? yum list installed | less

列出所有捆綁的組包 ? ? ? ? ? ? ? yum grouplist

?

安裝一組包 ? ? ? ? ? ? ? ? yum groupinstall ‘Minimal Install’

刪除一個組包 ? ? ? ? ? ? ? ? ?yum groupremove ‘NFS fille server’

?

搜索一個包 ? ? ? ? ? ? ? ? yum search httpd

列出一個包的信息 ? ? ?yum info httpd

?

找到屬于哪個包的文件 ? ? yum provides /etc/httpd/conf/httpd.conf

顯示所有repolist(啟用和禁用) ? ? yum repolist all

?

從特定的存儲庫安裝軟件包 ? ?yum –enablerepo=epel install nginx

清理yum緩存 ? ? ? ? ? ? ? ? ? ? ? yum clean all

?

yum的默認緩存文件存儲在/var/cache/yum中

查看YUM命令歷史記錄? yum history

?

?

一、用Centos鏡像搭建本地Yum源

由于安裝centos后的默認Yum源為centos的官方地址,所以在國內使用很慢甚至無法訪問,所以一般的做法都是把默認的Yum源替換成aliyun的Yum源或者163等國內的Yum源(下文介紹如何配置)。? 但是以上的方法都是需要網絡的,當沒有網絡的時候就無法使用了,所以還有一個常用的方法就是用Centos的ISO鏡像搭建本地Yum源,這樣安裝軟件的速度就會飛快,缺點是可能有些包沒有。

?

1.安裝Centos后默認的Yum源如下

?

[root@kangvcar ~]# ll /etc/yum.repos.d/ total?32 -rw-r--r--.?1?root root?1664?Dec ?9??2015?CentOS-Base.repo -rw-r--r--.?1?root root?1309?Dec ?9??2015?CentOS-CR.repo -rw-r--r--.?1?root root ?649?Dec ?9??2015?CentOS-Debuginfo.repo -rw-r--r--.?1?root root ?290?Dec ?9??2015?CentOS-fasttrack.repo -rw-r--r--.?1?root root ?630?Dec ?9??2015?CentOS-Media.repo -rw-r--r--.?1?root root?1331?Dec ?9??2015?CentOS-Sources.repo -rw-r--r--.?1?root root?1952?Dec ?9??2015?CentOS-Vault.repo

?

2.把默認Yum源備份(可選)

?

[root@kangvcar ~]# mkdir /opt/centos-yum.bak [root@kangvcar ~]# mv /etc/yum.repos.d/* /opt/centos-yum.bak/

?

3.在虛擬機上掛載CentOS鏡像文件

?

[root@kangvcar ~]# mount -t iso9660 /dev/sr0 /opt/centos mount:?/dev/sr0?is?write-protected, mounting?read-only

?

4.編寫repo文件并指向鏡像的掛載目錄

?

[root@kangvcar ~]# vi /etc/yum.repos.d/local.repo ? [local] name=local baseurl=file:///opt/centos enabled=1 gpgcheck=0

?

5.清除緩存

?

[root@kangvcar ~]# yum clean?all Loaded plugins:?fastestmirror Cleaning repos:?local Cleaning?up?everything Cleaning?up?list?of fastest mirrors [root@kangvcar ~]# yum makecache ? ? ? ?//把Yum源緩存到本地,加快軟件的搜索好安裝速度 [root@kangvcar ~]# yum?list?? ? ? ?//列出了3780個包

?

二、把默認的CentOS Yum源修改成國內的aliyun Yum源

阿里云官方教程:http://mirrors.aliyun.com/help/centos

1.安裝Centos后默認的Yum源如下

?

[root@kangvcar ~]# ll /etc/yum.repos.d/ total?32 -rw-r--r--.?1?root root?1664?Dec ?9??2015?CentOS-Base.repo -rw-r--r--.?1?root root?1309?Dec ?9??2015?CentOS-CR.repo -rw-r--r--.?1?root root ?649?Dec ?9??2015?CentOS-Debuginfo.repo -rw-r--r--.?1?root root ?290?Dec ?9??2015?CentOS-fasttrack.repo -rw-r--r--.?1?root root ?630?Dec ?9??2015?CentOS-Media.repo -rw-r--r--.?1?root root?1331?Dec ?9??2015?CentOS-Sources.repo -rw-r--r--.?1?root root?1952?Dec ?9??2015?CentOS-Vault.repo

?

2.把默認Yum源備份(可選)

?

[root@kangvcar ~]# mkdir /opt/centos-yum.bak [root@kangvcar ~]# mv /etc/yum.repos.d/* /opt/centos-yum.bak/

?

3.下載aliyun Yum源repo文件(對應自己的系統版本下載即可)

?

#各系統版本repo文件對應的下載操作 CentOS?5 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo CentOS?6 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo CentOS?7 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

?

[root@kangvcar ~]#?cat?/etc/redhat-release?? ? ? ?//查看系統的版本 CentOS?Linux?release?7.2.1511?(Core) [root@kangvcar ~]#?wget?-O?/etc/yum.repos.d/CentOS-Base.repo?http://mirrors.aliyun.com/repo/Centos-7.repo --2017-06-20?06:43:08--??http://mirrors.aliyun.com/repo/Centos-7.repo Resolving?mirrors.aliyun.com?(mirrors.aliyun.com)...?112.124.140.210,?115.28.122.210 Connecting?to?mirrors.aliyun.com?(mirrors.aliyun.com)|112.124.140.210|:80...?connected. HTTP?request?sent,?awaiting?response...?200?OK Length:?2573?(2.5K)?[application/octet-stream] Saving?to: ‘/etc/yum.repos.d/CentOS-Base.repo’ 100%[=======================================================================================================>]?2,573?? ? ??--.-K/s???in?0s?? ? ? 2017-06-20?06:43:08?(118?MB/s)?-?‘/etc/yum.repos.d/CentOS-Base.repo’?saved?[2573/2573]

?

4.清除緩存

?

[root@kangvcar ~]# yum clean?all Loaded plugins:?fastestmirror Cleaning repos:?base extras updates Cleaning?up?everything Cleaning?up?list?of fastest mirrors [root@kangvcar ~]# yum makecache ? ? ? ?//把Yum源緩存到本地,加快軟件的搜索好安裝速度 [root@kangvcar ~]# yum?list?? ? ? ?//總共列出了9954個包

?

三、把默認的CentOS Yum源修改成國內的163源

163官方教程:http://mirrors.163.com/.help/centos.html

1.安裝Centos后默認的Yum源如下

?

[root@kangvcar ~]# ll /etc/yum.repos.d/ total?32 -rw-r--r--.?1?root root?1664?Dec ?9??2015?CentOS-Base.repo -rw-r--r--.?1?root root?1309?Dec ?9??2015?CentOS-CR.repo -rw-r--r--.?1?root root ?649?Dec ?9??2015?CentOS-Debuginfo.repo -rw-r--r--.?1?root root ?290?Dec ?9??2015?CentOS-fasttrack.repo -rw-r--r--.?1?root root ?630?Dec ?9??2015?CentOS-Media.repo -rw-r--r--.?1?root root?1331?Dec ?9??2015?CentOS-Sources.repo -rw-r--r--.?1?root root?1952?Dec ?9??2015?CentOS-Vault.repo

?

2.把默認Yum源備份(可選)

?

[root@kangvcar ~]# mkdir /opt/centos-yum.bak [root@kangvcar ~]# mv /etc/yum.repos.d/* /opt/centos-yum.bak/

?

3.下載163 Yum源repo文件

?

#各系統版本repo文件對應的下載操作 CentOS?5 wget -O?/etc/yum.repos.d/CentOS5-Base-163.repo http://mirrors.163.com/.help/CentOS5-Base-163.repo CentOS?6 wget -O?/etc/yum.repos.d/CentOS6-Base-163.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo CentOS?7 wget -O?/etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo

?

[root@kangvcar ~]#?cat?/etc/redhat-release?? ? ? ?//查看系統的版本 CentOS?Linux?release?7.2.1511?(Core) [root@kangvcar ~]#?wget?-O?/etc/yum.repos.d/CentOS7-Base-163.repo?http://mirrors.163.com/.help/CentOS7-Base-163.repo --2017-06-20?06:29:47--??http://mirrors.163.com/.help/CentOS7-Base-163.repo Resolving?mirrors.163.com?(mirrors.163.com)...?123.58.173.185,?123.58.173.186 Connecting?to?mirrors.163.com?(mirrors.163.com)|123.58.173.185|:80...?connected. HTTP?request?sent,?awaiting?response...?200?OK Length:?1572?(1.5K)?[application/octet-stream] Saving?to: ‘/etc/yum.repos.d/CentOS7-Base-163.repo’ 100%[=======================================================================================================>]?1,572?? ? ??--.-K/s???in?0s?? ? ? 2017-06-20?06:29:47?(293?MB/s)?-?‘/etc/yum.repos.d/CentOS7-Base-163.repo’?saved?[1572/1572]

?

4.清除緩存

?

[root@kangvcar ~]# yum clean?all Loaded plugins:?fastestmirror Cleaning repos:?base extras updates Cleaning?up?everything Cleaning?up?list?of fastest mirrors [root@kangvcar ~]# yum makecache ? ? ? ?//把Yum源緩存到本地,加快軟件的搜索好安裝速度 [root@kangvcar ~]# yum?list?? ? ? ?//總共列出了9951個包

?

四、修改Yum源的優先級

當既有本地Yum源又有163源的時候,我們在裝軟件包的時候當然希望先用本地的Yum源去安裝,本地找不到可用的包時再使用163源去安裝軟件,這里就涉及到了優先級的問題,Yum提供的插件yum-plugin-priorities.noarch可以解決這個問題

1.查看系統是否安裝了優先級的插件

?

[root@kangvcar ~]# rpm -qa?|?grep?yum-plugin- yum-plugin-fastestmirror-1.1.31-34.el7.noarch ? ? ? ? //這里看到沒有安裝yum-plugin-priorities.noarch這個插件 [root@kangvcar ~]# yum?search?yum-plugin-priorities ? ? ? ? //用search查看是否有此插件可用 Loaded plugins:?fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras:?mirrors.aliyun.com *?updates:?mirrors.aliyun.com ======================================================?N/S matched: yum-plugin-priorities ======================================================= yum-plugin-priorities.noarch : plugin?to?give priorities?to?packages from different repos

?

2.安裝yum-plugin-priorities.noarch插件

?

[root@kangvcar ~]# yum -y install yum-plugin-priorities.noarch

?

3.查看插件是否啟用

?

[root@kangvcar ~]# cat /etc/yum/pluginconf.d/priorities.conf [main] enabled =?1 //1為啟用;0為禁用

?

4.修改本地Yum源優先使用

?

[root@kangvcar ~]# ll /etc/yum.repos.d/ total?8 -rw-r--r--.?1?root root?2573?May?15??2015?CentOS-Base.repo -rw-r--r--.?1?root root ??67?Jun?20?06:04?local.repo //有兩個repo文件 [root@kangvcar ~]# vi /etc/yum.repos.d/local.repo [local] name=local baseurl=file:///opt/centos enabled=1 gpgcheck=0 priority=1 //在原基礎上加入priority=1 ;數字越小優先級越高 //可以繼續修改其他源的priority值,經測試僅配置本地源的優先級為priority=1就會優先使用本地源了

?

5.測試

?

配置優先級前:(使用阿里云Yum源) [root@kangvcar ~]# yum -y?install?vim Dependencies Resolved ================================================================================================================================================= Package ? ? ? ? ? ? ? ? ? ? ? ? ? ?Arch ? ? ? ? ? ? ? ? ? ? ? ? Version ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Repository ? ? ? ? ? ? ? ? ? ? Size ================================================================================================================================================= Installing: vim-enhanced ? ? ? ? ? ? ? ? ? ? ? x86_64 ? ? ? ? ? ? ? ? ? ? ??2:7.4.160-1.el7_3.1?? ? ? ? ? ? ? ? ? ? ? ? updates ? ? ? ? ? ? ? ? ? ? ??1.0?M Updating?for?dependencies: vim-common ? ? ? ? ? ? ? ? ? ? ? ? x86_64 ? ? ? ? ? ? ? ? ? ? ??2:7.4.160-1.el7_3.1?? ? ? ? ? ? ? ? ? ? ? ? updates ? ? ? ? ? ? ? ? ? ? ??5.9?M 省略··· 配置優先級后:(使用本地Yum源) [root@kangvcar ~]# yum -y?install?vim Dependencies Resolved ================================================================================================================================================= Package ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Arch ? ? ? ? ? ? ? ? ? ? ? ?Version ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Repository ? ? ? ? ? ? ? ? ?Size ================================================================================================================================================= Installing: vim-enhanced ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?x86_64 ? ? ? ? ? ? ? ? ? ? ?2:7.4.160-1.el7 ? ? ? ? ? ? ? ? ? ? ? ?local ? ? ? ? ? ? ? ? ? ? ?1.0?M Installing?for?dependencies: gpm-libs ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?x86_64 ? ? ? ? ? ? ? ? ? ? ?1.20.7-5.el7 ? ? ? ? ? ? ? ? ? ? ? ? ? local ? ? ? ? ? ? ? ? ? ? ??32?k perl?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?x86_64 ? ? ? ? ? ? ? ? ? ? ?4:5.16.3-286.el7 ? ? ? ? ? ? ? ? ? ? ? local ? ? ? ? ? ? ? ? ? ? ?8.0?M perl-Carp ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? noarch ? ? ? ? ? ? ? ? ? ? ?1.26-244.el7 ? ? ? ? ? ? ? ? ? ? ? ? ? local ? ? ? ? ? ? ? ? ? ? ??19?k perl-Encode ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? x86_64 ? ? ? ? ? ? ? ? ? ? ?2.51-7.el7 ? ? ? ? ? ? ? ? ? ? ? ? ? ? local ? ? ? ? ? ? ? ? ? ? ?1.5?M perl-Exporter ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? noarch ? ? ? ? ? ? ? ? ? ? ?5.68-3.el7 ? ? ? ? ? ? ? ? ? ? ? ? ? ? local ? ? ? ? ? ? ? ? ? ? ??28?k perl-File-Path ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?noarch ? ? ? ? ? ? ? ? ? ? ?2.09-2.el7 ? ? ? ? ? ? ? ? ? ? ? ? ? ? local ? ? ? ? ? ? ? ? ? ? ??26?k perl-File-Temp ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?noarch ? ? ? ? ? ? ? ? ? ? ?0.23.01-3.el7 ? ? ? ? ? ? ? ? ? ? ? ? ?local ? ? ? ? ? ? ? ? ? ? ??56?k 省略···

?

?

?

更多YUM相關教程見以下內容

RHEL7 本地yum源配置 http://www.linuxidc.com/Linux/2017-01/139140.htm

CentOS 6.5 配置本地Yum源? http://www.linuxidc.com/Linux/2017-04/143127.htm

CentOS 7 使用阿里云的yum源、PIP源 http://www.linuxidc.com/Linux/2017-01/13966.htm

CentOS及Red Hat Linux安裝yum源? http://www.linuxidc.com/Linux/2017-02/140205.htm

CentOS 7更改yum源與更新系統 http://www.linuxidc.com/Linux/2017-01/140067.htm

redhat7.0配置本地yum源? http://www.linuxidc.com/Linux/2017-01/139148.htm?

RedHat Linux 7安裝CentOS 7 yum源? http://www.linuxidc.com/Linux/2017-04/142444.htm

軟件包管理之前端管理工具yum? http://www.linuxidc.com/Linux/2017-02/140270.htm

CentOS 7 使用阿里云的yum源、PIP源 http://www.linuxidc.com/Linux/2017-01/13966.htm

Linux yum的配置使用和程序包的編譯安裝? http://www.linuxidc.com/Linux/2017-09/146903.htm

?

Yum 加速設置請參考 <http://mirrors.163.com/.help/centos.html>

?

?

轉載于:https://my.oschina.net/u/3803405/blog/1821337

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的解决Yum下载慢 的问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。