All Products
Search
Document Center

Flink AnalyticDB MySQL Connector

Last Updated: Apr 20, 2021

This topic describes how to write the data of Apache Flink to AnalyticDB for MySQL.

Procedure

  1. The following versions of JAR packages are supported in this topic. Click the corresponding link to download a required package.

  2. Go to the /home/admin/flink-1.10.1/lib directory of each Apache Flink node and replace the flink-jdbc_2.11-1.10.1.jar file with JAR packages downloaded in Step 1.

  3. Restart all the Apache Flink nodes.

  4. Create an AnalyticDB for MySQL table in Apache Flink. You must add the dialect of AnalyticDB for MySQL.

CREATE TABLE table_test (
 col1 VARCHAR,
 col2 BIGINT,
 col3 BIGINT
) WITH (
 'connector.type' = 'jdbc', -- Use a JDBC connector.
 'connector.dialect'='adb ', -- Use the connector dialect.
 'connector.url' = 'jdbc:mysql://ip:port/db_name', -- jdbc url
 'connector.table' = 'table_name', -- The name of the table.
 'connector.username' = 'xxx', -- The username of the account that owns the destination AnalyticDB for MySQL cluster.
 'Connector.password'='xxx ', -- The password of the account that owns the destination AnalyticDB for MySQL cluster.
);

For more information about Apache Flink, see Flink.