Centos6 使用 yum 命令安装软件时报错
从2020年12月开始,将 CentOS6 相关的软件源移出了官方源,这样在使用 yum 命令安装软件时会出现如下错误:
[root@ora2 ~]# yum install -y vim Loaded plugins: fastestmirror YumRepo Error: All mirror URLs are not using ftp, http[s] or file. Eg. Invalid release/repo/arch combination/ removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
解决方法如下:
step1 关闭 fastestmirrors
执行如下命令:
vi /etc/yum/pluginconf.d/fastestmirror.conf [main] enabled=0 # 把 enabled 选项的参数由 1 改为 0 verbose=0 always_print_best_host = true socket_timeout=3 # Relative paths are relative to the cachedir (and so works for users as well # as root). hostfilepath=timedhosts.txt maxhostfileage=10 maxthreads=15 #exclude=.gov, facebook #include_only=.nl,.de,.uk,.ie
step2 设置 yum 源
执行如下命令:
[root@ora1 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak [root@ora1 ~]# cd /etc/yum.repos.d/ [root@ora1 yum.repos.d]# ls CentOS-Base.repo.bak CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo [root@oracle yum.repos.d]# yum clean all Cleaning repos: Cleaning up Everything [root@oracle yum.repos.d]# yum makecache Metadata Cache Created [root@ora1 yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Aliyun.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 102 1749 102 1749 0 0 2096 0 --:--:-- --:--:-- --:--:-- 9825
step3 测试 yum 命令
yum 安装文本编辑器 vim,OK!
[root@ora1 yum.repos.d]# yum install -y wget base | 3.7 kB 00:00 base/primary_db | 4.7 MB 00:03 extras | 3.4 kB 00:00 extras/primary_db | 29 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 12 MB 00:09 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package wget.x86_64 0:1.12-10.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================&