Migrate Bugzilla 3.0 Server to a Bugzilla 4.0 Server

238

Summary

I recently did a migration from Bugzilla 3.0 running on one server to Bugzilla 4.0 running on a new server.  Since I was already writing these down as I went, I thought that I would share these instructions with the greater Linux community.  You may find that some of these instructions may need to be run in a slightly different order, but this is a pretty complete account of what it took to get this going on the new server.  I know that I had to periodically go back the the ./checksetup.pl script over and over throughout the process to check myself and figure out what needed to occur next.  I tried to arrange all of these in an order that will work, but if you have to install the bugzilla folder first and continually re-run ./checkseutp.pl, it’s pretty much what I had to do.

These instructions are for RedHat 5.5.

Backup Your Current Bugzilla 3.0 Database

These directions all assume that you have a Bugzilla 3.0 database that you’ve backed up with teh following commands: 

sudo mkdir /data/backups/mysql-bugzilla-3.0
sudo chown www-data.www-data /data/backups/mysql-bugzilla-3.0
mysqldump -u bugs --password=XXXXXXXXX bugs | gzip -9v > `date '+/data/backups/mysql-bugzilla-3.0/bugs_%Y%m%d.sql.gz'`

 

Setup Apache

Install the Web Server, set the run levels, and start the service:

[root@mybugzilla]# yum groupinstall "Web Server"
[root@mybugzilla]# yum chkconfig --levels 2345 httpd on
[root@mybugzilla]# service httpd restart

Try the main site to ensure that apache is setup correctly by browsing to your site name or to http://localhost

You should see the default apache site showing that the webserver is installed properly.

Modify the httpd.conf file

Open the /etc/httpd/conf/httpd.conf file in your favorite editor.  Add these lines to the end of your httpd.conf file:

PerlSwitches -w -T
PerlConfigRequire /var/www/html/bugz/mod_perl.pl

Also make sure that you have the line “KeepAlive Off” per the bugzilla install instructions.

Restart Apache

[root@mybugzilla]# service httpd restart

Setup MySQL

Install MySQL, set the service to start on boot, and set the mysql root password:

[root@mybugzilla]# <b>yum groupinstall "MySQL Database"</b>
[root@mybugzilla]# <b>chkconfig --levels 2345 mysqld</b>
[root@mybugzilla]# <b>service mysqld restart</b>
[root@mybugzilla]# <b>/usr/bin/mysqladmin -u root password 'XXXX'</b>

Now login to mysql:

[root@mybugzilla]#  <b>mysql -pXXXX</b>

Once logged into mysql as root, create the bugs user and the database:

mysql> create user 'bugs'@'localhost' IDENTIFIED BY 'XXXpasswordXXX';
mysql> create database bugs;
mysql> show databases;

Restore data

These instructions assume that you followed the above instructions for exporting your bugzilla database from Bugzilla 3.0.

[root@mybugzilla]# cd /path/to/restore/file
[root@mybugzilla]# gunzip bugs_20110414.sql.gz
[root@mybugzilla]# mysql -u root -pXXXX bugs < bugs_20110414.sql

Grant Permissions

Login to mysql as above and run

mysql> grant all on bugs.* to 'bugs'@'localhost';

 

Fix MySQL Defaults in /etc/my.cnf

Edit the /etc/my.cnf file and add these lines under the [mysqld] section:

[mysqld]
# Allow packets up to 4MB
max_allowed_packet=4M

# Allow small words in full-text indexes
ft_min_word_len=2

This ensures that uploaded attachments to bugs is now 4MB instead of the default 1MB.

Restart MySQL

Restart the service to ensure any changes above are loaded:

service mysqld restart

 

Setup Bugzilla

Prep Bugzilla

Create the directories and download Bugzilla:

[root@mybugzilla]# cd /var/www
[root@mybugzilla]# mkdir bugz
[root@mybugzilla]# cd bugz
[root@mybugzilla]# wget http://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-4.0.tar.gz
[root@mybugzilla]# tar xzvf bugzilla-4.0.tar.gz
[root@mybugzilla]# cd /var/www/html
[root@mybugzilla]# ln -s ../bugz/bugzilla-4.0 bugz
[root@mybugzilla]# cd /var/www/bugz/bugzilla-4.0

 

Install Bugzilla Dependencies

./checksetup.pl --check-modules

You will be told you should run several commands to install all the perl modules.  For example,
I was told to run these:

