|
|
| P is for Practical | |
| PerlMonks |
Notes on Upgrading to 5.8.0 on a production web serverby markjugg (Curate) |
| on Aug 23, 2002 at 03:21 UTC ( #192255=perlmeditation: print w/ replies, xml ) | Need Help?? |
|
by Mark Stosberg
with contributions from Chris Hardie
Prepared for Summersault, info@summersault.com Last Updated on 08/24/02 This document details my experience upgrading Perl on FreeBSD 4.5 from the base 5.005 installation to perl 5.8.0. It was originally prepared for Summersault, a hosting company that has been using perl intensively since 1997. There were many modules from CPAN in use that needed to be preserved, and many more projects that depended on the installation that needed to remain working with a minimum of disruption. While I've tried to be accurate as possible, this should be considered a record of my experience and not gospel on how to do this correctly. It should be a supplement to knowing what you are actually doing, not a replacement. :) Much of the information here isn't specific to FreeBSD, although that operating system is assumed throughout the document. As well, all the shell syntax examples are using the bash shell. Table of Contents
0. Why Upgrade?I'd been using Perl 5.005 since it was released and was very satisfied with it, in terms of features and functionality, stability and performance and lack of bugs that affected me. Primarily for these reasons, we never upgraded our servers to Perl 5.6.x when they were released.However, Perl on our system is primarily used for CGI programming, commonly with a database backend. The CGI and DBI modules are core to our use of Perl at Summersault. The most recent versions of CGI.pm now include a "require" statement for Perl 5.6, and the Changes file for DBI 1.30 threatens to require at least Perl 5.6 soon. These occurances provide two reasons to upgrade. First to keep to up to date with modules that are core to our usage of Perl. Secondly, these are strong endorsements for upgrading by module authors I respect. It also didn't seem likely that it would be reasonable to hold out and skip the whole the 5.8 series without upgrading from 5.005, if only because modules would increasingly require a version of Perl newer than what we were running. Since I'd heard good things about 5.8.0 being a very stable, quality release, my feeling was that this could be a good way to skip the hassle of first upgrading to 5.6 and possibly be "set" for a while, possibly until Perl 6. Now we've been running Perl 5.8 for a couple of weeks, and have noticed no glitches other than the things noted in the upgrade process below, which don't appear to be cauesd by bugs in Perl from what I can tell. 1. Make life with the CPAN module easierThe CPAN module will be used a lot in this process to download and install new modules. Here are some tips that worked well to keep it functioning smoothly.
2. Create A Bundle of Existing ModulesTo make sure the new version of Perl has all the same modules installed as the last version, the first step is create a bundle file of all the modules that are currently installed. This will allow you to easily re-install the latest versions of these modules to work with the new version of Perl.
That will create a file with a name like "Bundle/Snapshot_2002_07_23_00.pm" that you can use to re-install the modules from. This file will be created in your .cpan directory, which is in /root by default. 3. Update your portNext you will need an up-to-date version of the Perl 5.8 port for FreeBSD. There are a number of ways to update your ports, here's how I updated mine:
4. Install the New PerlActually installing Perl is easy enough:
This finished in about an hour on my 233 Mhz machine with 256 MB RAM and a SCSI hard drive. YMMV. 5. Keep old perl active while you finish workingThe installation process will install about 20 binaries in /usr/local/bin related to then new version of Perl. Since some software may find these versions of perl binaries before they look in /usr/bin, I wanted to move these versions out of the way and symlink these binaries back into /usr/bin/ while I finished the upgrade. I found a definitive list of the binaries installed like this:
With this, I used a little shell scripting to generate the commands I needed to systematically move and symlink all these binaries:
That will print out the commands but not actually run them for you. 6. Install Updated ModulesNow it's time to re-install all your old modules for the new version of Perl. To do this, your CPAN/Config.pm file needs to be created or updated for 5.8. Since I already had one that worked from my last installation, I just re-used it, like this:
Once that is done, you can proceed to installing the modules. You will need to be in the directory where your "Bundle" directory is located that you created above. (/root/.cpan by default) Note: It's important to make sure you are using the new version of Perl when you do this.
Depending on how many modules you need to upgrade and your net connectivity, this could take several hours to complete. Some modules may ask for interactive feedback during the install process, so it's important to actively watch what's happening. For that reason, I use tee above so that I can work with the program interactively and still has a log of what happened for future reference. I ended up running this command several times, as I would review the output, fix some modules, and try again. Each time I changed the name of the output file, so I could compare the various results if I needed to. In my case the system tried to install a mod_perl module which wanted to know where my Apache source tree was, which didn't exist. I was able to use Control-C to cause that module to forcefully fail, while continuing on with the rest of the modules. (which was fine in my case, since I didn't need the mod_perl module). Other modules may fail without any interaction. In my case, the DBD::Pg module complained about not being able to find the Postgres libraries in environment variables. (hint to DBD::Pg users: define POSTGRES_LIB AND POSTGRES_INCLUDE before you start). For cases like that, it will be important to analyze the resulting log to see what modules, if any, need some manual intervention to be installed properly. You can look for this kind of wording in the
7. Some notable workaroundsHere are some patterns that were used when getting troublesome modules to install under Perl 5.8.
8. Verify the workNow I wanted to verify two things about the modules I had installed for Perl 5.8:
Creating the "use module" verification took a little more effort. First, I didn't wanted to load every module at the same time for fear of the memory consumption. Also, I needed to run the test for all the 5.5 modules as well, and have a good way way to compare the two result sets. I decided to produce a report that gave the module name, an arbitrary delimiter of "XXX" and then a failure message, if any. I used this kind of syntax for both reports, being careful to change the file names and the perl interpreter I was using for the 5.8 report:
With reports for both versions in hand, I could now produce a report of modules that were broken in 5.8 but not in 5.5. I did that like this:
Any errors at this stage will again need to be addressed by hand. 9. Some CGI.pm issuesAfter upgrading, I noticed some issues with the CGI.pm module. You might look into these before your upgrade is final if you are CGI.pm user.
10. Update system to use perl portNow it's time to actually switch from having the system use the old perl to having it use the new perl.
11. Reality Check ProjectsNow it's time to test some real perl scripts to check for problems that may have been missed elsewhere in the process. Since nearly all of our Perl is used for CGI scripting, we checked the log files of many websites on the machine to check for errors. A bash command like this was used to find all the error logs and grep them for errors that might be perl related. Season to taste.
12. Be Prepared to RevertAt this point, it's still good to be prepared for the worst case scenario of reverting to the old version of Perl if something is breaking that can't be fixed in a reasonable amount of time. Again, this should be an easy two step process.
13. Some Other Perl 5.8 Nodes of Interest
Copyright © 2002 Summersault, LLC. All rights reserved. update: improved formatting at jens suggestion, and html entities thanks to runrig. Added "Why" section on 8/24/02
Back to
Meditations
|
|
||||||||||||||||||||||||||||||