Canal结合RocketMQ同步MySQL到Redis的方法步骤
本篇内容主要讲解“Canal结合RocketMQ同步MySQL到redis的方法步骤”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Canal结合RocketMQ同步MySQL到Redis的方法步骤”吧!
网站建设哪家好,找成都创新互联公司!专注于网页设计、网站建设、微信开发、重庆小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了同心免费建站欢迎大家使用!
一、 安装Canal
Docker 安装单机 Canal
二、 安装RocketMQ
Docker安装单机RocketMQ
三、配置Canal的MQ
官方文档
3.1 修改 Canal Server配置
################################################# ######### common argument ############# ################################################# # canal admin config canal.admin.manager = 192.168.25.142:8089 canal.admin.port = 11110 canal.admin.user = admin canal.admin.passwd = 4ACFE3202A5FF5CF467898FC58AAB1D615029441 canal.serverMode = RocketMQ ################################################## ######### MQ ############# ################################################## canal.mq.servers = 192.168.25.142:9876 canal.mq.retries = 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.mq.compressionType = 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.kafka.kerberos.enable = false canal.mq.kafka.kerberos.krb5FilePath = "../conf/kerberos/krb5.conf" canal.mq.kafka.kerberos.jaasFilePath = "../conf/kerberos/jaas.conf"
修改好后,点击保存
3.2 核对instance配置
intance.properties
不需要修改,此处列出配置,方便大家避坑
################################################# ## mysql serverId , v1.0.26+ will autoGen # canal.instance.mysql.slaveId=0 # enable gtid use true/false canal.instance.gtidon=false # position info canal.instance.master.address=192.168.25.1: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=canal canal.instance.dbPassword=canal canal.instance.connectionCharset = UTF-8 # enable druid Decrypt database password canal.instance.enableDruid=false #canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiNdH1FWgGCpUfircSwlWKUCAwEAAQ== # table regex canal.instance.filter.regex=.*\\..* # 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=test.user,student\\..*,.*\\..* canal.mq.partition=0 # hash partition config canal.mq.partitionsNum=3 canal.mq.partitionHash=test.users:uid,.*\\..* #################################################
四、 重启Canal Server和Canal Instance
查看Canal Server
日志
查看Canal Instance
日志
五、 启动Canal测试RocketExample
5.1 拉取代码
$ git clone https://github.com/alibaba/canal.git
5.2 启动测试代码
修改RocketMQ配置
启动Main
方法,并查看控制台
注意: running now...不代表就连接Broker成功了,这里坑了好久
六、 测试发送
6.1 MySQL插入数据
6.2 查看RocketMQ运维控制台
点击Message Detail
6.3 查看RocketMQ Consume控制台
到此,相信大家对“Canal结合RocketMQ同步MySQL到Redis的方法步骤”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
网页题目:Canal结合RocketMQ同步MySQL到Redis的方法步骤
标题路径:http://scjbc.cn/article/gohpjh.html