方法一:
1. 配置yum.conf
终端输入以下命令
sudo chmod w /etc/yum.conf
sudo gedit /etc/yum.conf
将yum.conf配置如下
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
[base]
name=Red Hat Linux $releasever - $basearch - Base
baseurl= http://centos.ustc.edu.cn/centos/5.4/os/i386/
[updates]
name=Red Hat Linux $releasever - Updates
baseurl= http://mirror.centos.org/centos/5.4/updates/i386/
然后保存退出.
2. 测试
在终端输入命令:yum update
看一下效果!
方法二:
1. 查看当前安装的YUM软件包并将其删除
查看
在终端里输入以下命令
rpm -qa|grep yum
屏幕上会出现你已经安装的YUM包
删除
rpm -e XXXXXXXXX(刚才显示安装的包) --nodeps
就可以将你已经安装的包都删掉了.
不信你可以再用第一步的命令看下.
2. 下载CENTOS的YUM包并将下载包安装
下载
从http://centos.ustc.edu.cn/centos/5.4/os/i386/CentOS/下载以下文件并安装
yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
yum-3.2.22-20.el5.centos.noarch.rpm
yum-updatesd-0.9-2.el5.noarch.rpm
或者找个FTP站点用wget下载:
#wget ftp://ftp.pdc.kth.se/pub/bambi/centos/5.4/os/i386/CentOS/yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
#wget ftp://ftp.pdc.kth.se/pub/bambi/centos/5.4/os/i386/CentOS/yum-3.2.22-20.el5.centos.noarch.rpm
#wget ftp://ftp.pdc.kth.se/pub/bambi/centos/5.4/os/i386/CentOS/yum-updatesd-0.9-2.el5.noarch.rpm
在终端进入你下载以上文件的文件夹,本人是/root/download/,并安装下载的包
#cd /root/download/
#rpm -ivh yum*.rpm
你可以看到安装进度.
3. 修改自己的CentOS-Base.repo
#cd /etc/yum.repos.d
#mv rhel-debuginfo.repo rhel-debuginfo.repo.bak (备份原来的配置文件)
建一个文件名字叫CentOS-Base.repo,然后配置如下:
# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# 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=CentOS-$releasever - Base
baseurl=http://centos.ustc.edu.cn/centos/5.4/os/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://centos.ustc.edu.cn/centos/5.4/updates/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
baseurl=http://centos.ustc.edu.cn/centos/5.4/addons/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://centos.ustc.edu.cn/centos/5.4/extras/$basearch/
gpgcheck=1
gpgkey=ht |