9.20.2. thl apply Command

The thl apply command allows you to transfer THL from a source to a target, specifically the target does not need to be running Tungsten services.

thl apply [ -destination, -dst ] [ -no-log ] [ -service ] [ -source, -src ]

Where:

Table 9.45. thl apply Command-line Options

OptionDescription
-dst, -destinationSpecify the destination to apply. This should be a URI as either a mysql:// file:// or postgres:// endpoint, for example, mysql://myuser@myhost
-no-logDisable logging of transactions applied to the target binary log when destination is direct to a mysql database, if supported by the destination. Logging of transactions is enabled by default.
-serviceThe service to pull from when used in combination with -destination, in this case transactions will be sourced from the local service THL. When used with -source, it will apply to the service applier datasource
-src, -sourceSpecify the source when apply files from a directory or thl in the form of a URI, for example thl://hostname/.

thl apply can be used in a number of different use cases where you want to be able to apply THL either directly to a remote database, or to transfer THL between filesystems. This would result in additional backup/restore capabilities.

If applying directly into a remote database, the destination database can be either MySQL or PostgreSQL, and doesn't need to be part of a Tungsten topology. An example use case for this would be to feed a target database with specific transactions for testing purposes.

thl apply can also be used in recovery situations where failover within a Tungsten Cluster has resulted in transactions being available in the old primary THL but due to failures in network protocol, for example, were not applied the new primary. Using this command can then enable you to manually apply such transactions

Important

When transactions are applied directly to a database, statements that update the tungsten tracking schema are filtered out.

Important

By default, when applying transactions directly to MySQL, the transaction will be logged in the target binary logs if logging is enabled. If you DO NOT wish for this to happen, you will need to supply the -no-log option.

It is important to have this enabled when applying to a cluster as you will want the transactions to filter through the cluster to the downstream replicas.

Important

Both the -from and -to options must be supplied to provide a complete range of THL.

Note

When -destination is a directory, if the target directory doesn't exist, it will be created. For example -destination file:///tmp/newthl will result in the newthl directory being created within /tmp.

If the directory does exist, then it must be writeable by the OS user that issued the thl apply command.

9.20.2.1. Examples of using thl apply

Pushing THL from a service to remote MySQL

This example would be executed on a local host that is running the Tungsten Replicator service against a local database and has THL available locally. It is then written directly in a remote MySQL database:

shell> thl apply -service alpha -destination mysql://mysqlhostname/ -from 4 -to 1500
Using min and max seqno from store thl
 100% [====================================================================================================>] 1496/1496
THL successfully applied. Last applied seqno : 1500

Note

Unless specified in the destination URI, the database connection will be attempted as the user tungsten. If you need to create a user for this process, you should ensure that the user has the required privileges to write to the target schema/tables.

Pushing THL from a service to directory

This example would be executed on a local host that is running the Tungsten Replicator service against a local database and has THL available locally. THL is then written to a local directory.

shell> thl apply -service alpha -destination file:///tmp/newthl/ -from 4 -to 1500
 100% [====================================================================================================>] 1496/1496
THL successfully applied. Last applied seqno : 1500

Pushing THL from a directory to a directory

This example would be executed on a local host that hosts the Tungsten Replicator service and has THL available locally. Neither the database nor Tungsten Replicator need to be running on the source host. Raw THL is extracted and copied directly from the source files to the destination.

shell> thl apply -source file:///opt/continuent/thl/alpha -destination file:///tmp/newthl -from 10 -to 20
100% [====================================================================================================>] 10/10
THL successfully applied. Last applied seqno : 20

Pushing THL from a directory to MySQL

This example would be executed on a local host that hosts the Tungsten Replicator service and has THL available locally. Neither the database nor Tungsten Replicator need to be running on the source host. Raw THL is extracted and written directly from the source files to the destination database.

shell> thl apply -source file:///opt/continuent/thl/alpha -destination mysql://mysqlhostname/ -from 4 -to 1200
100% [====================================================================================================>] 1196/1196
THL successfully applied. Last applied seqno : 1200

Pushing THL from a directory to PostgreSQL

This example would be executed on a local host that hosts the Tungsten Replicator service and has THL available locally. Neither the database nor Tungsten Replicator need to be running on the source database. Raw THL is extracted and written directly from the source files to the destination database.

shell> thl apply -source file:///opt/continuent/thl/alpha -destination postgresql://username@pghostname/demo -from 3104 -to 3200
Enter password:
 100% [====================================================================================================>] 96/96
THL successfully applied. Last applied seqno : 3200

Pulling remote THL to service using a local service applier configuration

This example would be executed on a host that is running the Tungsten Replicator service through which we apply the THL pulled from the remote source defined by a THL URI. For this to work, the remote source would need to have an ONLINE Tungsten Replicator service running. By default, we will connect on the default port of 2112. If this differs, it should be included in the URI.

shell> thl apply -source thl://remotehost[:<port>]/ -service alpha -from 4 -to 1500
Connected to master on uri=null after 0 retries
Using min and max seqno from initial extractor stats 0 -> 3003
Applying 4 -> 1500
 100% [====================================================================================================>] 1496/1496
THL successfully applied. Last applied seqno : 1500

Pulling remote THL and applying to MySQL

This example would be executed on a host to which we write directly into MySQL, the THL pulled from the remote source defined by a THL URI. For this to work, the remote source would need to have an ONLINE Tungsten Replicator service running. By default, we will connect on the default port of 2112. If this differs, it should be included in the URI. Although Tungsten Replicator does not need to be running on the destination, you will still need to have access to the binaries either installed or accesible through the software staging directory.

shell> thl apply -src thl://remotehost[:<port>]/ -destination mysql://localhost -from 4 -to 1500>
Enter password:
Connected to master on uri=null after 0 retries
Using min and max seqno from initial extractor stats 0 -> 3003
Applying 4 -> 1500
 100% [====================================================================================================>] 1496/1496
THL successfully applied. Last applied seqno : 1500

Pulling remote THL and applying to local directory

This example would be executed on a host to which we write directly a local filesystem, the THL pulled from the remote source defined by a THL URI. For this to work, the remote source would need to have an ONLINE Tungsten Replicator service running. By default, we will connect on the default port of 2112. If this differs, it should be included in the URI. Although Tungsten Replicator does not need to be running on the destination, you will still need to have access to the binaries either installed or accesible through the software staging directory.

shell> thl apply -src thl://remotehost[:<port>]/ -destination file:///tmp/newthl -from 4 -to 1500
Connected to master on uri=null after 0 retries
Using min and max seqno from initial extractor stats 0 -> 3003
Applying 4 -> 1500
 100% [====================================================================================================>] 1496/1496
THL successfully applied. Last applied seqno : 1500