查看当前系统环境
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-358.el6.x86_64#1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.4 (Santiago)
创建一个用于挂载的目录
[root@localhost yum.repos.d]# mkdir /mnt/cdrom -pv
mkdir: created directory `/mnt/cdrom'
[root@localhost yum.repos.d]# mount /dev/cdrom /mnt/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost yum.repos.d]# cd /mnt/cdrom/Server/
[root@localhost Server]# ll
total 139
-r--r--r--. 2 root root 137534 Jan 31 2013 listing
dr-xr-xr-x. 2 root root 4096 Jan 31 2013 repodata
-r--r--r--. 1 root root 439 Jan 31 2013 TRANS.TBL
删除原来的文件保留这个文件
[root@localhost yum.repos.d]# cat my.repo
[rhel]
name=Reda
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
然后查看一下
[root@localhost Server]# yum list all#记住这里一定要查看一下 要不可能还用不了
测试看看是否成功
[root@localhost Server]# yum install lsof -y
报错(一)
[root@localhost yum.repos.d]# yum install unzip -y
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository 'rhel': Error parsing config: Error parsing "baseurl = 'file///mnt/cdrom/Server'": URL must be http, ftp, file or https not ""
Setting up Install Process
No package unzip available.
Error: Nothing to do
错误原因:
[root@localhost yum.repos.d]# cat my.repo
[rhel]
name=Reda
baseurl=file///mnt/cdrom/Server#缺少: 这个符号导致的报错
enabled=1
gpgcheck=1
由于配置文件 baseurl路径不对 缺少了个:这个符号。
错误解决办法
[root@localhost yum.repos.d]# cat my.repo
[rhel]
name=Reda
baseurl=file:///mnt/cdrom/Server# 添加这个:符号
enabled=1
gpgcheck=1
报错(二)
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Public key for wget-1.12-1.8.el6.x86_64.rpm is not installed
解决办法
估计是yum源你没有导入密钥。提示说NOKEY。密钥一般都在/etc/pki/rpm-gpg这个文件夹下,
在root用户,或者sudo命令下
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*
把rpm-gpg目录下的密钥全部导入进去,可能会有错误提示,无视了。
然后在安装应该就可以了
[root@localhost yum.repos.d]# cd /etc/pki/rpm-gpg/
[root@localhost rpm-gpg]# ll
total 20
-rw-r--r--. 1 root root 3375 Jan 29 2013 RPM-GPG-KEY-redhat-beta
-rw-r--r--. 1 root root 1990 Jan 29 2013 RPM-GPG-KEY-redhat-legacy-former
-rw-r--r--. 1 root root 1164 Jan 29 2013 RPM-GPG-KEY-redhat-legacy-release
-rw-r--r--. 1 root root 885 Jan 29 2013 RPM-GPG-KEY-redhat-legacy-rhx
-rw-r--r--. 1 root root 3211 Jan 29 2013 RPM-GPG-KEY-redhat-release
[root@localhost rpm-gpg]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*
正确的yum文件内容
[root@localhost yum.repos.d]# cat my.repo
[rhel]
name=Reda
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=1