的sink表的 url后面加上 &serverTimezone=Asia/Shanghai

________________________________
发件人: dushang <jihongc...@geekplus.com>
发送时间: 2020年10月13日 8:38
收件人: user-zh@flink.apache.org <user-zh@flink.apache.org>
主题: Re: flink-connector-jdbc 落入mysql的时候timestamp 有时差问题

time_zone       SYSTEM
system_time_zone SYSTEM

我是通过 flink-sql-connector-mysql-cdc获取mysql的binlog。通过flink-connector-jdbc
sink到mysql中。
source 中有调节时区的参数。所以读取到的是正确的。但是sink 中没有调节时区的参数。时间就有了时差。

source:
CREATE TABLE student (
 id INT,
  name STRING,
  create_time TIMESTAMP(0),
  update_time TIMESTAMP(0),
  time_ds STRING,
  ret INT
) WITH (
  'connector' = 'mysql-cdc',
  'hostname' = '127.0.0.1',
  'port' = '3306',
  'username' = 'dev',
  'password' = '**',
  'database-name' = 'wms',
  'table-name' = 'student',
  'source-offset-file' = 'mysql-bin.000007',
  'source-offset-pos' = '1574112',
  'server-time-zone' = 'Asia/Shanghai'
);

sink:
CREATE TABLE student_02 (
 id INT,
  name STRING,
  create_time TIMESTAMP(0),
  PRIMARY KEY (id) NOT ENFORCED
) WITH (
   'connector' = 'jdbc',
   'url' = 'jdbc:mysql://127.0.0.1:3306/wms',
   'table-name' = 'student_02',
   'username' = 'dev',
   'password' = '***'
);



--
Sent from: http://apache-flink.147419.n8.nabble.com/

回复