系统:
[root@abc mnt]# more /etc/redhat-release Red Hat Enterprise Linux Server release 6.7 (Santiago) [root@abc mnt]#
首先执行yum安装发现报错:
[root@abc iso]# yum install vim -bash: yum: command not found
检查发现没有yum安装:
# 发现的确有镜像 [root@abc home]# du -sh * 3.6G iso 16K zabbix [root@abc home]# cd iso/ [root@abc iso]# ll 总用量 3763204 -rw-r--r-- 1 root root 3853516800 9月 10 2018 rhel-server-6.5-x86_64-dvd.iso # 但是yum找不到 [root@abc iso]# rpm -qa |grep yum [root@abc iso]# pwd /home/iso [root@abc iso]#
好吧,从阿里找对应系统的rpm包来安装,因为可以访问外网,直接下载了:参考:https://blog.csdn.net/qq_37460356/article/details/79568387
[root@abc rpm]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm [root@abc rpm]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm [root@abc rpm]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-cron-3.2.29-81.el6.centos.noarch.rpm [root@abc rpm]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm [root@abc rpm]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm --2019-04-09 20:31:52-- http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm 正在解析主机 mirrors.163.com... 59.111.0.251 正在连接 mirrors.163.com|59.111.0.251|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 404 Not Found 2019-04-09 20:31:52 错误 404:Not Found。 [root@abc rpm]# ^C [root@abc rpm]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm --2019-04-09 20:32:58-- http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm 正在解析主机 mirrors.163.com... 59.111.0.251 正在连接 mirrors.163.com|59.111.0.251|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:33692 (33K) [application/x-redhat-package-manager] 正在保存至: “yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm” 100%[=====================================================================================================================================================>] 33,692 --.-K/s in 0.02s 2019-04-09 20:32:58 (1.69 MB/s) - 已保存 “yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm” [33692/33692]) [root@abc rpm]# [root@abc rpm]#
然后把下载的rpm包安装上:
[root@abc rpm]# [root@abc rpm]# rpm -ivh *rpm --nodeps --force warning: python-urlgrabber-3.9.1-11.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Preparing... ########################################### [100%] 1:yum-metadata-parser ########################################### [ 20%] 2:python-urlgrabber ########################################### [ 40%] 3:yum-plugin-fastestmirro########################################### [ 60%] 4:yum ########################################### [ 80%] 5:yum-cron ########################################### [100%] [root@abc rpm]# yum install vim 已加载插件:fastestmirror, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 设置安装进程 file:///mnt/cdrom/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/cdrom/repodata/repomd.xml 尝试其他镜像。 错误:Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again [root@i-B56C455B rpm]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo --2019-04-09 20:34:37-- http://mirrors.aliyun.com/repo/Centos-6.repo 正在解析主机 mirrors.aliyun.com... 175.6.29.216, 114.80.179.243, 117.91.183.226, ... 正在连接 mirrors.aliyun.com|175.6.29.216|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:2523 (2.5K) [application/octet-stream] 正在保存至: “/etc/yum.repos.d/CentOS-Base.repo” 100%[=====================================================================================================================================================>] 2,523 --.-K/s in 0s 2019-04-09 20:34:37 (269 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523]) [root@abc rpm]# [root@abc rpm]#
还是不能执行,然后检查了yum配置文件,发现有很多多余的repo:
[root@abc rpm]# cd /etc/yum.repos.d/ [root@abc yum.repos.d]# ll 总用量 20 -rw-r--r-- 1 root root 2523 6月 16 2018 CentOS-Base.repo -rw-r--r-- 1 root root 75 2月 7 2017 local.repo -rw-r--r-- 1 root root 131 9月 10 2018 my.repo -rw-r--r--. 1 root root 358 2月 7 2017 redhat.repo -rw-r--r--. 1 root root 529 6月 12 2015 rhel-source.repo [root@abc yum.repos.d]# mkdir bak [root@abc yum.repos.d]# mv CentOS-Base.repo bak/ [root@abc yum.repos.d]# mv local.repo bak/ [root@abc yum.repos.d]# mv redhat.repo bak/ [root@abc yum.repos.d]# mv rhel-source.repo bak/
还是继续报错:
[root@abc yum.repos.d]# [root@abc yum.repos.d]# yum install vim 已加载插件:fastestmirror, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 设置安装进程 Loading mirror speeds from cached hostfile file:///mnt/cdrom/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/cdrom/repodata/repomd.xml 尝试其他镜像。 错误:Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
检查配置:
# 检查repo配置 [root@abc mnt]# more /etc/yum.repos.d/my.repo [base] name = RedHat iso baseurl = file:///mnt/cdrom enable = 1 gpgcheck = 0 gpgkey = file:///mnt/cdrom/RPM-GPG-KEY-redhat-release [root@abc mnt]# cd cdrom/ # 发现镜像未挂载上 [root@i-B56C455B yum.repos.d]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda2 55G 49G 3.9G 93% / tmpfs 16G 72K 16G 1% /dev/shm /dev/vdb 197G 76G 112G 41% /mnt
[root@abc yum.repos.d]#
重新挂载,检查:
[root@abc mnt]# mount -o loop /home/iso/rhel-server-6.5-x86_64-dvd.iso /mnt/cdrom/ [root@abc mnt]# yum install vim 已加载插件:fastestmirror, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 设置安装进程 Loading mirror speeds from cached hostfile base | 3.9 kB 00:00 ... base/primary_db | 3.1 MB 00:00 ... 匹配 2:vim-enhanced-7.2.411-1.8.el6.x86_64 的软件包已经安装。检查更新。 无须任何处理 [root@abc mnt]#
终于恢复正常了。。。