OrientDB Teleporter: Making Migrations Easier (Part 2)
Want to move your database to a graph-based system? OrientDB's Teleporter makes that easy. See the supported databases and learn the code that makes it tick.
Join the DZone community and get the full member experience.
Join For FreeThis article is a step by step guide on how 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 or the official documentation.
In short, OrientDB Teleporter is a tool that synchronizes an 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 behavior is transparent to the user who will always follow the same procedure.
Teleporter is fully compatible with several RDBMS that have 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 requires a 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: the driver name of the DBMS from which you want to execute the import.
-jurl: the JDBC URL giving the location of the source database to import.
-ourl: the URL for the destination OrientDB 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: 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.
Migration and Sync 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 -juser admin -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 | a) jdbc:hsqldb:hsql://<HOST>/<DB> (connection to a database server) b) jdbc:hsqldb:file:<filepath>, jdbc:hsqldb:mem:<DB>, jdbc:hsqldb:res:<package name> (connection to a resource) | oteleporter.sh -jdriver HyperSQL |
(*) 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.
Here, I report the complete command syntax:
./oteleporter.sh -jdriver <jdbc-driver> -jurl <jdbc-url> -juser <username>
-jpasswd <password> -ourl <orientdb-url> [-s <strategy>]
[-nr <name-resolver>] [-v <verbose-level>]
([-include <table-names>] | [-exclude <table-names>])
[-inheritance <orm-technology>:<ORM-file-url>]
[-conf <configuration-file-location>]
I hope this post was helpful and interesting. Stay tuned.
Opinions expressed by DZone contributors are their own.
Trending
-
Building and Deploying Microservices With Spring Boot and Docker
-
Tomorrow’s Cloud Today: Unpacking the Future of Cloud Computing
-
Auto-Scaling Kinesis Data Streams Applications on Kubernetes
-
Merge GraphQL Schemas Using Apollo Server and Koa
Comments