CentOS Upgrade

/home/israel/centosupgrade

RHEL - CentOS Tranformación y Actualización

Se deseaba actualizar un servidor RedHat Enterprise Linux 4 a CentOS 5.3, ya que el usuario para actualizar el RHEL con RHN no se tiene (no se supo donde quedo), por lo cual el RHEL no se podria actualizar. 

Para esto se tiene a CentOS (Community ENTerprise Operating System), que es RHEL pero mas barato.

Primero se instaló el RHEL 4 básico, con servicio SSH, en un hardware DELL 2650 (ya medio oldie).

Despues teniamos que transformar a RHEL en CentOS, para lo cual se utilizó lo siguiente:

Converting RHEL 4 to CentOS 4

Updating your system
For best results, you should perform one final software update of your RHEL 4.x system with the "up2date" tool. Run "up2date --force --update" as root to ensure the latest kernel patches and security fixes are installed.

Downloading Required Packages
To begin, you will need to download the following packages. It's best to create a temporary directory for the packages, and download them to that temporary directory.

Depending on which architecture your system is running, you will need to download packages from a different directory on the CentOS mirror:

i386 (32-bit)
http://mirrors.kernel.org/centos/4/os/i386/CentOS/RPMS/

From this directory, you will want to select these RPM packages:

  • centos-release
  • python-elementtree
  • python-sqlite
  • python-urlgrabber
  • sqlite
  • yum
  • yum-metadata-parser

Removing RHEL Packages
Next, you have to remove some specific packages from Red Hat. As root, run the following commands on your system:

  • rpm -e --nodeps redhat-release
  • rpm -e rpmdb-redhat
  • service rhnsd stop
  • chkconfig rhnsd stop

Installing CentOS GPG Key
Now, we have to import the CentOS 4 RPM GPG key, which is used to sign all the packages provided by CentOS 4.

Installing CentOS Packages
Change into the temporary directory you created for the packages you downloaded above (cd) and run the following as root:

  • rpm -Uvh *.rpm

If you receive any warnings about a package already being installed, or a newer version of a package already installed, simply delete the downloaded package of the same name from your temporary directory, and re-run the above command. The conversion will still work.

Updating With CentOS Package
Once you've upgraded the necessary packages from the set that you downloaded manually, you can let yum take over and finish the job for you. Run the following two command as root:

  • yum clean all
  • yum -y update

The "yum -y update" may or may not download anything, so do not be alarmed if it doesn't do anything. That simply means your system's packages are up to date with the latest available versions provided by CentOS.

Reboot
While not strictly necessary unless new kernel packages are installed, it's strongly recommended that you now reboot your system to fully activate all the system changes.

You have now successfully completed your conversion from Red Hat Enterprise Linux 4.x to CentOS 4.x.

Luego lo paso a español, despues de esto ya tenemos CentOS 4.x en nuestro servidor. Ahora a convertirlo en CentOS 5.x:

Converting CentOS 4  to CentOS 5

The idea is to completely upgrade yum/rpm and the kernel, then use yum to upgrade the whole system.

There are always items that will be niggardly: in this case (for me at least) it was python-elementtree & python-sqlite, each of which unaccountably has the same version number in centos 4 as centos 5 (so will not get upgraded), yet will crash yum if not.

This post will explain what to collect beforehand, and the next post will give the upgrade process step-by-step.

I downloaded the CentOS 5.1 CD ISOs, and took the RPMs from there, so the listing below will include which ISO & directory they come from. Otherwise, get them from the mirror-site (link at top of first post). I also work on a Windows desktop, and the RPMs were collected within a folder, so the listing also includes that folder structure.

CentOS Repository info for Yum:

Quote:
ISO location: CentOS-5.1-i386-bin-1of6.iso/CentOS
Windows location: CentOS_5.1\upgrade\centos-release\
RPMs:
centos-release-5-1.0.el5.centos.1.i386.rpm
centos-release-notes-5.1.0-2.i386.rpm

Kernel:
Quote:
ISO location: CentOS-5.1-i386-bin-1of6.iso/CentOS
Windows location: CentOS_5.1\upgrade\kernel\
RPMs:
kernel-2.6.18-53.el5.i686.rpm

GPG Key:
Quote:
ISO location: CentOS-5.1-i386-bin-1of6.iso/
CentOS_5.1\upgrade\gpg-key\
file:
RPM-GPG-KEY-CentOS-5

