flink-connector-jdbc 落入mysql的时候timestamp 有时差问题

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

flink-connector-jdbc 落入mysql的时候timestamp 有时差问题

dushang-2
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: flink-connector-jdbc 落入mysql的时候timestamp 有时差问题

Kyle Zhang
感觉是时区的问题 ,是使用ddl做的么

*show* variables *like* '%time_zone%’ 看一下

On Tue, Oct 13, 2020 at 2:56 PM 姬洪超 <[hidden email]> wrote:

> flink-connector-jdbc 获取mysql的timestamp类型的数据后,sink到mysql后时间会晚八个小时。Ex:
> 获取到的是2020-05-12T11:53:08,写入mysql后变成2020-05-11 22:53:08
Reply | Threaded
Open this post in threaded view
|

Re: flink-connector-jdbc 落入mysql的时候timestamp 有时差问题

dushang-2
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

回复: flink-connector-jdbc 落入mysql的时候timestamp 有时差问题

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

________________________________
发件人: dushang <[hidden email]>
发送时间: 2020年10月13日 8:38
收件人: [hidden email] <[hidden email]>
主题: 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/