当前位置:  首页  >  服务器技术  >  Linux/unix  >  Linux教程

RHEL5.4和CENTOS的YUM升级-Enthusiasm 10年

方法一:1.配置yum.conf终端输入以下命令sudochmod+wetcyum.confsudogeditetcyum.conf将yum.conf配置如下[main]cachedirvarcacheyumdebuglevel2logfilevarlogyum.logpkgpolicynewestdistroverpkgredhat-releasetolerant1


方法一:
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=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://centos.ustc.edu.cn/centos/5.4/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

注:如果http://centos.ustc.edu.cn/centos这个服务器的CentOS映像不够快的话用自己适合的服务器替换,可以用IE上去先找找看~

4. 导入KEY文件,注意大小写
rpm --import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
或者
rpm --import http://centos.arcticnetwork.ca/5.4/os/i386/RPM-GPG-KEY-CentOS-5

5. 测试
#yum update

出来了~
[root@localhost download]# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
addons                                                                                                                  |  951 B     00:00    
addons/primary                                                                                                    |  201 B     00:00    
base                                                                                                                      | 2.1 kB     00:00    
base/primary_db                                                                                                  | 1.6 MB     00:09    
extras                                                                                                                  | 1.1 kB     00:00    
extras/primary                                                                                                    | 107 kB     00:00    
extras                                                                                                                                 325/325
updates                                                                                                                 | 1.9 kB     00:00    

吐了个 "CAO" !
扫码关注 PHP1 官方微信号
PHP1.CN | 中国最专业的PHP中文社区 | PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | PHP问答
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved PHP1.CN 第一PHP社区 版权所有