Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

canal 1.1.5 同步 es7.7.0 增量数据没法同步呀,手动全表同步却可以,求助! #2873

Open
liuchenbaidu opened this issue Jul 14, 2020 · 27 comments

Comments

@liuchenbaidu
Copy link

liuchenbaidu commented Jul 14, 2020

Question

环境:
Java:1.8
canal: 1.1.5
elastisearch:7.7.0

canal的deployer/config/example配置:
canal.instance.gtidon=false

###position info
canal.instance.master.address=10.90.0.11:3306
canal.instance.master.journal.name=
canal.instance.master.position=
canal.instance.master.timestamp=
canal.instance.master.gtid=

###rds oss binlog
canal.instance.rds.accesskey=
canal.instance.rds.secretkey=
canal.instance.rds.instanceId=

###table meta tsdb info
canal.instance.tsdb.enable=true
#canal.instance.tsdb.url=jdbc:mysql://127.0.0.1:3306/canal_tsdb
#canal.instance.tsdb.dbUsername=canal
#canal.instance.tsdb.dbPassword=canal

#canal.instance.standby.address =
#canal.instance.standby.journal.name =
#canal.instance.standby.position =
#canal.instance.standby.timestamp =
#canal.instance.standby.gtid=

###username/password
canal.instance.dbUsername=root
canal.instance.dbPassword=mima
canal.instance.connectionCharset = UTF-8
#canal.instance.defaultDatabaseName = database_name
###enable druid Decrypt database password
canal.instance.enableDruid=false
#canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiNdH1FWgGCpUfircSwlWKUCAwEAAQ==

###table regex
#canal.instance.filter.regex=.\..
canal.instance.filter.regex=call_bot.speech_intent_content
#table black regex
canal.instance.filter.black.regex=
###table field filter(format: schema1.tableName1:field1/field2,schema2.tableName2:field1/field2)
###canal.instance.filter.field=test1.t_product:id/subject/keywords,test2.t_company:id/name/contact/ch
###table field black filter(format: schema1.tableName1:field1/field2,schema2.tableName2:field1/field2)
###canal.instance.filter.black.field=test1.t_product:subject/product_image,test2.t_company:id/name/contact/ch

###mq config
canal.mq.topic=example
###dynamic topic route by schema or table regex
#canal.mq.dynamicTopic=mytest1.user,mytest2\..,.\..*
canal.mq.partition=0
###hash partition config
#canal.mq.partitionsNum=3
#canal.mq.partitionHash=test.table:id^name,.\..
#################################################

canal的adapter/config/application.yml配置
server:
port: 8081
spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
default-property-inclusion: non_null

canal.conf:
mode: tcp # kafka rocketMQ
canalServerHost: 127.0.0.1:11111
###zookeeperHosts: slave1:2181
###mqServers: 127.0.0.1:9092 #or rocketmq
###flatMessage: true
batchSize: 500
syncBatchSize: 1000
retries: 0
timeout:
accessKey:
secretKey:
username:
password:
vhost:
srcDataSources:
defaultDS:
url: jdbc:mysql://10.90.0.11:3306/call_bot?useUnicode=true
username: root
password: mima
canalAdapters:

  • instance: example # canal instance Name or mq topic name
    groups:
    • groupId: g1
      outerAdapters:
      • name: logger
      • name: es7
        ###key: exampleKey
        hosts: 127.0.0.1:9200 # 127.0.0.1:9200 for rest mode
        properties:
        mode: rest #transport # or rest
        ###security.auth: test:123456 # only used for rest mode
        cluster.name: my-application # elasticsearc

现象:
通过postman发送
http://10.90.0.10:8081/etl/es7/student.yml 同步请求,全表同步过来了
但是在mysql里插入数据,却不能同步到es里。搞了好几天了,求助。

@liusonfer
Copy link

问题解决了吗

@liusonfer
Copy link

我也卡了好几天

@liuchenbaidu
Copy link
Author

问题解决了吗

没呢,配置的参数试了遍,怀疑是es7x.etl.ESEtlService 没有调用,因为adapter已经检测到binlog里的insert事件了。java不懂呀,不然直接debug了,应该是1.1.5在某个条件下才调用es7x.etl.ESEtlService。解决了跟我说一下哈

@liusonfer
Copy link

好烦 我卡了几天 好的 ,到时候你解决了也告知一声

@liuchenbaidu
Copy link
Author

好烦 我卡了几天 好的 ,到时候你解决了也告知一声

你是什么现象?能增加一条然后同步吗

@huangdanyu
Copy link

我的也是 es7.4 canal1.1.5 阿里云的数据库8.0 不能增量同步

@liuchenbaidu
Copy link
Author

我的也是 es7.4 canal1.1.5 阿里云的数据库8.0 不能增量同步

全量可以吗?是什么现象

@huangdanyu
Copy link

https://abcops.cn/1279.html 我按照这个教程来了 全量和增量都可以了

@sunyaer66
Copy link

@huangdanyu 我也是按那个教程来的, 但不行. 能否帮忙看看?

我的是在阿里云ECS上搭建 , es7.8.1 canal1.1.5, 阿里云的rds数据库8.0
kibana, chrome-head 都运行得好好的, 在kibana可以写入数据. 数据库更改, canal-adapter检测到, 但没有写入es. 没有错误日记.

@huangdanyu
Copy link

