背景
今天在使用docker安装了centos7之后,使用yum去执行yum install net-tools失败了,出现了,出现了http://mirrors.163.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 400 - Bad Request错误。
问题
http://mirrors.163.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 400 - Bad Request。
解决办法
只需要将你所下载的配置源文件的baseURl地址里面的http协议改为https协议即可!
将/etc/yum.repos.d/CentOS-Base.repo文件中的baseurl路径这里的http协议全改为https即可,我这里采用的是http://mirrors.163.com源地址,你也可以尝试别的源地址。
配置文件可参照我的(CentOs7版本):
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=https://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=https://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=https://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=https://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
感想
我找了很多资源,说什么把centsOs里面的$releasever改为自己的版本,我试了很多次,没用!最后发现是因为400报错,权限访问不到,于是改了协议才可以!
当然,本次文章主要是因为我为了解决这个问题,研究了一下午!所以就记录一下啦~