Centos7上配置网络和本地yum方法

配置网络yum源

前提:1.这个系统能上网

2.vim /etc/resolv.conf

nameserver 8.8.8.8

nameserver 114.114.114.114

操作如下:

1.mkdir /etc/yum.repos.d/rpm

mv /etc/yum.repos.d/* /etc/yum.repos.d/rpm   #将这下面的原来就有源移动到rpm目录下

2.下载网络yum,比如阿里源,163源,epel源(可用)

wget http://mirrors.aliyun.com/repo/Centos-7.repo

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/Centos7-Base-163.repo

rpm -vih http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm

配置本地yum

前提桌面或者系统内有镜像有镜像

1.mkdir /ming    #创建挂载镜像的地方

2.vim /etc/yum.repos.d/local.repo

[base]

name=localrepo

baseurl=file:///ming    #本地镜象挂载的地方

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

配置优先级,越小越优先

1.安装组件rpm -ivh yum-plugin-priorities-1.1.31-40.el7.noarch.rpm

2.在本地yum上local.repo

最末行添加

priority=1

3.而在阿里源,163源上配置

每个节点上,即[*]后

最末行添加

priority=2

4.最后执行

yum clean all

yum makecache

原文地址:https://www.cnblogs.com/ming369/p/9622213.html