1. 程式人生 > >CentOS 7.0本地yum源地址及 配置yum地址優先順序

CentOS 7.0本地yum源地址及 配置yum地址優先順序

感謝朋友支援本部落格,歡迎共同探討交流,由於能力和時間有限,錯誤之處在所難免,歡迎指正!

如有轉載,請保留源作者部落格資訊。

如需交流,歡迎大家部落格留言。

首先附上本地centos7.0yun源基礎地址及epel源地址:
vi /etc/yum.repos.d/CentOS-local.repo
新增如下內容:
[base-local] 
name=CentOS-local 
baseurl=http://192.168.1.200/yum/centos/7.0/os/x86_64 
gpgcheck=0 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 
priority=1 

[updates-local] 
name=CentOS-local 
baseurl=
http://192.168.1.200/yum/centos/7.0/updates/x86_64
 
gpgcheck=0 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 
priority=1
vi /etc/yum.repos.d/CentOS-local-epel.repo
新增如下內容:
[base-local-epel] 
name=CentOS-local 
baseurl=http://192.168.1.200/yum/epel/centos/7.0/os/x86_64/
gpgcheck=0 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 
priority=1 

1.安裝yum-plugin-priorities包

# yum install yum-plugin-priorities

2.修改/etc/yum.repos.d目錄中的CentOS-Base.repo、CentOS-local.repo的優先順序

//直接加上priority=N即可

附CentOS-Base.repo檔案的配置:

附CentOS-local.repo檔案的配置

由上圖可以看出本地yum源優先順序比官網base源高,因此在yum安裝包時,首先會在本地查詢,沒有找到才會去官網查詢。

4、驗證:

yum clean all yum install vim

上圖顯示vim的rpm包在本地base-local源中查詢。

備註:

1、要使priority引數有效,必須安裝yum-plugin-priorities外掛2、N為整型數.預設優先順序為99.數值越小優先順序越高;