日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
CentOS配置本地yum源和優(yōu)先級(jí)的方法

這篇“CentOS配置本地yum源和優(yōu)先級(jí)的方法”文章的知識(shí)點(diǎn)大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細(xì),步驟清晰,具有一定的借鑒價(jià)值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來(lái)看看這篇“CentOS配置本地yum源和優(yōu)先級(jí)的方法”文章吧。

十多年的分宜網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。網(wǎng)絡(luò)營(yíng)銷推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整分宜建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)從事“分宜網(wǎng)站設(shè)計(jì)”,“分宜網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

一、用centos鏡像搭建本地yum源

由于安裝centos后的默認(rèn)yum源為centos的官方地址,所以在國(guó)內(nèi)使用很慢甚至無(wú)法訪問(wèn),所以一般的做法都是把默認(rèn)的yum源替換成aliyun的yum源或者163等國(guó)內(nèi)的yum源(下文介紹如何配置)。

但是以上的方法都是需要網(wǎng)絡(luò)的,當(dāng)沒(méi)有網(wǎng)絡(luò)的時(shí)候就無(wú)法使用了,所以還有一個(gè)常用的方法就是用centos的iso鏡像搭建本地yum源,這樣安裝軟件的速度就會(huì)飛快,缺點(diǎn)是可能有些包沒(méi)有。

1.安裝centos后默認(rèn)的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.把默認(rèn)yum源備份(可選)

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

3.在虛擬機(jī)上掛載centos鏡像文件

CentOS配置本地yum源和優(yōu)先級(jí)的方法

[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個(gè)包

二、把默認(rèn)的centos yum源修改成國(guó)內(nèi)的aliyun yum源

阿里云官方教程:

1.安裝centos后默認(rèn)的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.把默認(rèn)yum源備份(可選)

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

3.下載aliyun yum源repo文件(對(duì)應(yīng)自己的系統(tǒng)版本下載即可)

#各系統(tǒng)版本repo文件對(duì)應(yīng)的下載操作
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    //查看系統(tǒng)的版本
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個(gè)包

三、把默認(rèn)的centos yum源修改成國(guó)內(nèi)的163源

163官方教程:

1.安裝centos后默認(rèn)的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.把默認(rèn)yum源備份(可選)

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

3.下載163 yum源repo文件

#各系統(tǒng)版本repo文件對(duì)應(yīng)的下載操作
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    //查看系統(tǒng)的版本
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個(gè)包

四、修改yum源的優(yōu)先級(jí)

ps:當(dāng)既有本地yum源又有163源的時(shí)候,我們?cè)谘b軟件包的時(shí)候當(dāng)然希望先用本地的yum源去安裝,本地找不到可用的包時(shí)再使用163源去安裝軟件,這里就涉及到了優(yōu)先級(jí)的問(wèn)題,yum提供的插件yum-plugin-priorities.noarch可以解決這個(gè)問(wèn)題

1.查看系統(tǒng)是否安裝了優(yōu)先級(jí)的插件

[root@kangvcar ~]# rpm -qa | grep yum-plugin-
yum-plugin-fastestmirror-1.1.31-34.el7.noarch    
//這里看到?jīng)]有安裝yum-plugin-priorities.noarch這個(gè)插件
[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源優(yōu)先使用

[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
//有兩個(gè)repo文件
[root@kangvcar ~]# vi /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///opt/centos
enabled=1
gpgcheck=0
priority=1
//在原基礎(chǔ)上加入priority=1 ;數(shù)字越小優(yōu)先級(jí)越高
//可以繼續(xù)修改其他源的priority值,經(jīng)測(cè)試僅配置本地源的優(yōu)先級(jí)為priority=1就會(huì)優(yōu)先使用本地源了

5.測(cè)試

配置優(yōu)先級(jí)前:(使用阿里云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
省略···
配置優(yōu)先級(jí)后:(使用本地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
省略···

以上就是關(guān)于“CentOS配置本地yum源和優(yōu)先級(jí)的方法”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對(duì)大家有幫助,若想了解更多相關(guān)的知識(shí)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。


網(wǎng)站名稱:CentOS配置本地yum源和優(yōu)先級(jí)的方法
本文網(wǎng)址:http://www.dlmjj.cn/article/iighjh.html