{"id":486,"date":"2010-09-24T11:34:18","date_gmt":"2010-09-24T16:34:18","guid":{"rendered":"http:\/\/swildow.darktech.org\/wp\/?p=486"},"modified":"2010-09-24T16:40:47","modified_gmt":"2010-09-24T21:40:47","slug":"upgrade-centos-4-8-to-5-x-32bit","status":"publish","type":"post","link":"https:\/\/www.wildow.com\/blog\/?p=486","title":{"rendered":"Upgrade CentOS 4.8 to 5.x (32bit)"},"content":{"rendered":"<p><a href=\"http:\/\/www.rfxn.com\/upgrade-centos-4-8-to-5-3\/\" target=\"_blank\">http:\/\/www.rfxn.com\/upgrade-centos-4-8-to-5-3\/<\/a><\/p>\n<p>Traditionally, the dist upgrade path that many were familiar with from  the RH8\/9-&gt;Fedora or similarly Fedora dist upgrades, have applied  more or less to RHEL\/CentOS but with the release of 4.5 and early  releases of 5.0 the actual dist upgrade path was messy or nearly  impossible. The early versions of 5.0 (up to 5.2) had excessive  dependency issues with versions later than 4.4 for straight dist  upgrades that would often result in a box blowing up on you or forcing a  messy downgrade attempt of 4.5+ to 4.4 to try get things to dist  upgrade. With more recent release updates the gap has closed and now  dist upgrades on are far more reasonable to complete with little in the  way of problems.<\/p>\n<p><!--more--><\/p>\n<p>If you are currently running a version of RHEL\/CentOS earlier than  4.8 (cat \/etc\/redhat-release) then please do a proper \u2018yum update\u2019 and  get yourself on 4.8. Although this is intended for CentOS it <em>\u201cshould\u201d<\/em> (read: at own risk) work on RHEL systems as well, in the unfortunate  situation that something does blow up please post a comment and I will  try to assist.<\/p>\n<p>The first thing we must do is make sure none of our core binaries,  libraries or other content is set immutable as this will cause a package  to fail on installation. If you are running an earlier version of LES  or you use immutable bits on system paths  (sbin\/bin\/share\/include\/libexec\/etc) then you should run the following:<br \/>\n<code><br \/>\nwget http:\/\/www.rfxn.com\/downloads\/disable.les.rpmpkg<br \/>\nsh disable.les.rpmpkg<br \/>\n<\/code><\/p>\n<p>Once that is done we should go ahead and have a quick run through of  cleaning up yum cache, double check that any pending updates are  installed and rebuild the rpmdb:<br \/>\n<code><br \/>\nrpm --rebuilddb<br \/>\nyum clean all<br \/>\nyum update<br \/>\n<\/code><\/p>\n<p>If for some reason the rpm rebuild hangs for more than a few minutes then you may need to manually clear the rpmdb files:<br \/>\n<code><br \/>\nrm -f \/var\/lib\/rpm\/__db.00*<br \/>\nrpm --rebuilddb<br \/>\n<\/code><\/p>\n<p>If you run into any minor dependency issues for packages that are not  essential, such as syslinux and lftp then you can either exclude them  or better yet remove them. If you are not sure what a package does, then  you should query it for description details and make an educated choice  (rpm -qi PACKAGE):<br \/>\n<code><br \/>\nrpm -e lftp syslinux mkboot<br \/>\n<\/code><br \/>\nOR (but not recommended)<br \/>\n<code><br \/>\nyum update --exclude=syslinux --exclude=lftp --exclude=mkboot<br \/>\n<\/code><\/p>\n<p>At this point you should be able to run a \u2018yum update\u2019 command with  optional exclude and receive no errors (again, I recommend you remove  conflicts items instead of using exclusions).<\/p>\n<blockquote><p># yum update \u2013exclude=nagios-plugins<br \/>\nSetting up Update Process<br \/>\nSetting up repositories<br \/>\nReading repository metadata in from local files<br \/>\nExcluding Packages in global exclude list<br \/>\nFinished<br \/>\nNo Packages marked for Update\/Obsoletion<\/p><\/blockquote>\n<p>Now we are ready to get going, I have put together a small package  that contains the needed packages for this upgrade in addition to a few  that you might require to resolve dependency conflicts:<br \/>\n<code><br \/>\nwget http:\/\/www.rfxn.com\/downloads\/CentOS-5up.tar.gz<br \/>\ntar xvfz CentOS-5up.tar.gz<br \/>\ncd CentOS-5up<br \/>\n<\/code><\/p>\n<p>We need to go ahead and setup the centos-release package as follows:<br \/>\n<code><br \/>\nrpm -Uhv centos-release-*<br \/>\n<\/code><\/p>\n<p>If you see that CentOS-Base.repo was created as  \/etc\/yum.repos.d\/CentOS-Base.repo.rpmnew then go ahead and move it into  the proper place:<br \/>\n<code><br \/>\nmv \/etc\/yum.repos.d\/CentOS-Base.repo.rpmnew \/etc\/yum.repos.d\/CentOS-Base.repo<br \/>\n<\/code><\/p>\n<p>Now we are ready to go with kernel changes, this is an important part  so pay attention. The key to successful upgrade is that you remove ALL  OLD KERNELS as many packages will fail to install during the upgrade if  they detect a release 4.x kernel due to minimum kernel version  dependency checks. We will start with first installing the new kernel so  it preserves grub templating:<br \/>\n<code><br \/>\nrpm -ivh kernel-2.6.18-164.el5.i686.rpm kernel-devel-2.6.18-164.el5.i686.rpm  --nodeps<br \/>\n<\/code><br \/>\nNOTE: release 5.x has smp support integrated into the standard kernel, so no -smp version is required for mp systems<\/p>\n<p>If you are running an older system the chances are you got allot of  older kernel packages installed so make sure you get them all out of the  way:<br \/>\n<code><br \/>\nrpm -e $(rpm -qa | grep kernel | grep -v 2.6.18 | tr '\\n' ' ')<br \/>\n<\/code><\/p>\n<p>You may end up with a few dependencies coming up such as lm_sensors  and net-snmp if the list is fairly small and packages you do not  recognize as critical (if unsure always query the package for info \u2018rpm  -qi PACKAGE\u2019, remember you can reinstall them later):<\/p>\n<blockquote><p># rpm -e $(rpm -qa | grep kernel | grep -v 2.6.18)<br \/>\nerror: Failed dependencies:<br \/>\nkernel-utils is needed by (installed) lm_sensors-2.8.7-2.40.5.i386<\/p><\/blockquote>\n<p>The command the ended up being required on most of my servers to get  the kernel packages and related dependencies came out to the following:<br \/>\n<code><br \/>\nrpm -e $(rpm -qa | grep kernel | grep -v 2.6.18 | tr '\\n' ' ') lm_sensors net-snmp net-snmp-devel net-snmp-utils<br \/>\n<\/code><\/p>\n<p>That said and done you should now only have 2 kernel packages  installed which are the 2.6.18 release 5.x kernels, DO NOT under any  circumstance continue if you still got 2.6.9 release 4.x kernels  packages still installed, remove them!<\/p>\n<blockquote><p># rpm -qa | grep -i kernel<br \/>\nkernel-2.6.18-164.el5<br \/>\nkernel-devel-2.6.18-164.el5<\/p><\/blockquote>\n<p>A cleanup of \/etc\/grub.conf may be required, though if all went as  planned then the rpm command should have done this up for us but review  it anyways for good measure. You should find that 2.6.18-164.el5 is the  only kernel in the file, if it is not go ahead and clean it by removing  all older entries for 2.6.9 kernels.<\/p>\n<p>There is a known bug with python-elementtree package versions which  cause yum\/rpm to think the release 4.x version is newer than the 5.x  version, to get around this without blowing up the entire python  installation we need to remove the package from just the rpmdb as  follows:<br \/>\n<code><br \/>\nrpm -e --justdb python-elementtree --nodeps<br \/>\n<\/code><\/p>\n<p>We can now go ahead and use yum to start the upgrade process, this is  a dry run and will take a few minutes to compile list of available  packages and associated dependency checks. You should carry the exclude  options, if any, that you used during the \u2018yum update\u2019 process as so to  avoid unresolvable dependencies:<br \/>\n<code><br \/>\nyum clean all<br \/>\nyum upgrade --exclude=nagios-plugins<br \/>\n<\/code><\/p>\n<p>You will end up with a small list of dependency errors, these should  be resolved by again evaluating a packages need as a critical system  component and either removing it with \u2018rpm -e\u2019 or excluding it with  \u2018\u2013exclude\u2019 (remember to query description with \u2018rpm -qi PACKAGE\u2019 if you  are unsure what something does). In my case the packages that threw up  red flags were stuff I had manually installed over time such as iftop  and mrtg in addition to default installed samba, these can all safely be  removed or excluded as you prefer (removal always safest to prevent  dependency chain issues).<\/p>\n<blockquote><p>Error: Missing Dependency: libpcap.so.0.8.3 is needed by package iftop<br \/>\nError: Missing Dependency: perl(Convert::ASN1) is needed by package samba<br \/>\nError: Missing Dependency: libevent-1.1a.so.1 is needed bypackage nfs-utils<br \/>\nError: Missing Dependency: perl-Socket6 is needed by package mrtg<br \/>\nError: Missing Dependency: perl-IO-Socket-INET6 is needed by package mrtg<\/p><\/blockquote>\n<p><code><br \/>\nrpm -e iftop samba nfs-utils mrtg system-config-samba<br \/>\n<\/code><\/p>\n<p>sw&#8230; had to do teh following on my virtual machine<\/p>\n<p>rpm -e MySQL-python<\/p>\n<p>yum remove ghostscript<\/p>\n<p>sw &#8230;<\/p>\n<p>At this point we should be ready to do a final dry run of with yum  and see where we stand on dependencies, rerun the earlier \u2018yum upgrade\u2019  while making sure to carry over any exclude options you are using.<br \/>\n<code><br \/>\nyum upgrade --exclude=nagios-plugins<br \/>\n<\/code><\/p>\n<p>You should now end up with a summary of actions that yum needs to  perform, go ahead and kick it off\u2026 this will take a bit to complete so  go grab some coffee\/jolt\/redbull and maybe a small snack cause it could  be a long night if this blows up on you.<\/p>\n<blockquote><p>Transaction Summary<br \/>\n=============================================================================<br \/>\nInstall    183 Package(s)<br \/>\nUpdate     327 Package(s)<br \/>\nRemove       0 Package(s)<br \/>\nTotal download size: 299 M<br \/>\nIs this ok [y\/N]:<\/p><\/blockquote>\n<p>Once yum has completed (hopefully without major errors) we need to  fix a few things, the first is the rpmdb needs a rebuild due to version  changes that will cause any rpm commands to fail:<\/p>\n<blockquote><p># rpm -qa<br \/>\nrpmdb: Program version 4.3 doesn\u2019t match environment version<br \/>\nerror: db4 error(-30974) from dbenv-&gt;open: DB_VERSION_MISMATCH: Database environment version mismatch<br \/>\nerror: cannot open Packages index using db3 \u2013  (-30974)<br \/>\nerror: cannot open Packages database in \/var\/lib\/rpm<\/p><\/blockquote>\n<p>This can be fixed by running the following to manually rebuild the rpmdb:<br \/>\n<code><br \/>\nrm -f \/var\/lib\/rpm\/__db.00*<br \/>\nrpm --rebuilddb<br \/>\nyum clean all<br \/>\n<\/code><\/p>\n<p>The next issue on the list is python-elementtree and python-sqlite,  one or both of these may have ended up in a broken state that will cause  all yum commands to break, so we will go ahead and reinstall both of  these for good measure:<br \/>\n<code><br \/>\nrpm -e --justdb python-elementtree --nodeps<br \/>\nrpm -ivh python-elementtree-1.2.6-5.el5.i386.rpm<br \/>\nrpm -ivh python-sqlite-1.1.7-1.2.1.i386.rpm  --nodeps --force<br \/>\n<\/code><\/p>\n<p>The yum command should now work, go ahead and run it with no options, if you do not get any errors you are all sorted.<\/p>\n<p>Hopefully the install went well for you, the only thing left to do is  go ahead and reboot the system; this is the last point at which you  have to make backups (but we all maintain backups right?). For the sake  of avoiding a heart attack if the system goes into an fsck, we will  reboot with the -f option to skip fsck:<br \/>\n<code><br \/>\nshutdown -rf now<br \/>\n<\/code><\/p>\n<p>That\u2019s a wrap, I hope you found this HowTo useful, if you did run  into any issues then go ahead and post them into the comments field and I  will try to assist but when in doubt typically google is the fastest  alternative.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/www.rfxn.com\/upgrade-centos-4-8-to-5-3\/ Traditionally, the dist upgrade path that many were familiar with from the RH8\/9-&gt;Fedora or similarly Fedora dist upgrades, have applied more or less to RHEL\/CentOS but with the release of 4.5 and early releases of 5.0 the actual dist &#8230; <a class=\"more-link\" href=\"https:\/\/www.wildow.com\/blog\/?p=486\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-486","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=486"}],"version-history":[{"count":3,"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/486\/revisions"}],"predecessor-version":[{"id":488,"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/486\/revisions\/488"}],"wp:attachment":[{"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}