Migration of Gerrit Server Old to New

From ppwiki
Jump to navigation Jump to search

In this tutorial, we will be migrating our gerrit 2.13 to a new server running gerrit 2.15

Prerequisites

To complete this tutorial, you'll need the following 2 nodes

  • Database node
  • New gerrit node

Environment

Old gerrit

Server Information
OS MYSQL MYSQL version Gerrit version Authentication
Ubuntu 14.04 mysql-server 5.5.57 2.13 LDAP

New gerrit

Server Information
OS MYSQL MYSQL version Gerrit version Authentication
Debian 9 (Stretch) mysql-client 5.8 2.15 LDAP

MYSQL node

Server Information
OS MYSQL mysql-version
Ubuntu 16.04 mysql-server 5.7.22

STEP 1 On old gerrit node

Stop gerrit

Login to your gerrit server with the gerrit user or the user running gerrit. Navigate to /gerrit/bin and run

sudo ./gerrit.sh stop

Backup gerrit database

Login to your old gerrit node and backup your gerrit data base. In this case the database name is reviewdb. I use mysqldump to backup the database to a file.

mysqldum -u gerrit -p database  reviewdb > reviewdb_backup.sql

If prompt, enter you mysql password. This will backup your database reviewdb to a file called reviewdb_backup.sql

Copy the .sql file to the MYSQL server node

You have 2 options to accomplish this:

  • Option 1 : Use scp
  • Option 2 : User rsync

For this tutorial we are going to use option 1.

The syntax of the command is :

scp path_to file_to_copy remote_usernmane@remote_server:path_to_copy_the_file

To make it go faster, I create a directory on the mysql server node called files. From the old gerrit server a copy the .sql file to the mysql server node using the command below.

sudo scp /home/gerrit/reviewdb_backup.sql pp@db2007.dfw.ppnet:/home/pp/files

STEP 2: On the MYSQL server

I am not going to convert the installation of MYSQL server in this tutorial. I assume, you have already MYSQL server running on your node. login to mysql and create the database reviewdb and the user gerrit, grant all privileges to gerrit user.

Create the database and user

Login to mysql and run

mysql> CREATE DATABASE reviewdb;
mysql> CREATE USER gerrit@gerrit_hostname IDENTIFIED BY 'gerrit_password';
mysql> GRANT ALL PRIVILEGES ON reviewdb.* TO 'gerrit'@'gerrit_hostname';";
mysql> FLUSH PRIVILEGES;

gerrit_password = your gerrit user password

gerrit_hostname = your new gerrit host-name or IP address

The gerrit hostname in my case is gerrit2001.dfw.ppnet, since i am using a DNS server in my environment. If you do not have a DNS server you can update your /etc/hosts or use IP address

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| reviewdb           |
+--------------------+
2 rows in set (0.00 sec)

Now we are going to make sure that the database is empty with no tables.

mysql> use  reviewdb;
Database changed
mysql> show tables;
Empty set (0.00 sec)

Check to see that the user gerrti@gerrit2001.dfw.ppnet exist and have All privileges on database reviewdb

mysql> show grants for gerrit@gerrit2001.dfw.ppnet;
+-------------------------------------------------------------------------+
| Grants for gerrit@gerrit2001.dfw.ppnet                                  |
+-------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'gerrit'@'gerrit2001.dfw.ppnet'                   |
| GRANT ALL PRIVILEGES ON `reviewdb`.* TO 'gerrit'@'gerrit2001.dfw.ppnet' |
+-------------------------------------------------------------------------+
2 rows in set (0.00 sec)

Import data to the database

Navigate to the dircectory where you saved your reviewdb_backup.sql file. I my case /home/pp/files/

Run the command below to restore data to the reviewdb database

mysql reviewdb < /home/pp/files/reviewdb_backup.sql

STEP 3: On new gerrit node

Installation

Make sure that you have Ubuntu 16.04 installed on you new gerrit node.

Configuation