出现的问题:
[hadoop@hadoop ~]$ sudo yum install mysql-server 已加载插件:fastestmirror, langpacks Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的名称或服务" One of the configured repositories failed (未知), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this: 1. Contact the upstream for the repository and get them to fix the problem. 2. Reconfigure the baseurl/etc. for the repository, to point to a working upstream. This is most often useful if you are using a newer distribution release than is supported by the repository (and the packages for the previous distribution release still work). 3. Run the command with the repository temporarily disabled yum --disablerepo=<repoid> ... 4. Disable the repository permanently, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage: yum-config-manager --disable <repoid> or subscription-manager repos --disable=<repoid> 5. Configure the failing repository to be skipped, if it is unavailable. Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: base/7/x86_64
你遇到的问题是因为 yum
无法解析 mirrorlist.centos.org
,并且尝试使用默认的 CentOS 镜像列表失败。解决这个问题的方法之一是直接指定一个可靠的镜像站点,而不是使用镜像列表。
处理步骤如下:
1. 备份原始文件
首先备份原始的 CentOS 库配置文件,以防需要恢复。
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2. 修改 YUM 配置文件
sudo vi /etc/yum.repos.d/CentOS-Base.repo(将原文件中的[base]后面的删除,报错以下的CentOS镜像)
编辑 /etc/yum.repos.d/CentOS-Base.repo 文件,将 mirrorlist 替换为具体的镜像 URL。以下是一个示例配置,使用阿里云提供的 CentOS 镜像:
[base] name=CentOS Base Repo #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=stock baseurl=http://mirrors.aliyun.com/centos/7/os/x86_64/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=stock baseurl=http://mirrors.aliyun.com/centos/7/updates/x86_64/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=stock baseurl=http://mirrors.aliyun.com/centos/7/extras/x86_64/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages [reserves] name=CentOS-Sources #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=sources&infra=stock baseurl=http://mirrors.aliyun.com/centos/7/source/SRPMS/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
3. 保存并退出编辑器
在 vi 编辑器中保存并退出:
- 按 Esc 键;
- 输入 :wq;
- 按回车键。
4. 清除缓存并尝试安装
清除 yum 的缓存并尝试安装 MySQL Server:
- sudo yum clean all
- sudo yum makecache
- sudo yum install mysql-server
如果依旧会出现问题failure: repodata/repomd.xml from reserves: [Errno 256] No more mirrors to try. http://mirrors.aliyun.com/centos/7/source/SRPMS/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found请进行一下步骤:
①尝试进行永久禁用 reserves
仓库:
- sudo yum-config-manager --disable reserves
②禁用后,再次尝试创建缓存:
- udo yum makecache
③ 在执行完命令后,都可以通过以下命令来验证仓库的状态:
- sudo yum repolist
④继续安装 MySQL Server
一旦缓存建立成功,你可以继续安装 MySQL Server:
- sudo yum install mysql-server