1.使用Centos映像構(gòu)建本地百勝源
由于安裝centos后的默認(rèn)百勝源是centos的官方地址,在國(guó)內(nèi)使用比較慢甚至無(wú)法訪問(wèn),所以一般做法是用阿里云的百勝源或者國(guó)內(nèi)百勝源比如163來(lái)代替默認(rèn)的百勝源(具體如何配置如下)。但是以上的方法都需要一個(gè)網(wǎng)絡(luò),沒(méi)有網(wǎng)絡(luò)的情況下無(wú)法使用,所以另一種常見的方法是用Centos的ISO映像構(gòu)建一個(gè)本地的Yum源,這樣軟件的安裝速度會(huì)比較快,但是缺點(diǎn)是有些包可能沒(méi)有。
1.安裝Centos后的默認(rèn)Yum源如下
[root @ kang vcar ~]# ll/etc/yum . repa . d/
總計(jì)32
-rw-r - r -。1 root root 1664 dec 92015 centos-base . repo
-rw-r - r -。1 root root 1309 dec 92015 centos-CR . repo
-rw-r - r -。1 root root 649 dec 92015 centos-debuginfo . repo
-rw-r - r -。1 root root 290 dec 92015 centos-fast track . repo
-rw-r - r -。1 root root 630 dec 92015 centos-Media . repo
-rw-r - r -。1 root root 1331 dec 92015 centos-sources . repo
-rw-r - r -。1 root root 1952 dec 92015 centos-vault . repo
2.備份默認(rèn)的百勝源(可選)
[root @ kang vcar ~]# mkdir/opt/centos-yum . bak
[root @ kang vcar ~]# mv/etc/yum . rep . d/*/opt/centos-yum . bak/
3.在虛擬機(jī)上裝載中央操作系統(tǒng)映像文件
[root @ kang vcar ~]# mount-t iso 9660/dev/sr0/opt/centos
moun t:/dev/sr0是寫保護(hù)的,只讀安裝
4.寫入一個(gè)回購(gòu)文件,并指向鏡像的裝載目錄
[root @ kang vcar ~]# VI/etc/yum . repo . d/local . repo
[本地]
name=local
baseurl=file:///opt/centos
enabled= 1
gpgcheck= 0
5.清除緩存
[root@kangvcar ~]# yum clean all
加載的插件:快速鏡像
清潔報(bào)告:本地
打掃衛(wèi)生
清潔速度最快的鏡子的上表面
[root @ kang vcar ~]# Yum make cache//在本地緩存Yum源,加快軟件的搜索和安裝
[root@kangvcar ~]# yum list//列出3780個(gè)包
第二,將默認(rèn)的CentOS Yum源修改為國(guó)內(nèi)的aliyun Yum源
阿里巴巴云官方教程:http://mirrors.aliyun.com/help/centos
1.安裝Centos后的默認(rèn)Yum源如下
[root @ kang vcar ~]# ll/etc/yum . repa . d/
總計(jì)32
-rw-r - r -。1 root root 1664 dec 92015 centos-base . repo
-rw-r - r -。1 root root 1309 dec 92015 centos-CR . repo
-rw-r - r -。1 root root 649 dec 92015 centos-debuginfo . repo
-rw-r - r -。1 root root 290 dec 92015 centos-fast track . repo
-rw-r - r -。1 root root 630 dec 92015 centos-Media . repo
-rw-r - r -。1 root root 1331 dec 92015 centos-sources . repo
-rw-r - r -。1 root root 1952 dec 92015 centos-vault . repo
2.備份默認(rèn)的百勝源(可選)
[root @ kang vcar ~]# mkdir/opt/centos-yum . bak
[root @ kang vcar ~]# mv/etc/yum . rep . d/*/opt/centos-yum . bak/
3.下載阿里云Yum源碼回購(gòu)文件(根據(jù)自己的系統(tǒng)版本下載)
#各系統(tǒng)版本回購(gòu)文件對(duì)應(yīng)的下載操作
CentOS 5
wget-O/etc/yum . repo . d/CentOS-base . repo http://mirrors . aliyun . com/repo/Centos-5 . repo
CentOS 6
wget-O/etc/yum . repo . d/CentOS-base . repo http://mirrors . aliyun . com/repo/Centos-6 . repo
CentOS 7
wget-O/etc/yum . repo . d/CentOS-base . repo http://mirrors . aliyun . com/repo/Centos-7 . repo
[root @ kang vcar ~]# cat/etc/red hat-release//檢查系統(tǒng)版本
CentOSLinuxrelease7.2.1511(核心)
[根@ kang vcar ~]# wget-O/etc/yum . repo . d/CentOS-base . repo http://mirrors . aliyun . com/repo/Centos-7 . repo
-2017-06-2006: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 mirrors . aliyun . com(mirrors . aliyun . com)| 112 . 124 . 140 . 210 |:80...連接。
HTTPrequestsent,awaitingresponse...200OK
長(zhǎng)度:2573(2.5K)[應(yīng)用/八位字節(jié)流]
saving to:'/etc/yum . repo . d/CentOS-base . repo '
100%[= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]2, 573 - .-K/ sin0s
2017-06-2006:43:08(118 MB/s)-'/etc/yum . repo . d/CentOS-base . repo ' saved[2573/2573]
4.清除緩存
[根@kangvcar ~]# yum clean all
加載的插件:快速鏡像
清理回購(gòu):基礎(chǔ)額外更新
打掃衛(wèi)生
清潔速度最快的鏡子的上表面
[root @ kangvcar ~]# Yum make cache//在本地緩存Yum源碼,加快軟件的搜索和安裝
[root@kangvcar ~]# yum list//共列出9954個(gè)套餐
第三,將默認(rèn)CentOS Yum源修改為國(guó)內(nèi)163源
163官方教程:http://mirrors.163.com/.help/centos.html
1.安裝Centos后的默認(rèn)Yum源如下
[魯特@ kang vcar ~]# ll/etc/yum . repo . d/
總計(jì)32
-rw-r - r -。1 root root 1664 dec 92015 centos-base . repo
-rw-r - r -。1 root root 1309 dec 92015 centos-CR . repo
-rw-r - r -。1 root root 649 dec 92015 centos-debuginfo . repo
-rw-r - r -。1 root root 290 dec 92015 centos-fast track . repo
-rw-r - r -。1 root root 630 dec 92015 centos-Media . repo
-rw-r - r -。1 root root 1331 dec 92015 centos-sources . repo
-rw-r - r -。1 root root 1952 dec 92015 centos-vault . repo
2.備份默認(rèn)的百勝源(可選)
[root @ kang vcar ~]# mkdir/opt/centos-yum . bak
[root @ kang vcar ~]# mv/etc/yum . rep . d/*/opt/centos-yum . bak/
3.下載163 Yum源碼回購(gòu)文件
#各系統(tǒng)版本回購(gòu)文件對(duì)應(yīng)的下載操作
CentOS 5
http://mirrors.163.com/.help/CentOS5-Base回購(gòu)163
CentOS 6
http://mirrors.163.com/.help/CentOS6-Base回購(gòu)163
CentOS 7
http://mirrors.163.com/.help/CentOS7-Base回購(gòu)163
[root @ kang vcar ~]# cat/etc/red hat-release//檢查系統(tǒng)版本
CentOSLinuxrelease7.2.1511(核心)
[root @ kang vcar ~]# wget-O/etc/yum . repo . d/Centos7-Base-163 . repo http://mirrors . 163 . com/。幫助/CentOS7-Base-163.repo
-2017-06-2006:29:47-http://mirrors . 163 . com/。幫助/CentOS7-Base-163.repo
Resolvingmirrors.163.com(鏡像。163.com)...123.58.173.185 , 123.58.173.186
connecting mirrors . 163 . com(鏡像。163.com)| 123.58.173.185| :80...連接。
HTTPrequestsent,awaitingresponse...200OK
長(zhǎng)度:1572(1.5K)[應(yīng)用/八位字節(jié)流]
saving to:'/etc/yum . repo . d/CentOS7-Base-163 . repo '
100%[= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]1, 572 - .-K/ sin0s
2017-06-2006:29:47(293 MB/s)-'/etc/yum . repo . d/Centos7-Base-163 . repo '已保存[1572/1572]
4.清除緩存
[root@kangvcar ~]# yum clean all
加載的插件:快速鏡像
清理回購(gòu):基礎(chǔ)額外更新
打掃衛(wèi)生
清潔速度最快的鏡子的上表面
[root @ kang vcar ~]# Yum make cache//在本地緩存Yum源,加快軟件的搜索和安裝
[root@kangvcar ~]# yum list//共列出9951個(gè)包
第四,修改百勝源的優(yōu)先級(jí)
當(dāng)既有本地Yum源又有163源的時(shí)候,我們?cè)诎惭b軟件包的時(shí)候當(dāng)然是想用本地Yum源來(lái)安裝軟件,然后在本地沒(méi)有包的時(shí)候用163源來(lái)安裝軟件,這就涉及到優(yōu)先級(jí)的問(wèn)題了。Yum提供的插件Yum-plugin-priorities.noarch可以解決這個(gè)問(wèn)題。
1.檢查系統(tǒng)是否安裝了優(yōu)先插件
[root @ kang vcar ~]# rpm-QA | grepyum-plugin-
yum-plugin-fastestmirror- 1.1。31- 34.el7.noarch
//我在這里看到插件yum-plugin-priorities.noarch沒(méi)有安裝
[root @ kang vcar ~]# yum search yum-plugin-priorities
//使用搜索查看該插件是否可用
加載的插件:快速鏡像
從緩存的主機(jī)文件加載鏡像速度
*基地:mirrors.aliyun. com
* extra s:mirrors.aliyun. com
*更新:mirrors.aliyun. com
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = N/S匹配:yum-plugin-priorities = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
yum-plugin-priorities . no arch:plugin to give priorities to package from不同的轉(zhuǎn)帖
2.安裝yum-plugin-priorities.noarch插件
[root @ kang vcar ~]# yum-y install yum-plugin-priorities . no arch
3.檢查插件是否已啟用
[root @ kang vcar ~]# cat/etc/yum/plugin cf . d/priorities . conf
[主要]
enabled = 1
//1已啟用;0已禁用
4.修改本地Yum源,先使用
[root @ kang vcar ~]# ll/etc/yum . repa . d/
總計(jì)8
-rw-r - r -。1 root root 2573 may 152015 centos-base . repo
-rw-r - r -。1 root root 67 jun 2006:04 local . repo
//有兩個(gè)回購(gòu)文件
[root @ kang vcar ~]# VI/etc/yum . repo . d/local . repo
[本地]
name=local
baseurl=file: ///opt/centos
enabled= 1
gpgcheck= 0
優(yōu)先級(jí)= 1
//在原優(yōu)先級(jí)上增加priority = 1;數(shù)字越小,優(yōu)先級(jí)越高
//可以繼續(xù)修改其他來(lái)源的優(yōu)先級(jí)值。測(cè)試后,只將本地源的優(yōu)先級(jí)配置為priority=1,優(yōu)先使用本地源。
5.測(cè)試
配置優(yōu)先級(jí)前:(使用阿里巴巴云百勝源)
[根@kangvcar ~]# yum - yinstall vim
依賴性已解決
=================================================================================================================================================
軟件包版本庫(kù)大小
=================================================================================================================================================
安裝g:
vim-增強(qiáng)型x86_64 2: 7.4。160- 1.el7_3。1更新1.0M
正在更新依賴項(xiàng):
vim-普通x86_64 2: 7.4。160- 1.el7_3。1更新5.9M
省略...
配置優(yōu)先級(jí)后:(使用本地Yum源)
[根@kangvcar ~]# yum - yinstall vim
依賴性已解決
=================================================================================================================================================
軟件包版本庫(kù)大小
=================================================================================================================================================
安裝g:
vim-增強(qiáng)型x86_64 2: 7.4。160-1.17本地1.0M
正在為依賴項(xiàng)安裝:
gpm-libs x86_64 1.20。7- 5.el7本地32k
perlx86_64 4: 5.16。3-286.17本地8.0M
perl-Carp no arch 1.26-244.17 local 19k
perl-Encode x86 _ 64 2.51-7.57本地1.5M
perl-Exporter no arch 5.68-3.el7 local 28k
本地26k
文件溫度0.23。01- 3.el7本地56k
省略...
Linux云計(jì)算與運(yùn)維架構(gòu)師高薪實(shí)踐班“2019年4月29日即將開課,120天Linux運(yùn)維年薪30萬(wàn),變化速度大概~ ~
1.《安裝yum Yum 慢到無(wú)法忍受?那是因?yàn)槟銢](méi)有這么做》援引自互聯(lián)網(wǎng),旨在傳遞更多網(wǎng)絡(luò)信息知識(shí),僅代表作者本人觀點(diǎn),與本網(wǎng)站無(wú)關(guān),侵刪請(qǐng)聯(lián)系頁(yè)腳下方聯(lián)系方式。
2.《安裝yum Yum 慢到無(wú)法忍受?那是因?yàn)槟銢](méi)有這么做》僅供讀者參考,本網(wǎng)站未對(duì)該內(nèi)容進(jìn)行證實(shí),對(duì)其原創(chuàng)性、真實(shí)性、完整性、及時(shí)性不作任何保證。
3.文章轉(zhuǎn)載時(shí)請(qǐng)保留本站內(nèi)容來(lái)源地址,http://f99ss.com/caijing/762569.html