版本升级是经常的,但升级后脚本就不能用了,所以今天特意做了个分析 Packeges 获取所需 rpm 包的脚本,以将这一切自动化,
从 RHEL 6.x 直接升级为Centos 6.x,注意,将 version 改为当前的版本号,本人已经测试6.4可以正常工作
将内容另存为一个 sh 文件,执行即可(for x86_64):
1 #! /bin/sh 2 3 version="6.4" 4 5 download_files() 6 { 7 base_url="http://mirror.centos.org/centos/${version}/os/x86_64/RPM-GPG-KEY-CentOS-6" 8 package_url="http://mirror.centos.org/centos/${version}/os/x86_64/Packages/" 9 10 cat >pattern <<-EEE 11 centos-release-[\d\.\-]+.el6.centos.\d+.x86_64.rpm 12 yum-[\d\.\-]+.el6.centos.noarch.rpm 13 yum-utils-[\d\.\-]+.el6.noarch.rpm 14 yum-plugin-fastestmirror-[\d\.\-]+.el6.noarch.rpm 15 EEE 16 17 echo "download $package_url" 18 wget "$package_url" 19 20 echo "get files to be downloaded" 21 pcregrep -f pattern index.html |awk -F'><' '{print $5 $5 $6}'|awk -F'"' '{print $2}' >founded_fiels 22 23 for i in `cat founded_fiels`; 24 do 25 echo "wget ${package_url}${i}" 26 wget "${package_url}${i}" 27 done 28 29 wget "$base_url" 30 } 31 32 yum clean all 33 mkdir ~/centos; cd ~/centos 34 download_files 35 36 rpm --import RPM-GPG-KEY-CentOS-6 37 rpm -e --nodeps redhat-release-server 38 rpm -e yum-rhn-plugin rhn-check rhnsd rhn-setup rhn-setup-gnome 39 rpm -Uhv --force *.rpm 40 yum upgrade
老式脚本
从 RHEL 6.x 直接升级为Centos 6.3
直接在命令行执行如下语句即可(for x86_64):
1 yum clean all 2 mkdir ~/centos; cd ~/centos 3 wget http://mirror.centos.org/centos/6.3/os/x86_64/RPM-GPG-KEY-CentOS-6 4 wget http://mirror.centos.org/centos/6.3/os/x86_64/Packages/centos-release-6-3.el6.centos.9.x86_64.rpm 5 wget http://mirror.centos.org/centos/6.3/os/x86_64/Packages/yum-3.2.29-30.el6.centos.noarch.rpm 6 wget http://mirror.centos.org/centos/6.3/os/x86_64/Packages/yum-utils-1.1.30-14.el6.noarch.rpm 7 wget http://mirror.centos.org/centos/6.3/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm 8 rpm --import RPM-GPG-KEY-CentOS-6 9 rpm -e --nodeps redhat-release-server 10 rpm -e yum-rhn-plugin rhn-check rhnsd rhn-setup rhn-setup-gnome 11 rpm -Uhv --force *.rpm 12 yum upgrade