yum/RPM:
Quote:
ISO location: CentOS-5.1-i386-bin-1of6.iso/CentOS
Windows location: CentOS_5.1\upgrade\yum\
RPMs:
beecrypt-4.1.2-10.1.1.i386.rpm
binutils-2.17.50.0.6-5.el5.i386.rpm
db4-4.3.29-9.fc6.i386.rpm
elfutils-libelf-0.125-3.el5.i386.rpm
glibc-2.5-18.i686.rpm
glibc-common-2.5-18.i386.rpm
krb5-libs-1.6.1-17.el5.i386.rpm
libselinux-1.33.4-4.el5.i386.rpm
libsepol-1.15.2-1.el5.i386.rpm
libxml2-2.6.26-2.1.2.i386.rpm
libxml2-python-2.6.26-2.1.2.i386.rpm
m2crypto-0.16-6.el5.1.i386.rpm
mcstrans-0.2.6-1.el5.i386.rpm
neon-0.25.5-5.1.i386.rpm
openssl-0.9.8b-8.3.el5_0.2.i686.rpm
popt-1.10.2-47.el5.i386.rpm
python-2.4.3-19.el5.i386.rpm
python-sqlite-1.1.7-1.2.1.i386.rpm
python-urlgrabber-3.1.0-2.noarch.rpm
readline-5.1-1.1.i386.rpm
rpm-4.4.2-47.el5.i386.rpm
rpm-libs-4.4.2-47.el5.i386.rpm
rpm-python-4.4.2-47.el5.i386.rpm
yum-3.0.5-1.el5.centos.5.noarch.rpm

ISO location: CentOS-5.1-i386-bin-2of6/CentOS
Windows location: CentOS_5.1\upgrade\yum\
RPMs:
elfutils-0.125-3.el5.i386.rpm
elfutils-libs-0.125-3.el5.i386.rpm
glibc-devel-2.5-18.i386.rpm
glibc-headers-2.5-18.i386.rpm
python-devel-2.4.3-19.el5.i386.rpm

ISO location: CentOS-5.1-i386-bin-4of6/CentOS
Windows location: CentOS_5.1\upgrade\yum\
RPMs:
beecrypt-python-4.1.2-10.1.1.i386.rpm

On the Windows machine, open a command prompt and change into the `CentOS_5.1' folder. Note that Pageant is running in the background, and contains an SSH key to login to Olivia, which psftp will use transparently. The folder tree is then copied into /tmp/ on the server. This is what it looks like:
Code:
C:\>SET PUTTY=C:\Program Files\PuTTY
C:\>SET PATH=%PUTTY%;%PATH%
C:\>cd "My Documents\CentOS_5.1\upgrade"
C:\My Documents\CentOS_5.1\upgrade>psftp Olivia
Using username "root".
Remote working directory is /root
psftp> cd /tmp
Remote directory is now /tmp
psftp> mput -r *
local:centos-release\centos-release-5-1.0.el5.centos.1.i386.rpm => remote:/tmp/centos-release/centos-release-5-1.0.el5.centos.1.i386.rpm
...
local:yum\yum-3.0.5-1.el5.centos.5.noarch.rpm => remote:/tmp/yum/yum-3.0.5-1.el5.centos.5.noarch.rpm
psftp> bye

En este caso lo que hice fue bajar los paquetes desde el servidor CentOS con wget.

Step-by-step through the process of upgrade.

1 Log into Server & install the CentOS repository files:
"Make sure you disable all other repos and only have CentOS Base and Updates repositories enabled": thus, added `enabled=0' to bottom of [addons] + [extras]

Code:
[root@olivia ~]# cat /etc/redhat-release
CentOS release 4.6 (Final)
[root@olivia ~]# uname -a
Linux olivia.modem-help.com 2.6.9-67.0.4.ELsmp #1 SMP Sun Feb 3 07:08:57 EST 2008 i686 i686 i386 GNU/Linux

[root@olivia ~]# cd /tmp/centos-release/
[root@olivia centos-release]# rpm -Uvh centos-release-5-1.0.el5.centos.1.i386.rpm centos-release-notes-5.1.0-2.i386.rpm
warning: centos-release-5-1.0.el5.centos.1.i386.rpm: V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
   1:centos-release-notes   ########################################### [ 50%]
   2:centos-release         warning: /etc/yum.repos.d/CentOS-Base.repo created as /etc/yum.repos.d/CentOS-Base.repo.rpmnew
########################################### [100%]
[root@olivia centos-release]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.old
[root@olivia centos-release]# mv /etc/yum.repos.d/CentOS-Base.repo.rpmnew /etc/yum.repos.d/CentOS-Base.repo

2 Import GPG key:
Code:
[root@olivia centos-release]# cd ../gpg-key/
[root@olivia gpg-key]# rpm --import RPM-GPG-KEY-CentOS-5

3 Get the new yum/rpm working:
(the error is only fixed right at the end)
Code:
[root@olivia gpg-key]# cd ../yum/
[root@olivia yum]# rpm -Uvh *.rpm --nodeps
Preparing...                ########################################### [100%]
        package python-sqlite-1.1.7-1.2.1 is already installed
        file /usr/bin/c++filt from install of binutils-2.17.50.0.6-5.el5 conflicts with file from package gcc-c++-3.4.6-9

4 Temporary fix for python-elementtree:
(python-elementtree-1.2.6-5 (centos5) has the same release number as python-elementtree-1.2.6-5.el4.centos) (centos4) - "The only way I could make it work was to remove the old python-elementtree with --nodeps but save its files and copy them back in order to have a working yum")
Code:
[root@olivia yum]# rsync -a /usr/lib/python2.3/site-packages /tmp/
[root@olivia yum]# rpm -e python-elementtree --nodeps
[root@olivia yum]# rsync -a /tmp/site-packages /usr/lib/python2.3/

