Redhat AS4和AS5快速升级至CentOS系统

单位很多服务器都是RedHat AS4和AS5的机器,平时经常需要安装和编译软件包,升级到CentOS系统能够方便不少!

网上查阅了相关资料,但是都不尽如人意,最终自己摸索出以下方法,和大家一起分享!

查看当前系统版本号
# less /etc/redhat-release
检查系统已安装的组件包中是否已存在Redhat的自带的yum系列组件包
# su root
# rpm -qa | grep yum
如果存在请逐一全部删除
# rpm -e --nodeps 组件包名称
建立Centos专用目录,然后下载并安装Centos系统的yum系列组件包
# su webuser
# cd /home/webuser
# mkdir centos
下载Centos升级组件包(注:根据RedHat AS4或RedHat AS5分别操作)
RedHat AS4:
# wget http://centos.ustc.edu.cn/centos/4.7/os/i386/CentOS/RPMS/python-elementtree-1.2.6-5.el4.centos.i386.rpm
# wget http://centos.ustc.edu.cn/centos/4.7/os/i386/CentOS/RPMS/python-sqlite-1.1.7-1.2.1.i386.rpm
# wget http://centos.ustc.edu.cn/centos/4.7/os/i386/CentOS/RPMS/python-urlgrabber-2.9.8-2.noarch.rpm
# wget http://centos.ustc.edu.cn/centos/4.7/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm
# wget http://centos.ustc.edu.cn/centos/4.7/os/i386/CentOS/RPMS/yum-2.4.3-4.el4.centos.noarch.rpm
# wget http://centos.ustc.edu.cn/centos/4.7/os/i386/CentOS/RPMS/yum-metadata-parser-1.0-8.el4.centos.i386.rpm
# wget http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4
RedHat AS5:
# wget http://centos.ustc.edu.cn/centos/5.3/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
# wget http://centos.ustc.edu.cn/centos/5.3/os/i386/CentOS/yum-3.2.19-18.el5.centos.noarch.rpm
# wget http://centos.ustc.edu.cn/centos/5.3/os/i386/CentOS/yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
# wget http://centos.ustc.edu.cn/centos/5.3/os/i386/CentOS/yum-metadata-parser-1.1.2-2.el5.i386.rpm
# wget http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
安装Centos升级组件包
# su root
# rpm -Uvh --nodeps /home/webuser/centos/*.rpm
导入Centos升级组件授权(注:根据RedHat AS4或RedHat AS5分别操作)
RedHat AS4:
# rpm --import /home/webuser/centos/RPM-GPG-KEY-CentOS-4
RedHat AS5:
# rpm --import /home/webuser/centos/RPM-GPG-KEY-CentOS-5
创建并编辑yum升级源配置文件
# su root
# mkdir -p /etc/yum.repos.d/
# vi /etc/yum.repos.d/CentOS-Base.repo
粘贴以下内容覆盖文件:
RedHat AS4:
[base]
name=CentOS-$releasever - Base
baseurl=http://centos.ustc.edu.cn/centos/4.7/os/$basearch/
gpgcheck=1
gpgkey= http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4
#released updates
[update]
name=CentOS-$releasever - Updates
baseurl=http://centos.ustc.edu.cn/centos/4.7/updates/$basearch/
gpgcheck=1
gpgkey= http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
baseurl=http://centos.ustc.edu.cn/centos/4.7/addons/$basearch/
gpgcheck=1
gpgkey= http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://centos.ustc.edu.cn/centos/4.7/extras/$basearch/
gpgcheck=1
gpgkey= http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://centos.ustc.edu.cn/centos/4.7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey= http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
baseurl=http://centos.ustc.edu.cn/centos/4.7/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey= http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4
RedHat AS5:
[base]
name=CentOS-$releasever - Base
baseurl=http://centos.ustc.edu.cn/centos/5.3/os/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
#released updates
[update]
name=CentOS-$releasever - Updates
baseurl=http://centos.ustc.edu.cn/centos/5.3/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.3/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.3/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.3/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
baseurl=http://centos.ustc.edu.cn/centos/5.3/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
核对后保存并退出
开始升级系统
# yum update
等待系统列出需要升级的组件清单并按”y”确认
Total download size: 334 M
Is this ok [y/n]: y
Complete!
等待全部组件下载完成后,重新启动服务器,操作系统升级完毕!

相关推荐