阿里DatatX mysql8往 Elasticsearch 7 插入时间数据 时区引发的问题

1、mysql 读取错误指定serverTimezone=UTC

jdbc:mysql://192.168.8.248:3306/sourcedb?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC"

2、改成北京或者上海东八区时间

"jdbc:mysql://192.168.8.248:3306/sourcedb?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai"

3、时间字段需要把date类型变成text类型

{ "name": "createdate","type": "text", "format": "yyyy-MM-dd HH:mm:ss.SSSSSS"}

4、完成以上步骤,导入数据时间格式正确

以后为调试记录:

用来配置Elasticsearch Writer,详情请参见Elasticsearch Writer。
index:索引名称。
indexType:索引类型,7.0及以上版本的Elasticsearch必须使用_doc。
使用数据库id作为es中记录的_id
{"name": "pk", "type": "id"},
name指定为id,type也指定为id,这样就会把数据库的id作为es中的id了。
不需要再指定name为id的字段了,不然会报错 
   { "name": "col_text", "type": "text", "analyzer": "ik_max_word"},
   
注意时区问题 写入时指定时区 或 对UTC时间戳进行转换

指定:“2019-03-12T12:12:12.123+0800”
转换:东八区时间戳 = 3600000*8 + UTC时间戳   
   
4.4.1.ES日期字段创建需指定格式 yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis

{
     "name": "CREATE_DATE",
     "type": "date",
     "format": "yyyy-MM-dd HH:mm:ss"
}
4.4.2.日期数据导入时,text写入为日期格式,long写入为时间戳

4.4.3.注意时区问题 写入时指定时区 或 对UTC时间戳进行转换

指定:“2019-03-12T12:12:12.123+0800”
转换:东八区时间戳 = 3600000*8 + UTC时间戳
{ "name": "createdate","type": "date", "format": "yyyy-MM-dd HH:mm:ss||epoch_millis"}
 { "name": "createdate","type": "text", "format": "yyyy-MM-dd HH:mm:ss"}
       { "name": "createdate","type": "text", "format": "yyyy-MM-dd HH:mm:ss"}
      
Asia/Shanghai
//北京时间东八区
serverTimezone=GMT%2B8 
//上海时间
serverTimezone=Asia/Shanghai
为解决此问题,可以选择东8区的Hongkong、Asia/Shanghai或者Asia/Hongkong作为参数,修改后url为    
原文地址:https://www.cnblogs.com/Jeely/p/15242480.html