Migrating database X to database Y
If you want to migrate from one database to another, for example from H2 to MySQL, you need to use the MetaServlet command called migrateDatabase.
As the source database is updated during the migration process, it is mandatory to back it up before migrating it.
The MetaServlet application is located in <TomcatPath>/webapps/<TalendAdministrationCenter>/WEB-INF/classes folder.
To display the help of this command (with related parameters), you need to enter the following in the MetaServlet application:
./MetaServletCaller.sh --tac-url=<yourApplicationURL> -h migrateDatabase
For more information on the MetaServlet application, see Non-GUI operation in metaServlet.
See below an example of migration between H2 and MySQL databases.
To be able to use this command, you need to put it on one single line first.
./MetaServletCaller.sh --tac-url http://localhost:8080/org.talend.administrator --json-params="{'actionName':'migrateDatabase','dbConfigPassword':'admin','mode':'synchronous','sourcePasswd':'tisadmin','sourceUrl':'jdbc:h2:/home/Talend/<version>/tac/apache-tomcat/webapps/org.talend.administrator/WEB-INF/database/talend_administrator','sourceUser':'tisadmin','targetPasswd':'root','targetUrl':'jdbc:mysql://localhost:3306/base','targetUser':'root'}"
- Encode special characters in source/target database URL. For example, encode & as %26 and ; as %3B.
- Use single quote for *json-params, for
example:
./MetaServletCaller.sh --tac-url http://192.168.30.36:8080/org.talend.administrator-7.3.1/ -v --json-params="{'actionName':'migrateDatabase','skipBackup':'true','dbConfigPassword':'admin','mode':'synchronous','sourcePasswd':'root','sourceUrl':'jdbc:mysql://mysql-8:3306/tac?useSSL=false%26serverTimezone=UTC%26allowPublicKeyRetrieval=true','sourceUser':'root','targetPasswd':'Root1234!','targetUrl':'jdbc:sqlserver://mssql-2017:1433%3BdatabaseName=tac','targetUser':'sa'}"
Use case: Migrating database X to database Y using MetaServlet
The examples use the following conventions:
Talend Administration Center URL
http://tac.test.fr:8081/org.talend.administrator/
DB config password: admin
MySQL
user: mysql8
password: mysqlpass
database: mysql
database server: mysql8.test.fr
jdbc:mysql://mysql8.test.fr:3306/mysql_source?useSSL=false&allowPublicKeyRetrieval=true
MSSQL2017
user: SA
password: MSSQLpass2017
database: MSSQL
database server: mssql2017.test.fr
jdbc:sqlserver://mssql2017.test.fr:1433;databaseName=MSSQL_DEST
Tomcat endorsed folder
You can store all the JDBC drivers you're using in the following folder: tac/apache-tomcat/endorsed or, depending on Tomcat, <TomcatPath>/webapps/org.talend.administrator/WEB-INF/lib .
Restart Tomcat if you add a driver.
For example, on Linux:
'jdbc:mysql://mysql8.test.fr:3306/mysql?useSSL=false&allowPublicKeyRetrieval=true'
It needs to be written as:
'jdbc:mysql://mysql8.test.fr:3306/mysql?useSSL=false\&allowPublicKeyRetrieval=true'
Migration from MySQL to MySQL
Use the following command:
mysql> drop database mysql_dest;
Query OK, 12 rows affected (0.10 sec)
mysql> create database mysql_dest;
Query OK, 1 row affected (0.00 sec)
mysql> grant ALL PRIVILEGES on *.* to 'mysql8'@'%';
Query OK, 0 rows affected (0.01 sec)
# /opt/Talend/tac/apache-tomcat/webapps/org.talend.administrator/WEB-INF/classes/MetaServletCaller.sh
--tac-url http://tac.test.fr:8081/org.talend.administrator/ -v
--json-params="{'actionName':'migrateDatabase','skipBackup':'true','dbConfigPassword':'admin','mode':'synchronous','sourcePasswd':'mysqlpass','sourceUrl':'jdbc:mysql://mysql8.test.fr:3306/mysql?useSSL=false\&allowPublicKeyRetrieval=true','sourceUser':'mysql8','targetPasswd':'mysqlpass','targetUrl':'jdbc:mysql://mysql8.test.fr:3306/mysql_dest?useSSL=false\&allowPublicKeyRetrieval=true','targetUser':'mysql8'}"
-> URL: http://tac.test.fr:8081/org.talend.administrator/
-> Json parameters:
"{
'actionName': 'migrateDatabase',
'dbConfigPassword': 'admin',
'mode': 'synchronous',
'skipBackup': 'true',
'sourcePasswd': 'mysqlpass',
'sourceUrl': 'jdbc:mysql://mysql8.test.fr:3306/mysql?useSSL=false&allowPublicKeyRetrieval=true',
'sourceUser': 'mysql8',
'targetPasswd': 'mysqlpass',
'targetUrl': 'jdbc:mysql://mysql8.test.fr:3306/mysql_dest?useSSL=false&allowPublicKeyRetrieval=true',
'targetUser': 'mysql8'
}"
-> Complete request: http://tac.test.fr:8081/org.talend.administrator//metaServlet?eyJhY3Rpb25OYW1lIjoibWlncmF0ZURhdGF...
{'executionTime':{'millis':20052,'seconds':20},'returnCode':0}
Migration from MySQL to MSSQL
If you're migrating to MSSQL/SQLServer, the source database and destination database name must be dbo. The dbo source database needs to be the active Talend Administration Center database.
Use the following command to create a destination database and schema:
$ /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P MSSQLpass2017
1> CREATE DATABASE dbo;
2> go
# /opt/Talend/tac/apache-tomcat/webapps/org.talend.administrator/WEB-INF/classes/MetaServletCaller.sh
--tac-url http://tac.test.fr:8081/org.talend.administrator/ -v
--json-params="{'actionName':'migrateDatabase','skipBackup':'true','dbConfigPassword':'admin','mode':'synchronous','sourcePasswd':'mysqlpass','sourceUrl':'jdbc:mysql://mysql8.test.fr:3306/dbo?useSSL=false\&allowPublicKeyRetrieval=true','sourceUser':'mysql8','targetPasswd':'MSSQLpass2017','targetUrl':'jdbc:jtds:sqlserver://mssql2017.test.fr:1433/dbo','targetUser':'SA'}"
-> URL: http://tac.test.fr:8081/org.talend.administrator/
-> Json parameters:
"{
'actionName': 'migrateDatabase',
'dbConfigPassword': 'admin',
'mode': 'synchronous',
'skipBackup': 'true',
'sourcePasswd': 'mysqlpass',
'sourceUrl': 'jdbc:mysql://mysql8.test.fr:3306/dbo?useSSL=false&allowPublicKeyRetrieval=true',
'sourceUser': 'mysql8',
'targetPasswd': 'MSSQLpass2017',
'targetUrl': 'jdbc:jtds:sqlserver://mssql2017.test.fr:1433/dbo',
'targetUser': 'SA'
}"
-> Complete request: http://tac.test.fr:8081/org.talend.administrator//metaServlet?eyJhY3Rpb25OYW1lIjoibWlncmF0ZURhdGF...
{'executionTime':{'millis':20062,'seconds':20},'returnCode':0}
Migrating from MSSQL to MySQL
Use the following command:
# /opt/Talend/tac/apache-tomcat/webapps/org.talend.administrator/WEB-INF/classes/MetaServletCaller.sh
--tac-url http://tac.test.fr:8081/org.talend.administrator/ -v
--json-params="{'actionName':'migrateDatabase','skipBackup':'true','dbConfigPassword':'admin','mode':'synchronous','sourcePasswd':'MSSQLpass2017','sourceUrl':'jdbc:jtds:sqlserver://mssql2017.test.fr:1433/mssql_test','sourceUser':'SA','targetPasswd':'mysqlpass','targetUrl':'jdbc:mysql://mysql8.test.fr:3306/mysql_dest?useSSL=false\&allowPublicKeyRetrieval=true','targetUser':'mysql8'}"
-> URL: http://tac.test.fr:8081/org.talend.administrator/
-> Json parameters:
"{
'actionName': 'migrateDatabase',
'dbConfigPassword': 'admin',
'mode': 'synchronous',
'skipBackup': 'true',
'sourcePasswd': 'MSSQLpass2017',
'sourceUrl': 'jdbc:jtds:sqlserver://mssql2017.test.fr:1433/mssql_test',
'sourceUser': 'SA',
'targetPasswd': 'mysqlpass',
'targetUrl': 'jdbc:mysql://mysql8.test.fr:3306/mysql_dest?useSSL=false&allowPublicKeyRetrieval=true',
'targetUser': 'mysql8'
}"
-> Complete request: http://tac.test.fr:8081/org.talend.administrator//metaServlet?eyJhY3Rpb25OYW1lIjoibWlncmF0ZURhdGF...
{'executionTime':{'millis':28108,'seconds':28},'returnCode':0}