DB2 to MySQL Database Migration
Beginning in 12.0.1, Traveler supports migrating data stored in DB2 databases to MySQL Databases.
This migration is handled by the travelerUtil command line utility. There are two methods of migrating data from DB2 to MySQL. The first method uses only travelerUtil to move all of the data automatically. This process is simpler and is recommended to customers with small amounts of data. The other process is a hybrid approach which uses DB2 export and MySQL Import to move the bulk of the data. In this scenario travelerUtil migrates a smaller amount of the data to improve performance. We strongly recommend this process for customers that have medium to large amounts of data.
Both processes migrate all data in the DB2 database into the new MySQL database. The data in the original database remains unchanged and can be reverted to in the event of a failed migration. The migration uses the existing Traveler database connection information as the source for migration.
Usage
db migrate [url=dburl] [path=libPath] [user=username] [pw=password] [drop]
[check] [imported] [verify]
Where dburl is the JDBC database connection URL for the destination server.
jdbc:mysql://mysqlserver.example.com:3306/TRAVELER
Where libPath is the full path to the JDBC Driver used by the destination database.
Where username is the username to use for the connection to the destination database.
Where password is the password to use for the connection to the destination database.
If the drop parameter is passed, all existing data is removed in the destination database before migrating. The database user must have the drop permission. Drop is not valid when used with verify or imported.
If the check parameter is passed, travelerUtil
validates that the requirements for migration are met. No data migration occurs when
check is specified. Check is not valid
when used with verify.
If the imported parameter is passed,
travelerUtil
only migrates tables that have not already been
migrated through the import and export process. Imported is not
valid when used with drop or verify.
If the verify parameter is passed, travelerUtil
validates that the migration completed successfully. No data migration occurs when
verify is specified. Verify is not
valid when used with drop, check, or
imported.
Migration procedure using only travelerUtil
Before migration:
- The Traveler HA pool should be configured for V12.0.1 or higher and running smoothly before attempting migration.
- All Traveler Servers in the HA pool must be down during the entire migration process.
- The destination database exists and is not populated. If the database is
populated and the user has permission to drop tables
drop=true
may be used to clear the existing data. - The destination database is in the same timezone as the source database.
- The database user being used for the migration has the requisite permissions to insert the data and create the schema if applicable.
- If NTS_AUTO_DBSCHEMA is set to
false
the schema must be manually created before migration can begin. - We strongly recommend tuning the
innodb_buffer_pool_size
before starting the migration. For more information, see MySQL's documentation. - We recommend migrating a test environment before migrating the production database.
We recommend making sure the source database has been re-organized too. For more information on deploying and configuring enterprise databases, see Configuring HCL Traveler for enterprise database.
Transferring data:
./travelerUtil db migrate url=jdbc:mysql://mysqlserver.example.com:3306/TRAVELER
path=/opt/hcl/domino/notes/latest/linux/mysql-connector-java-8.0.21.jar
user=databaseAdmin pw=samplePassword
The migration uses the existing stored database credentials for accessing the current source database. The parameters input to travelerUtil are used to access the new target database. This migration method may take several hours or more for deployments that have more than a million rows of data.
The migration checks the connection to the source and destination database. In the event of a failed connection, the migration fails and the user is notified. The migration will also fail if any servers in the HA Pool are online. If any servers come online during the migration, data already migrated to the target database will be out of date and the migration process must be restarted.
The migration automatically generates the schema if NTS_AUTO_DBSCHEMA is not set to false. If this value is set to false, the schema must be generated before migration can begin. If using the drop parameter with NTS_AUTO_DBSCHEMA set to false the database user must have the drop permission or else the drop command fails.
During the migration process every Traveler database table is migrated. When a table's data has been migrated, a status message is logged to the command console indicating that this table has been migrated. Once the migration completes, a message indicates that the migration has either passed or failed.
If the migration process fails, the error is output to the console. If the error is
resolved, migration can be attempted again. However, if the database is now
populated it must be cleared either manually or by using the
drop=true
parameter. If the error cannot be resolved, Traveler
can be started, but it still uses the old database configuration.
Configuring Servers to use the new database
After a successful migration, we recommend rebuilding indexes on the new database before modifying the configuration. In order to start using the new database, the servers must be re-configured using travelerUtil db set command to point to the new database server before start-up. This must be done manually on each server in the HA pool. For more information on configuring the Traveler server for Enterprise database, see Configuring HCL Traveler for enterprise database.
Hybrid Migration procedure using Export from DB2 and Import into MySQL
The Hybrid Migration process is recommended for customers that have large amouts of data and need to minimize the Traveler outage required for migrating. This method is more complex and it is recommended that it is performed by administrators with requisite DB2 and MySQL skills.
Before migration:
- The Traveler HA pool should be configured for V12.0.1 or higher and running smoothly before attempting migration.
- All Traveler Servers in the HA pool must be down during the entire migration process.
- The destination database must be in the same timezone as the source database.
- The database user being used for the migration must have the requisite permissions to insert the data and the file permission to import the data into MySQL.
- We strongly recommend migrating a test environment before migrating the production database.
- We strongly recommend tuning the innodb_buffer_pool_size before starting the migration. For more information, see MySQL's documentation.
Summary of steps:
- Create the MySQL DB Schema.
- Determine the upload directory on the MySQL Server.
- Prepare for export from DB2.
- Stop Traveler on each Traveler server in the HA Pool.
- Export the data from the DB2 database.
- Fix files exported from DB2.
- Validate exported files.
- Move the DB2 .csv files onto the MySQL Database server.
- Prepare for import to MySQL.
- Import export data into the MySQL database.
- Issue migration with travelerUtil.
- Configure Traveler Server(s) to the MySQL database.
- Start Traveler.
- Create the MySQL DB SchemaCreate the MySQL schema.
Use the method to create the schema described in Deploying and configuring the enterprise database. If you are using
NTS_AUTO_DBSCHEMA=true
, you should use the default values in the createDB.sql and appsGrant.sql file and do not need to add NTS_AUTO_SCHEMA to the notes.ini. If you want to useNTS_AUTO_DBSCHEMA=false
, you should update the .sql files for your configuration. If the schema already exists and has data it needs to be dropped. - Determine the upload directory on the MySQL Server.Use the MySQL client and issue the following query to determine the directory used in Step 8) and 9):
mysql> show variables like 'secure_file_priv';
Note: MySQL may not recognize file paths with "\
", instead change "\
" to "/
" in order for MYSQL to recognize that the directory matches thesecure_file_priv
. - Prepare for export from DB2.Extract exportDB2.sql from the DB2 folder for the
<domino install datadir>\traveler\cfg\db\TravelerSQL.zip
orTravelerSQL.tar.gz>
and copy it to your DB2 server. Review the comments in exportDB2.sql for instructions. You may need to update the connect to database statement to run under the correct DB2 user. The export file is generated with the default schema LNT and default database TRAVELER. If your configuration uses a different database name or schema name please update them accordingly. The db2 schema and database name can be found in the database configuration information section of the system dump. Please set <export_directory> to the directory where you would like the .csv files to be generated.Note: You can test the export while Traveler is running to validate the export commands process. However, during the actual migration process, you must export the data when Traveler is down otherwise the data will not be consistent. - Stop Traveler on each Traveler server in the HA Pool.
Go through each server in the Traveler HA Pool and stop Traveler. We recommend stopping Domino too.
- Export the data from the DB2 database.
Run the exportDB2.sql file to export the data. Verify each table export ran without errors and 22 files were generated. If there are errors, check the Troubleshooting section below. If the problem can be fixed, the export command can be run again. Do not proceed if errors can not be resolved.
Windows:db2cmd -c -w -i db2 -tvf exportDB2.sql
Linux® or AIX®:su - db2inst1 db2 -tvf exportDB2.sql
- Fix file formats.
DB2 exports columns with with null values as "
,,
". MySQL needs them to be ",NULL,
" in order for the import to work. MySQL's default escape character is\
. In order to properly escape this data '\
' needs to be converted into "\\
". See below for a sample script to accomplish these tasks:Windows:echo "Usage: exportDataToFileFromDB2.bat <output directory>" set "list=account adaptive_filter_sync approvedapps banneddoc bind device graduated_sync guidmap inv_map logsettings replicas sec_records sendmail travelerreplicas ts_field_name ts_global ts_global_id ts_sync_timestamp ts_sync_timestamp_folder users ts_gud_timestamp ts_record_mapping" for %%a in (%list%) do ( echo "Fixing format for import for table %%a" @PowerShell "(GC %1/%%a.csv)| %%{$_ -Replace ',,',',NULL,'}|SC %1/%%a.csv" @PowerShell "(GC %1/%%a.csv)| %%{$_ -Replace ',,',',NULL,'}|SC %1/%%a.csv" @PowerShell "(GC %1/%%a.csv)| %%{$_ -Replace '\\','\\'}|SC %1/%%a.csv" )
Linux:echo "Usage: exportDataToFileFromDB2.sh <output directory>" list="account adaptive_filter_sync approvedapps banneddoc bind device graduated_sync guidmap inv_map logsettings replicas sec_records sendmail travelerreplicas ts_field_name ts_global ts_global_id ts_sync_timestamp ts_sync_timestamp_folder users ts_record_mapping ts_gud_timestamp" for table in $list; do sed -i s/,,/,NULL,/g "${1}/${table}.csv" sed -i s/,,/,NULL,/g "${1}/${table}.csv" sed -i s/'\\'/'\\\\'/g "${1}/${table}.csv" done
- Validate exported files.22 .csv files should be generated. Verify that the contents of these files are encoded in UTF-8. Verify that any '
\
' have been properly converted to "\\
". Verify that any ",,
" have been properly converted to ",NULL,
". Some files may empty (these files would likely be adaptive_filter_sync.csv, approvedapps.csv and banneddocs.csv).Note: If you run export script again it overwrites the .csv files. These files need to have their formats fixed again. - Move the DB2 .csv files onto the MySQL Database server.
If the files are large, consider zipping them up into one zip file before transfering. Be sure to place them in the directory identified in step 2. If this directory is not defined then the files can be uploaded from anywhere.
- Prepare import into MySQL.
Extract importMySQL.sql from the MYSQL folder for the
<domino install datadir>\traveler\cfg\db\TravelerSQL.zip
orTravelerSQL.tar.gz>
and copy it to your MySQL server. Review the comments in importMySQL.sql for instructions. Update the<MySQL Upload directory>
to point to the directory determined in step 2. Finally, update the database name if not using the default TRAVELER database.Note: MySQL may not recognize file paths with "\
", instead change "\
" to "/
" in order for MYSQL to recognize that the directory matches thesecure_file_priv
. - Run importMySQL.sql.Make sure that the user running the .sql file has the File permission on the MySQL Database. Verify that each table import statement runs without error.
mysql -u <admin_user> -p < importMySQL.sql
Run the importMy.sql file to import the data. Make sure that the user running the .sql file has the File permission on the MySQL Database. Verify that each table import statement runs successfully without error. If there are errors check the Troubleshooting section below.
If the problem can be fixed, the import command can be run again. However if any data was imported to database, you should start with a clean database, or re-run the import steps that failed. Do not proceed if errors can not be resolved.
- Issue migration with travelerUtil.
It is important that the travelerUtil migration command is only run on one server. This step finalizes the migration and verifies that it completed successfully.
EXAMPLE:
travelerUtil db migrate url=jdbc:mysql://<Server Name>:3306<database name> path=<path to MySQL-Connector.jar> user=<db login user> pw=<db user pwd> imported
Note: If the imported option is not specified then travelerUtil will try to move all the table data and will fail because data already exists from MySQL import step.If the migration fails do not proceed. If the error can be resolved, migration can be attempted again. However, if the database is now populated it must be cleared before re-attempting migration. If the error cannot be resolved, Traveler can be started, but it still uses the old database configuration. Please refer to the troubleshooting section below for help resolving common migration problems.
- Configure Traveler Server(s) to the MySQL database.
After a successful migration, we recommend rebuilding indexes on the new database before modifying the configuration. In order to start using the new database, the servers must be re-configured using travelerUtil db set command to point to the new database server before start-up. This must be done manually on each server in the HA pool. For more information on configuring the Traveler server for Enterprise database, see Configuring HCL Traveler for enterprise database.
Note: This must be done on each traveler server in the HA pool. - Start Traveler.
Start Traveler and Domino on each traveler server in the HA pool.
Troubleshooting: Export from DB2
- SQL3022 error. This is likely caused by selecting from the wrong schema or not using the correct user. Confirm that the correct user and schema are being used in the exportDB2.sql file and try exporting again.
-
SQL20397W Routine "SYSPROC.ADMIN_CMD" execution has completed, but at least one error, "SQL3022", was encountered during the execution. More information is available. SQLSTATE=01H52
- SQL3001 error. This is likely caused by exporting to a directory that does not exist or the user not having the correct permissions to export to this directory. Make sure the directory exists and the user has the proper permissions and try exporting again.
-
SQL20397W Routine "SYSPROC.ADMIN_CMD" execution has completed, but at least one error, "SQL3022", was encountered during the execution. More information is available. SQLSTATE=01H52
Troubleshooting: Import to MySQL
- If a file is not properly UTF-8 encoded, the following error occurs. Resolve
the error by converting the file to UTF-8.
Error 1300 - Invalid utf8mb4 character string
- If column data for nulls "
,,
" were not correctly changed to ",NULL,
" the following error occurs. Resolve the error by converting ",,
" to ",NULL,
".Error Code: 1366. Incorrect integer value: '' for column 'TS_TAGGED_FOR_SLOW_SYNC' at row 1 0.046 sec