ltdts_mysql

ltdts_mysql(Experiment) — ltdts_mysql is used for synchronize data from MySQL|MariaDB to LightDB.

Synopsis

java -jar ltdts_mysql.jar [option...]

example:

java -jar ltdts_mysql.jar --server.port=8888 --zk=127.0.0.1:2181 --kafka=127.0.0.1:9092 --db=database --lh=127.0.0.1:5432/test --lu=lightdb --lp=lightdb123 --bl=table1,table2
   

Description

ltdts_mysql is used for synchronize data from MySQL|MariaDB to LightDB. Before you run the ltdts_mysql.jar, you should finish the prepare work as blow first.

Zookeeper

You can download it from this url:https://dlcdn.apache.org/zookeeper/zookeeper-3.8.0/apache-zookeeper-3.8.0-bin.tar.gz

# unpack the package
tar -zxvf apache-zookeeper-3.8.0-bin.tar.gz
# create a new directory to store zookeeper data
mkdir zk-data
cd conf/
# copy file
cp zoo_sample.cfg zoo.cfg
# edit file
vim zoo.cfg
dataDir=/data/lightdb/zm/apache-zookeeper-3.8.0-bin/zk-data

cd apache-zookeeper-3.8.0-bin/bin
# start zookeeper server
./zkServer.sh start

Kafka

You can download kafka from this url:https://downloads.apache.org/kafka/3.3.1/kafka_2.12-3.3.1.tgz

You can download Debezium for mysql from this url:https://repo1.maven.org/maven2/io/debezium/debezium-connector-mysql/1.9.7.Final/debezium-connector-mysql-1.9.7.Final-plugin.tar.gz

# unpack the kafka package
tar -zxvf kafka_2.12-3.3.1.tgz
# unpack the debezium package
unzip debezium-debezium-connector-mysql-1.9.7.zip

# create a new directory to store kafka data
mkdir kafka-data

# create a new directory to store kafka plugin
mkdir kafka-plugin

# move the debezium directory to kafka-plugin
mv debezium-debezium-connector-mysql-1.9.7 kafka-plugin/

# then the kafka directory is like below
--kafka_2.12-3.3.1
   --config
   --bin
   --kafka-data
   --kafka-plugin
      --debezium-debezium-connector-mysql-1.9.7


# edit the kafka'server.properties
vim server.properties
# please change the value like this
log.dirs=/data/lightdb/zm/kafka_2.12-3.3.1/kafka-data
# please change the value like this,use your address
listeners=PLAINTEXT://Your IP:9092


# edit the kafka'connect-distributed.properties
vim connect-distributed.properties
# please change the value like this,use your address
bootstrap.servers=Your IP:9092
listeners=HTTP://Your IP:8083
# please change the value like this
plugin.path=/data/lightdb/zm/kafka_2.12-3.3.1/kafka-plugin


# start kafka
cd kafka_2.12-3.3.1/bin
./kafka-server-start.sh -daemon ../config/server.properties

# start kafka connect
./connect-distributed.sh -daemon ../config/connect-distributed.properties

Debezium


# you should check kafka connect is available first,use your IP address
curl -H "Accept:application/json" IP:8083/

# list all the kafka connectors
curl -H "Accept:application/json" IP:8083/connectors

# deploying the MySQL connector
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" IP:8083/connectors/ -d '{
    "name": "test-connector",
    "config": {
        "connector.class": "io.debezium.connector.mysql.MySqlConnector",
        "tasks.max": "1",
        "database.hostname": "mysql host,example:127.0.0.1",
        "database.port": "3306",
        "database.user": "mysql user",
        "database.password": "mysql password",
        "database.server.id": "184077",
        "database.server.name": "mysql database name,example:acm",
        "database.include.list": "mysql database name,example:acm",
        "database.history.kafka.bootstrap.servers": "your kafka IP and port,example:127.0.0.1:9092",
        "database.history.kafka.topic": "schema-changes.acm",
        "include.schema.changes": "true",
        "decimal.handling.mode": "string",
        "include.schema.comments": "false"
    }
}'

# delete the MySQL connector
curl -v -X DELETE IP:8083/connectors/test-connector

# check the connector's work status
curl -i IP:8083/connectors/test-connector/status

# view the connector's config
curl -i IP:8083/connectors/test-connector/config

Options

At least one of the following options must be specified to select an action:

--zk

Specifies the host of the Zookeeper and the port of the Zookeeper. The format is like 127.0.0.1:2181

--kafka

Specifies the host of the Kafka and the port of the Kafka. The format is like 127.0.0.1:9092

--db

The source database you want to synchronize.It can also be understood as kafka topic,because the kafka is been used.

--lh

Specifies the host of the LightDB,the port of the LightDB,and the database name of the LightDB. The format is like 192.168.1.1:5432/postgres

--lu

LightDB user name to connect as.

--lp

LightDB user password.

--bl

Blacklist table not to synchronize, if you have more then one, separate by ','.

See Also

ltdts_recvlogical