This topic describes how to write the data of Apache Flink to AnalyticDB for MySQL.
Procedure
Go to the
/home/admin/flink-1.10.1/lib
directory of each Apache Flink node and replace theflink-jdbc_2.11-1.10.1.jar
file with flink-jdbc-adb-compatibility_2.11-1.10.10.jar.Restart all the Apache Flink nodes.
Create an AnalyticDB for MySQL table in Apache Flink.
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 user name 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.