Force-installing the new python-elementtree and then attempting to run yum gives:
Quote:
[root@olivia yum]# yum clean all
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

No module named cElementTree

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.3.4 (#1, Dec 11 2007, 05:27:57)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-9)]
...whilst using the old python-elementtree and attempting upgrade gives the error message:
Quote:
Error: Missing Dependency: python-abi = 2.3 is needed by package python-elementtree

5 Clean and rebuild rpmdb for CentoS 5:
Code:
[root@olivia yum]# rm -f /var/lib/rpm/__*
[root@olivia yum]# rpm --rebuilddb

6 Clean yum files:
Code:
[root@olivia yum]# yum clean all
Cleaning up Everything
775 headers removed
0 packages removed
8 metadata files removed
0 cache files removed
4 cache files removed

7 Remove deps/outdated packages:
(first run `yum upgrade' to find deps that need to removed; after a very long process they will show at the bottom):
Code:
Error: Unable to satisfy dependencies
Error: Package initscripts needs kernel < 2.6.12, this is not available.
Error: Package kudzu needs kernel < 2.6.13, this is not available.
Error: Package MySQL-python needs libmysqlclient_r.so.14, this is not available.
Error: Package hal needs kernel < 2.6.17, this is not available.
Error: Package autofs needs kernel < 2.6.17, this is not available.
Error: Package MySQL-python needs libmysqlclient_r.so.14(libmysqlclient_14), this is not available.

[root@olivia yum]# rpm -e initscripts kudzu MySQL-python hal autofs pcmcia-cs --nodeps
(I used `yum update' by mistake, and only got pcmcia-cs dependency later)

8 Install new CentOS 5 kernel:
Code:
[root@olivia yum]# rpm -ivh kernel-2.6.18-53.el5.i686.rpm --nodeps
Preparing...                ########################################### [100%]
   1:kernel                 ########################################### [100%]

9 Find & remove old CentOS4 kernels:
Code:
[root@olivia yum]# rpm -qa | grep kernel
kernel-devel-2.6.9-22.0.2.EL
kernel-2.6.9-34.0.2.EL
[root@olivia yum]# rpm -e kernel-devel-2.6.9-22.0.2 kernel-2.6.9-34.0.2.EL --nodeps

10 Upgrade to CentOS 5.1:
Code:
[root@olivia yum]# yum upgrade
Transaction Summary
============================================================
Install    106 Package(s)
Update     415 Package(s)
Remove       0 Package(s)
Total download size: 353 M
Is this ok [y/N]:y
...
Success!!!

11 Fix yum error message:
(yum gives an error message after upgrade; you have to force an install of python-sqlite):
Code:
[root@olivia yum]# yum
Loading "installonlyn" plugin


Could not find any working storages.
[root@olivia yum]# rpm -Uvh --replacepkgs python-sqlite-1.1.7-1.2.1.i386.rpm
Preparing...                ########################################### [100%]
   1:python-sqlite          ########################################### [100%]

12 Check for & fix any removed packages from (7) that were not reinstalled:
Code:
[root@olivia yum]# yum list initscripts kudzu MySQL-python hal autofs pcmcia-cs python-elementtree
...
Available Packages
MySQL-python.i386                        1.2.1-1                base
autofs.i386                              1:5.0.1-0.rc2.55.el5.3 updates
(so install missing ones)
[root@olivia yum]# yum install MySQL-python autofs

13 Generate list of RPMS on the system after upgrade to spot old RPMS that are left:
Code:
[root@olivia yum]# cd ..
[root@olivia tmp]# rpm -qa | sort >Upgrade_RPM_List

14 Job done! Restart as to confirm the new system:
Code:
[root@olivia tmp]# shutdown -r now
(restart PuTTY session)
[root@olivia tmp]# Using username "root".
Authenticating with public key "root public key" from agent
Last login: Tue Feb 26 23:59:26 2008 from david.lan
[root@olivia ~]# uname -a
Linux olivia.modem-help.com 2.6.18-53.1.13.el5 #1 SMP Tue Feb 12 13:01:45 EST 2008 i686 i686 i386 GNU/Linux
[root@olivia ~]# cat /etc/redhat-release
CentOS release 5 (Final)
(yeah!)
         

Algunos pasos pueden cambiar un poco como en el caso de los paquetes que se tienen que remover en el paso 7, pero todo lo demas sale a la perfeccion, esto funciono para hacer una actualizacion de CentOS 4.7 a CentOS 5.3.

 Si tenemos problemas con la base de rpms debemos hacer esto:

# rm -f /var/lib/rpm/__db.*
# rpm --rebuilddb

Si sucede algo extraño al momento de querer instalar algo con yum, limpiamos con:
 
# yum clean all
 
Y eso es todo... 
 
Resources:
 
RHEL 4 - CentOS 4 
CentOS 4 - CentOS 5