首先附上本地CentOS 7.0 yun源基础地址及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.数值越小优先级越高;
RedHat 6.2 Linux修改yum源免费使用CentOS源