14 March 2016
14 March 2016,
 Off

By OrientDB Developer Gabriele Ponzi

Teleporter to Sync your DB and OrientDB

This is Part 2 of our step by step guide on how to use Teleporter to migrate and synchronize your database with OrientDB.

If you are interested in a detailed description of the tool, of its inner workings and features, please read the previous post (part 1) or the official documentation.

In short, OrientDB Teleporter is a tool that synchronizes a RDBMS to an OrientDB database. You can use Teleporter to:

- Import your existing RDBMS to OrientDB.

- Keep your OrientDB database synchronized with changes from the RDBMS. In this case the database on RDBMS remains the primary one and the database on OrientDB a synchronized copy. Synchronization is one way, so all the changes in the OrientDB database will not be propagated to the RDBMS.

This means that the first execution process performs a migration from scratch, whereas all subsequent migrations on the same target OrientDB graph database carry out a synchronization between your source database and OrientDB.
This dual behaviour is transparent to the user who will always follow the same procedure.

Teleporter is fully compatible with several RDBMS that have a JDBC drivers: we successfully tested Teleporter with Oracle, SQLServer, MySQL, PostgreSQL and HyperSQL. Teleporter manages all the necessary type conversions between the different DBMSs and imports all your data as a Graph in OrientDB.
This tool is really easy to use thanks to a completely automatic and clear execution which require few important parameters. At the same time, it’s possible to enrich the migration process by specifying different strategies and customizations which allow you to obtain more refined results.

Now let’s start from the simplest migration case. First of all, you can invoke the tool through  the oteleporter.sh (Unix and OS X platforms) or oteleporter.bat (Windows platforms) scripts. Then you must type 3 mandatory arguments to begin your import:

- -jdriver: is the driver name of the DBMS from which you want to execute the import.

- -jurl: is the JDBC URL giving the location of the source database to import.

- -ourl: is the URL for the destination Orient graph database.

 If credentials are required to access your source database you have to type two  more arguments:

- -juser: is the username to access the source database.

- -jpasswd is the password to access the source database.

Thus, in this case the generic call to Teleporter looks like this:

oteleporter.sh -jdriver <jdbc-driver> -jurl <jdbc-url> -juser <username>

-jpasswd <password> -ourl <orientdb-url>

 

All other parameters are optional: now let’s start with a standard migration from each compatible DBMS.

When you specify the DBMS you want to connect with through the argument -jdriver, you must choose amongst the following values:

- Oracle

- SQLServer

- MySQL

- PostgreSQL

- HyperSQL

N.B.: the driver identification is not case sensitive, so you may also type  “oracle”, “sqlserver” etc.

Migrating and Syncing with your database

Let’s suppose we want to import the source database “source-db”  into an OrientDB graphDB called “myTargetDB” and that the source database relies on our local machine with credentials admin|admin.
Depending on our specific DBMS we’ll type the different commands reported in the following table:

DBMS

SOURCE DB URL FORMAT

TELEPORTER COMMAND

Oracle

jdbc:oracle:thin:@<HOST>:<PORT>:<SID>

oteleporter.sh -jdriver Oracle

-jurl jdbc:oracle:thin:@localhost:1521:xe
-juser admin -jpasswd admin
-ourl /ORIENTDB_HOME/databases/myTargetDB

SQLServer

jdbc:sqlserver://<HOST>:<PORT>;databaseName=<DB>

oteleporter.sh -jdriver SQLServer

-jurl jdbc:sqlserver://localhost:1433;databaseName=source-db
-juser admin-jpasswd admin
-ourl /ORIENTDB_HOME/databases/myTargetDB
(*)

MySQL

jdbc:mysql://<HOST>:<PORT>/<DB>

oteleporter.sh -jdriver MySQL

-jurl jdbc:mysql://localhost:3306/source-db
-juseradmin -jpasswd admin
-ourl /ORIENTDB_HOME/databases/myTargetDB

PostgreSQL

jdbc:postgresql://<HOST>:<PORT>/<DB>

oteleporter.sh -jdriver PostgreSQL

-jurl jdbc:postgresql://localhost:5432/source-db
-juser admin -jpasswd admin
 -ourl /ORIENTDB_HOME/databases/myTargetDB

HyperSQL

jdbc:hsqldb:hsql://<HOST>/<DB>

(connection to a database server)

jdbc:hsqldb:file:<filepath>,
jdbc:hsqldb:mem:<DB>,
jdbc:hsqldb:res:<package name>

(connection to a resource)

oteleporter.sh -jdriver HyperSQL

-jurl jdbc:hsqldb:hsql://localhost/source-db
-juser admin-jpasswd admin
 -ourl /ORIENTDB_HOME/databases/myTargetDB

(*) If the source database contains spaces in the name you have to use a URL like this:
“Source DB” →  -jurl “jdbc:sqlserver://localhost:1433;databaseName={Source DB};”

Next, we must simply wait for the process to end.

Migration with optional parameters

If you want to enrich the migration process from your specific DBMS with optional parameters, you just have to type them following the syntax described in the documentation and in the previous post [link].
Here I report the complete command syntax:

oteleporter.sh -jdriver <jdbc-driver> -jurl <jdbc-url> -ourl <orientdb-url>

[-juser <username>] [-jpasswd <password>] [-s <strategy>]
[-nr <name-resolver>] [-v <verbose-level>]
([-include <table-names>] | [-exclude <table-names>])
[-inheritance <orm-technology>:<ORM-file-url>]

 

I hope this post was helpful and interesting.

Stay tuned,

Gabriele Ponzi
OrientDB Ltd

Download OrientDB Teleporter!

References:
Teleporter full documentation

 

 

Comments are closed.