错误提示如下
[root@newings yum.repos.d]# yum -c /etc/yum.conf --installroot=/usr/local/wget install wget -y Loaded plugins: fastestmirror Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com http://mirrors.aliyun.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found" Trying other mirror. http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: (28, 'connect() timed out!') Trying other mirror. http://mirrors.cloud.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.cloud.aliyuncs.com'" Trying other mirror. Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
解释下两个参数
-c /etc/yum.com #指定Yum配置文件地址
--installroot=/usr/local/wget #指定所安装软件的路径
该错误是由于$releasever和$basearch这两个变量中任何一个无法识别都会出现上面的错误,所以在配置yum源的时候首先要确认这两个变量是否存在。
如果变量不存在就用数字6和i386/x86_64代替。
我的配置如下
[base] name=CentOS-6 - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/6/os/x86_64/ http://mirrors.aliyuncs.com/centos/6/os/x86_64/ http://mirrors.cloud.aliyuncs.com/centos/6/os/x86_64/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-6 - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/6/updates/x86_64/ http://mirrors.aliyuncs.com/centos/6/updates/x86_64/ http://mirrors.cloud.aliyuncs.com/centos/6/updates/x86_64/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-6 - Extras - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/6/extras/x86_64/ http://mirrors.aliyuncs.com/centos/6/extras/x86_64/ http://mirrors.cloud.aliyuncs.com/centos/6/extras/x86_64/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-6 - Plus - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/6/centosplus/x86_64/ http://mirrors.aliyuncs.com/centos/6/centosplus/x86_64/ http://mirrors.cloud.aliyuncs.com/centos/6/centosplus/x86_64/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-6 - Contrib - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/6/contrib/x86_64/ http://mirrors.aliyuncs.com/centos/6/contrib/x86_64/ http://mirrors.cloud.aliyuncs.com/centos/6/contrib/x86_64/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6