本文参考自: http://hi.baidu.com/wang01ning/item/9f2a1859975ad615abf6d767
在redhat中使用yum进行包管理时, 遇到以下错误:
[root@localhost Server]# yum install sudo Loaded plugins: rhnplugin, security This system is not registered with RHN. RHN support will be disabled. Setting up Install Process No package sudo available. Nothing to do
解决方案:
- 卸载redhat的yum包
[root@localhost Server]# rpm -qa | grep yum yum-updatesd-0.9-2.el5 yum-security-1.1.16-13.el5 yum-metadata-parser-1.1.2-3.el5 yum-3.2.22-20.el5 yum-rhn-plugin-0.5.4-13.el5
[root@localhost Server]# rpm -e –nodeps yum-updatesd-0.9-2.el5 yum-security-1.1.16-13.el5 yum-metadata-parser-1.1.2-3.el5 yum-3.2.22-20.el5 yum-rhn-plugin-0.5.4-13.el5
- 切换到要yum包保存的目录中
[root@localhost Server]# cd /software/share
- 下载centos的yum包
[root@localhost share]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm –2013-11-15 04:35:16– http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm Resolving centos.ustc.edu.cn… 202.141.160.110, 2001:da8:d800:95::110 Connecting to centos.ustc.edu.cn|202.141.160.110|:80… connected. HTTP request sent, awaiting response… 200 OK Length: 1034960 (1011K) [application/x-redhat-package-manager] Saving to: `yum-3.2.22-40.el5.centos.noarch.rpm’ 100%[====================================================================>] 1,034,960 1.54M/s in 0.6s 2013-11-15 04:35:16 (1.54 MB/s) - `yum-3.2.22-40.el5.centos.noarch.rpm’ saved [1034960/1034960]
[root@localhost share]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm –2013-11-15 04:37:16– http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm Resolving centos.ustc.edu.cn… 202.141.160.110, 2001:da8:d800:95::110 Connecting to centos.ustc.edu.cn|202.141.160.110|:80… connected. HTTP request sent, awaiting response… 200 OK Length: 21033 (21K) [application/x-redhat-package-manager] Saving to: `yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm’ 100%[====================================================================>] 21,033 –.-K/s in 0.03s 2013-11-15 04:37:16 (709 KB/s) - `yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm’ saved [21033/21033]
[root@localhost share]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm –2013-11-15 04:38:08– http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm Resolving centos.ustc.edu.cn… 202.141.160.110, 2001:da8:d800:95::110 Connecting to centos.ustc.edu.cn|202.141.160.110|:80… connected. HTTP request sent, awaiting response… 200 OK Length: 26164 (26K) [application/x-redhat-package-manager] Saving to: `yum-metadata-parser-1.1.2-4.el5.i386.rpm’ 100%[====================================================================>] 26,164 –.-K/s in 0.04s 2013-11-15 04:38:08 (575 KB/s) - `yum-metadata-parser-1.1.2-4.el5.i386.rpm’ saved [26164/26164]
4.安装centos的yum包
[root@localhost share]# rpm -ivh yum-*
warning: yum-3.2.22-40.el5.centos.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e8562897 Preparing… ########################################### [100%] 1:yum-metadata-parser ########################################### [ 33%] 2:yum-fastestmirror ########################################### [ 67%] 3:yum ########################################### [100%]
5.下载CentOS-Base.repo
[root@localhost share]# wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo –2013-11-15 04:41:48– http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo Resolving docs.linuxtone.org… 117.79.157.57 Connecting to docs.linuxtone.org|117.79.157.57|:80… connected. HTTP request sent, awaiting response… 200 OK Length: 1426 (1.4K) [application/octet-stream] Saving to: `CentOS-Base.repo’ 100%[================================================================================>] 1,426 –.-K/s in 0s 2013-11-15 04:41:49 (133 MB/s) - `CentOS-Base.repo’ saved [1426/1426]
6.将repo移动到相应的目录
[root@localhost share]# mv CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
7.制作缓存
[root@localhost share]# yum makecache Loaded plugins: fastestmirror Determining fastest mirrors addons | 1.9 kB 00:00 addons/filelists_db | 574 B 00:00 addons/other_db | 550 B 00:00 addons/primary_db | 1.1 kB 00:00 base | 1.1 kB 00:00 base/filelists | 3.1 MB 00:01 base/other | 11 MB 00:08 base/group | 1.1 MB 00:00 base/primary | 995 kB 00:00 extras | 2.1 kB 00:00 extras/filelists_db | 211 kB 00:00 extras/other_db | 431 kB 00:00 extras/group | 9.7 kB 00:00 extras/primary_db | 164 kB 00:00 update | 1.9 kB 00:00 update/filelists_db | 522 kB 00:00 update/other_db | 2.5 MB 00:01 update/primary_db | 109 kB 00:00 base 2789/2789 base 2789/2789 base 2789/2789 Metadata Cache Created
- 至此, 可以正常使用yum进行install操作了
[root@localhost share]# yum install sudo Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Setting up Install Process Resolving Dependencies –> Running transaction check —> Package sudo.i386 0:1.7.2p1-28.el5 set to be updated –> Finished Dependency Resolution Dependencies Resolved
Package Arch Version Repository Size
Installing: sudo i386 1.7.2p1-28.el5 base 357 k Transaction Summary
Install 1 Package(s) Upgrade 0 Package(s) Total download size: 357 k Is this ok [y/N]: y Downloading Packages: sudo-1.7.2p1-28.el5.i386.rpm | 357 kB 00:00 warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897 base/gpgkey | 1.5 kB 00:00 Importing GPG key 0xE8562897 “CentOS-5 Key (CentOS 5 Official Signing Key) <centos-5-key@centos.org>” from http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 Is this ok [y/N]: y Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : sudo 1/1 Installed: sudo.i386 0:1.7.2p1-28.el5 Complete!