@sunyaer66 下面的添加权限步骤做了吗,还有我的es版本也是7.4。如果修改权限还能用,试试将es版本改成7.4。

2.添加mysql8.0.18连接器
默认canal-adapter的lib中只有mysql5.x版本的连接器

wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.18/mysql-connector-java-8.0.18.jar
mv mysql-connector-java-8.0.18.jar /usr/local/canal-adapter/lib/
chmod 777 /usr/local/canal-adapter/lib/mysql-connector-java-8.0.18.jar #权限修改与其它lib库一致
chmod +st /usr/local/canal-adapter/lib/mysql-connector-java-8.0.18.jar

@sunyaer66
Copy link

@huangdanyu 这两天试试,再回来汇报结果。多谢了。

@sunyaer66
Copy link

sunyaer66 commented Aug 14, 2020

@huangdanyu 啥都做了, 也换成了es 7.4.1, 还是没有写入es

不知能否帮忙看看 (远程也可以).

这是 es7/ es_test.yml

dataSourceKey: defaultDS
destination: example
groupId: g1
esMapping:
_index: es_test
_id: _id
upsert: true
sql: "select t.id as _id, t.id,t.count,t.name,t.color from es_test t"
commitBatch: 3000

这是adapter 的 application.yml

server:
port: 8081
spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
default-property-inclusion: non_null
canalServerHost: 127.0.0.1:11111
batchSize: 500
syncBatchSize: 1000
retries: 0
timeout:
accessKey:
secretKey:
username:
password:
vhost:
srcDataSources:
defaultDS:
url: jdbc:mysql:/rm-3ns1f77g7856g4137125010.mysql.rds.aliyuncs.com:3306/mytest?useUnicode=true
username: my-sql
password: my-pass
canalAdapters:

  • instance: example # canal instance Name or mq topic name
    groups:
    • groupId: g1
      outerAdapters:
      • name: logger
      • name: es7
        hosts: 127.0.0.1:9300 # 127.0.0.1:9300 for transport mode
        properties:
        mode: transport
        cluster.name: my-es

@huangdanyu
Copy link

@sunyaer66 哥们 刚看到 url: jdbc:mysql:/rm-3ns1f77g7856g4137125010.mysql.rds.aliyuncs.com:3306/mytest?useUnicode=true 兄弟 你字符串少写了斜杠 url 写的不正确会导致不同步到es 且日志也不会报错

@huangdanyu
Copy link

@sunyaer66 正确的 url: jdbc:mysql://rm-3ns1f77g7856g4137125010.mysql.rds.aliyuncs.com:3306/mytest?useUnicode=true

@zhanghs0901
Copy link

url写错的问题我也碰到过,当时调了半天,更好做法应该是在启动的时候做检查如果db的url不通或格式错误直接报错

@huangdanyu
Copy link

@zhanghs0901

@hhanhao
Copy link

hhanhao commented Jul 1, 2021

看下是不是有多个adapter同时消费一个example,我测试代码和adapter先后都起了,只有测试代码再消费。

@RodyTime
Copy link

同样不能增量同步的路过。。。插眼

@RodyTime
Copy link

com.alibaba.druid.pool.DruidDataSource cannot be cast to com.alibaba.druid.pool.DruidDataSource 报错信息

@RodyTime
Copy link

将 v1.1.5-alpha-2 的 adapter/plugin/client-adapter.es7x-1.1.5-SNAPSHOT-jar-with-dependencies.jar
替换到正式 1.1.5 plugin/client-adapter.es7x-1.1.5-jar-with-dependencies.jar
这在我的节点上,经过测试一切运行正常。 其他issue给出的解决方案,实测可用 mysql5.7.26 cannal1.1.5 es7.13.3

@RodyTime
Copy link

ubuntu环境 记录一个错误 宝塔安装的mysql 启用了ssl 会导致报错协议被禁用的错,禁用(skip-ssl)以后,即可实现全量同步,增量同步

@RodyTime
Copy link

ubuntu环境 记录一个错误 宝塔安装的mysql 启用了ssl 会导致报错协议被禁用的错,禁用(skip-ssl)以后,即可实现全量同步,增量同步暂时不行。。。。试试上面的方法。

@RodyTime
Copy link

试了上面的替换dependencies.jar方法,ubuntu环境也实现了

@PeteLuo
Copy link

PeteLuo commented Aug 23, 2021

查看mysql binlog格式是否为ROW
show global variables like "binlog_format";
如果不为ROW,需要修改为ROW

my.cnf里设置:
binlog_format=ROW

或mysql终端执行:
set global binlog_format=ROW;

@zhongjing
Copy link

同问,
目前只能 写个定时器 用etl 做了,
原来mysql 同步到 mysql ,是因为canal-server里面
canal.instance.filter.regex=test1.export_data_config 这个配置要写具体,不然无法增量实时同步

但是mysql 同步到ES7 , 还没找到错误的地方,
dependencies.jar 也重新编译替换了,中间也是各种问题,解决之后还是不能 实时增量同步

@zhongjing
Copy link

我的问题解决了,
在canal-adapter里面 把mode 改成 transport,如果是 rest则不能增量同步
properties:
mode: transport

@sunbirder
Copy link

我遇到类似问题, 配置里面的sql异常, 虽然可以正常执行, 但是canal不能完全支持, 也没有异常提示导致的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants