You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-zh@flink.apache.org by 姬洪超 <ji...@geekplus.com> on 2020/10/13 06:18:53 UTC
flink-connector-jdbc 落入mysql的时候timestamp 有时差问题
flink-connector-jdbc 获取mysql的timestamp类型的数据后,sink到mysql后时间会晚八个小时。Ex: 获取到的是2020-05-12T11:53:08,写入mysql后变成2020-05-11 22:53:08
回复: flink-connector-jdbc 落入mysql的时候timestamp 有时差问题
Posted by 史 正超 <sh...@outlook.com>.
的sink表的 url后面加上 &serverTimezone=Asia/Shanghai
________________________________
发件人: dushang <ji...@geekplus.com>
发送时间: 2020年10月13日 8:38
收件人: user-zh@flink.apache.org <us...@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/
Re: flink-connector-jdbc 落入mysql的时候timestamp 有时差问题
Posted by dushang <ji...@geekplus.com>.
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/
Re: flink-connector-jdbc 落入mysql的时候timestamp 有时差问题
Posted by Kyle Zhang <sh...@gmail.com>.
感觉是时区的问题 ,是使用ddl做的么
*show* variables *like* '%time_zone%’ 看一下
On Tue, Oct 13, 2020 at 2:56 PM 姬洪超 <ji...@geekplus.com> wrote:
> flink-connector-jdbc 获取mysql的timestamp类型的数据后,sink到mysql后时间会晚八个小时。Ex:
> 获取到的是2020-05-12T11:53:08,写入mysql后变成2020-05-11 22:53:08