When using yum for package management in redhat, I encountered the following error:
[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
Solution:
1. uninstall the redhat yum package
[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 –nodepsyum-updatesd-0.9-2.el5yum-security-1.1.16-13.el5yum-metadata-parser-1.1.2-3.el5yum-3.2.22-20.el5yum-rhn-plugin-0.5.4-13.el5
2. switch to the directory where you want to save the yum package
[root@localhost Server]#cd /software/share
3. Download the yum package for centos
[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. Install the centos yum package
[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.Download 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. Move the repo to the appropriate directory
[root@localhost share]# mv CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
7. Make a cache
[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
8. At this point, you can use yum for install operations normally
[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) <[email protected]>” 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!