备份本地源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
配置CentOS6(aliyun)
$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
$ sed -i ‘s/$releasever/6/g’ /etc/yum.repos.d/CentOS-Base.repo
配置CentOS7(aliyun)
$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
$ sed -i ‘s/$releasever/7/g’ /etc/yum.repos.d/CentOS-Base.repo
配置Nexus3私服YUM源(可选,适用于中小企业)
注:没有搭建nexus3-yum私服,请直接忽略此步骤
$ vim CentOS-Base.repo
针对于centos7的样例
[base]
name=Nexus
baseurl=http://192.168.1.100:8081/repository/yum-public/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://192.168.1.100:8081/repository/yum-public/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever-Updates-custom
baseurl=http://192.168.1.100:8081/repository/yum-public/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://192.168.1.100:8081/repository/yum-public/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever-Extras-custom
baseurl=http://192.168.1.100:8081/repository/yum-public/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://192.168.1.100:8081/repository/yum-public/RPM-GPG-KEY-CentOS-7
[centosplus]
name=CentOS-$releasever-Plus-custom
baseurl=http://192.168.1.100:8081/repository/yum-public/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://192.168.1.100:8081/repository/yum-public/RPM-GPG-KEY-CentOS-7
清理
$ yum clean all
$ yum list all
可能遇到的问题
安装网络yum源时遇到异常
$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)… failed: Temporary failure in name resolution.
wget: unable to resolve host address ?.irrors.aliyun.com?
解决办法:
$ vim /etc/resolv.conf
nameserver 114.114.114.114
nameserver 8.8.8.8
原文链接:https://www.cnblogs.com/zyrs/p/13653173.html
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/5701