canal实现Elasticsearch数据同步
⼀.canal介绍
canal 主要⽤途是基于 MySQL 数据库增量⽇志解析,提供增量数据订阅和消费
基于⽇志增量订阅和消费的业务包括
数据库镜像
数据库实时备份
索引构建和实时维护(拆分异构索引、倒排索引等)
业务 cache 刷新
带业务逻辑的增量数据处理
当前的 canal ⽀持源端 MySQL 版本包括 5.1.x , 5.5.x , 5.6.x , 5.7.x , 8.0.x
⼆. canal⼯作原理
植物种子的传播方式MySQL主备复制原理
MySQL master 将数据变更写⼊⼆进制⽇志( binary log, 其中记录叫做⼆进制⽇志事件binary log events,可以通过 show binlog events 进⾏查看)
MySQL slave 将 master 的 binary log events 拷贝到它的中继⽇志(relay log)
MySQL slave 重放 relay log 中事件,将数据变更反映它⾃⼰的数据
canal ⼯作原理
canal 模拟 MySQL slave 的交互协议,伪装⾃⼰为 MySQL slave ,向 MySQL master 发送dump 协议
MySQL master 收到 dump 请求,开始推送 binary log 给 slave (即 canal )
canal 解析 binary log 对象(原始为 byte 流)
三. 其他同步⽅案对⽐
四. canal搭建配置
canal.adapter下载地址:
canal-server下载地址:
canal-server: canal.properties配置
>>>>>>>>>####
>#### common argument >>###
>>>>>>>>>####
# tcp bind ip
canal.ip = 192.168.2.224
# register ip to zookeeper
虎皮青椒是什么地方的菜
canal.port = 11111
# canal instance user/passwd
# canal.user = canal
# canal.passwd = E3619321C1A937C46A0D8BD1DAC39F93B27D4458
# canal admin config
#canal.admin.manager = 127.0.0.1:8089
canal.admin.port = 11110
canal.admin.user = admin
canal.admin.passwd = 4ACFE3202A5FF5CF467898FC58AAB1D615029441
#canal.zkServers = 192.168.2.224:2181
# flush data to zk
canal.withoutNetty = false
# tcp, kafka, RocketMQ
canal.serverMode = tcp
# flush meta cursor/parse position to file
canal.file.data.dir = ${f.dir}
canal.file.flush.period = 1000
## memory store RingBuffer size, should be Math.pow(2,n)
buffer.size = 16384
## memory store RingBuffer used memory unit size , default 1kb
unit = 1024
## meory store gets mode used MEMSIZE or ITEMSIZE
de = MEMSIZE
rawEntry = true
## detecing config
canal.able = false
王者荣耀雅典娜#canal.instance.detecting.sql = insert into retl.xdual values(1,now()) on duplicate key update x=now()
canal.instance.detecting.sql = select 1
canal.instance.detecting.interval.time = 3
canal.threshold = 3
canal.instance.detecting.heartbeatHaEnable = false
# support maximum transaction size, more than the size of the transaction will be cut into multiple transactions delivery
ansaction.size = 1024
# mysql fallback connected to new master should fallback times
canal.instance.fallbackIntervalInSeconds = 60
# network config
iveBufferSize = 16384
canal.instancework.sendBufferSize = 16384
canal.instancework.soTimeout = 30
# binlog filter config
canal.instance.filter.druid.ddl = true
canal.instance.filter.query.dcl = false
canal.instance.filter.query.dml = false
canal.instance.filter.query.ddl = false
canal.instance. = false
canal.ws = false
canal. = false
# binlog format/image check
canal.instance.binlog.format = ROW,STATEMENT,MIXED
canal.instance.binlog.image = FULL,MINIMAL,NOBLOB
# binlog ddl isolation
ddl.isolation = false
# parallel parser config
canal.instance.parser.parallel = true
## concurrent thread number, default 60% available processors, suggest not to Runtime().availableProcessors() #canal.instance.parser.parallelThreadSize = 16
公租房 申请条件## disruptor ringbuffer size, must be power of 2
canal.instance.parser.parallelBufferSize = 256
# table meta tsdb info
canal.able = true
canal.instance.tsdb.dir = ${canal.file.data.dir:../conf}/${canal.instance.destination:}
canal.instance.tsdb.url = jdbc:h2:${canal.instance.tsdb.dir}/h2;CACHE_SIZE=1000;MODE=MYSQL;
canal.instance.tsdb.dbUsername = canal
canal.instance.tsdb.dbPassword = canal
# dump snapshot interval, default 24 hour
# dump snapshot interval, default 24 hour
canal.instance.tsdb.snapshot.interval = 24
# purge snapshot expire , default 360 hour(15 days)
canal.instance.pire = 360
# aliyun ak/sk , support rds/mq
canal.aliyun.accessKey =
canal.aliyun.secretKey =
>>>>>>>>>####
>#### destinations >>###
>>>>>>>>>####
canal.destinations = mogu #实例名称,需要在conf⽂件夹内创建同名⽂件夹,并添加instance.properties⽂件# conf root dir
# auto scan instance dir add/remove and start/stop instance
canal.auto.scan = true
canal.auto.scan.interval = 5
canal.instance.l = classpath:spring/l
#canal.instance.l = classpath:spring/l
canal.de = spring
canal.instance.global.lazy = false
canal.instance.global.manager.address = ${canal.admin.manager}
#canal.instance.l = classpath:l
canal.instance.l = classpath:l
#canal.instance.l = classpath:l
>>>>>>>>>>
>#### MQ >>###
>>>>>>>>>>
canal.mq.servers = 127.0.0.1:6667
ies = 0
canal.mq.batchSize = 16384
canal.mq.maxRequestSize = 1048576
canal.mq.lingerMs = 100
canal.mq.bufferMemory = 33554432
canal.mq.canalBatchSize = 50
canal.mq.canalGetTimeout = 100
canal.mq.flatMessage = true
canal.mqpressionType = none
canal.mq.acks = all
#canal.mq.properties. =
canal.mq.producerGroup = test
# Set this value to "cloud", if you want open message trace feature in aliyun.
canal.mq.accessChannel = local
# aliyun mq namespace
#canal.mq.namespace =
>>>>>>>>>>
>#### Kafka Kerberos Info >>###
>>>>>>>>>>
canal.mq.able = false
canal.mq.kafka.kerberos.krb5FilePath = "../conf/f"
canal.mq.kafka.kerberos.jaasFilePath = "../conf/f"
canal-server:instance.properties配置
>>>>>>>>>####
## mysql serverId , v1.0.26+ will autoGen
# sql.slaveId=0
# enable gtid use true/false
idon=false
# position info
canal.instance.master.address=192.168.2.243:3306 #mysql主数据库地址
canal.instance.master.journal.name=
canal.instance.master.position=
canal.instance.master.timestamp=
canal.id=
# rds oss binlog
canal.instance.rds.accesskey=
canal.instance.rds.secretkey=
canal.instance.rds.instanceId=
# table meta tsdb info
canal.able=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.id=
# username/password
canal.instance.dbUsername=root #数据库⽤户名
canal.instance.dbPassword=root #数据库密码
tionCharset = UTF-8
# enable druid Decrypt database password
ableDruid=false
#canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiN
# table regex
canal.=.*\\..*
# table black regex
canal.instance.=
# 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
pic=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,.*\\..*
眼霜好用排行榜2012>>>>>>>>>####
canal-adapter(canal是配置⽤于同步es、kafka、mq):l 配置
server:
port: 8081
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
详解MySQL双活同步复制四种解决方案
« 上一篇
mysql主备同步的基本原理
下一篇 »
热门文章
-
被女生问是不是喜欢她怎么回答显得高情商?
2024-12-21 -
怎么与内向的女生聊天
2024-12-21 -
男生表白情书(推荐22篇)
2024-12-21 -
男生写给女生的最深情的情信7篇
2024-12-21 -
女生给男生表白情书3篇
2024-12-21 -
相亲失败对男方说的得体话
2024-12-21 -
情绪演讲稿
2024-12-21 -
性格内向怎么跟人聊天
2024-12-21 -
2015年罗辑思维60秒文字版(1月-8月24日)
2024-12-21 -
送给为情所困男男女女的12句话
2024-12-21 -
追女孩的经典幽默笑话
2024-12-21 -
女生拒绝男生表白后男生的小作文
2024-12-21 -
如何拒绝男生的表白的小作文
2024-12-21 -
直接点的感人的表白的话,对女生对男生表白的话,无法拒绝的感人表白句子...
2024-12-21 -
女生给男生的情书9篇
2024-12-21 -
女生和女生聊天技巧
2024-12-21 -
女生给男生表白的话
2024-12-21 -
拒绝男生告白的话
2024-12-21 -
让男生无法拒绝的表白 女生表白男生的情书
2024-12-21 -
表白文本女生向男生500字
2024-12-21
最新文章
-
水瓶座暗恋一个人的表现是怎样的
2024-12-21 -
男生写给女生的情书
2024-12-21 -
男生爱女生个性签名
2024-12-21 -
甜言蜜语-情场沟通不要大意
2024-12-21 -
过年表白的话对男生
2024-12-21 -
每日经典神回复段子_各种机智神回复幽默段子集锦
2024-12-21
发表评论