[root@mybugzilla]# /usr/bin/perl install-module.pl Digest::SHA
[root@mybugzilla]# /usr/bin/perl install-module.pl Date::Format
[root@mybugzilla]# /usr/bin/perl install-module.pl DateTime
[root@mybugzilla]# /usr/bin/perl install-module.pl DateTime::TimeZone
[root@mybugzilla]# /usr/bin/perl install-module.pl Template
[root@mybugzilla]# /usr/bin/perl install-module.pl Email::Send
[root@mybugzilla]# /usr/bin/perl install-module.pl Email::MIME
[root@mybugzilla]# /usr/bin/perl install-module.pl List::MoreUtils

or just simply:

  [root@mybugzilla]# /usr/bin/perl install-module.pl --all

 
DateTime won’t build so I’m trying this:

  [root@mybugzilla]# yum install mysql-devel gd gd-devel perl-DBD-MySQL mod_perl-devel

 
  (per instructions at http://www.bugzilla.org/docs/4.0/en/html/installation.html)
 
The perl-DBD-MySQL package is 3.07 which is too old (4.0 is needed) so I had to be sure to
run the cpan install:

[root@mybugzilla]# /usr/bin/perl install-module.pl DBD::mysql

 
I noticed that DateTime complains that I only have Archive::Tar 1.3901 which it found in the
perl-Archive-Tar package.  I upgraded with the following:

[root@mybugzilla]# /usr/bin/perl install-module.pl Archive::Tar

 
Which got me Archive::Tar 1.76, which stopped the complaints in DateTime.  I installed datetime
running these:

[root@mybugzilla]# /usr/bin/perl install-module.pl Module::Build
[root@mybugzilla]# /usr/bin/perl install-module.pl DateTime

 

Install Additional Modules

I installed these extra modules:

[root@mybugzilla]# /usr/bin/perl install-module.pl Net::LDAP
[root@mybugzilla]# /usr/bin/perl install-module.pl GD
[root@mybugzilla]# /usr/bin/perl install-module.pl Chart::Lines
[root@mybugzilla]# /usr/bin/perl install-module.pl Email::Reply
[root@mybugzilla]# /usr/bin/perl install-module.pl Apache2::SizeLimit
[root@mybugzilla]# /usr/bin/perl install-module.pl GD::Graph
[root@mybugzilla]# /usr/bin/perl install-module.pl PatchReader
[root@mybugzilla]# /usr/bin/perl install-module.pl Email::MIME::Attachment::Stripper

   
I know that out of the above, if you don’t have Apache2::SizeLimit then there will be a problem when restarting the httpd server, which (per the above instructions) includes a reference to the mod_perl.pl script in the bugzilla folder, which in turn uses Apache2::SizeLimit.  If you have trouble (as I did), make sure you have the =mod_perl-devel= package installed in order to install Apache2::SizeLimit.

Edit Configuration

Now you’ll need to edit the localconfig file to setup the variables.  Make sure you have these variables set.  You’ll probably have to manually set
those listed in bold:

$create_htaccess = 1;
$webservergroup = 'apache';
$use_suexec = 0;
$db_driver = 'mysql';
$db_host = 'localhost';
$db_name = 'bugs';
$db_user = 'bugs';
<b>$db_pass = 'XXXpasswordXXX';</b>
$db_port = 0;
$db_sock = '';
$db_check = 1;
$index_html = 0;
$cvsbin = '/usr/bin/cvs';
$interdiffbin = '/usr/bin/interdiff';
$diffpath = '/usr/bin';
$site_wide_secret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

 

Re-Run CheckSetup

Now re-run checksetup now that you’ve fixed the localconfig file.  This should test the settings in the localconfig to ensure the correct db name, user name and password:

./checksetup.pl --check-modules

The script may remind you to perform some actions documented above.  If you’ve missed anything, go ahead and fix it now before continuing.

Bugzilla Upgrade

Upgrading can cause serious harm to the database.  Make sure you’ve backed up or you have a file migrated from another server that you can use to restore the database ‘bugs’ table in case the following fail.  There are probably more ways to migrate, but these are the actions that I took.

Ensure the character encoding is correct

Your database must be in UTF-8.  If the previous database used another encoding, you should fix it with the recode.pl script.

[root@mybugzilla]# /usr/bin/perl install-module.pl Encode::Detect
[root@mybugzilla]# cd /var/www/bugz/bugzilla-4.0/
[root@mybugzilla]# contrib/recode.pl --dry-run --guess

Review what changes then do the command for real:

[root@csobugzilla]# contrib/recode.pl --guess

 

Continue with the checksetup.pl

Try the checksetup.pl script again.  You can now safely continue when prompted about the UTF-8 stuff.

References

http://www.bugzilla.org/docs/4.0/en/html/configuration.html
http://www.velikan.net/import-sql-dump-file-to-mysql-database/
http://dev.mysql.com/doc/refman/5.1/en