执行 yum install vim 命令后发现报错
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
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 find a valid baseurl for repo: base
解决办法:
1.备份 /etc/yum.repos.d 目录下文件
[root@node0 ~]# cd /etc/yum.repos.d/
[root@node0 yum.repos.d]# mkdir backup
[root@node0 yum.repos.d]# mv CentOS* backup
2.下载安装源
网址:http://mirrors.aliyun.com/repo/Centos-6.repo 下载repo文件, 放入/etc/yum.repos.d/
3.生成缓存
将 Centos-6.repo 文件中$releasever 修改为7 不然后期可能会报错
yum clean all--清除yum缓存
yum makecache--把服务器的包信息下载到本地电脑缓存起来
执行yum makecache 时报错,错误信息
注释掉上述Centos-6.repo中updates第二行代码
[updates]
name=CentOS-7 - Updates - mirrors.aliyun.com
#failovermethod=priority-------此行注释
baseurl=http://mirrors.aliyun.com/centos/7/updates/$basearch/
http://mirrors.aliyuncs.com/centos/7/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
重新执行yum makecache 成功解决
有的时候因为网络问题不允许联网,需要将yum源本地化
1.将Centos-6.repo 备份
cp Centos-6.repo Centos-6.repo.back
2.删除base下所有数据并修改 Centos-6.repo信息
# CentOS-6.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# 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=local
baseurl=file:///mnt
gpgcheck=1
enable=1
重新执行yum clean all yum makecache 报错
df -h 发现磁盘没有挂载
[root@node0 yum.repos.d]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 18G 1.2G 16G 7% /
tmpfs 491M 0 491M 0% /dev/shm
[root@node0 yum.repos.d]# mount /dev/cdrom /mnt
[root@node0 yum.repos.d]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 18G 1.2G 16G 7% /
tmpfs 491M 0 491M 0% /dev/shm
/dev/sda1 194M 28M 157M 15% /boot
重新执行yum makecache 成功