zoukankan      html  css  js  c++  java
  • canal 配置 多个监听 推送到不同mq

    canal整合rabbitmq  见上篇  

    如果想监听不同库 不同表到不同队列如何操作 

    1. vim canal.properties

    canal.destinations = route1,route2

    设置目的地为多个  对应的目录是conf下的对应名字的目录 

    2 复制example 为新的 

    cp -r example route1
    cp -r example route2

    chmod -R 777 route1

    chmod -R 777 route2

    rm -rf example/

    3 cd route1  设置监听表为test库的uesr表 

    vim instance.properties

    canal.instance.filter.regex=test.user  

    canal.mq.topic=route1

    4 cd route2 

    vim instance.properties

    canal.instance.filter.regex=test.tests

    canal.mq.topic=route2

    表过滤规则 规定要监听那些库 那些表

    canal.instance.filter.regex 

    mysql 数据解析关注的表,Perl正则表达式.多个正则之间以逗号(,)分隔,转义符需要双斜杠(\) 
    常见例子:
    1. 所有表:.* or .*\..*
    2. canal schema下所有表: canal\..*
    3. canal下的以canal打头的表:canal\.canal.*
    4. canal schema下的一张表:canal.test1
    5. 多个规则组合使用:canal\..*,mysql.test1,mysql.test2 (逗号分隔)
    注意:此过滤条件只针对row模式的数据有效(ps. mixed/statement因为不解析sql,所以无法准确提取tableName进行过滤)

    5 手动建立队列 绑定 到交换机,用定义的route1 和route2 

    分别更改两个表数据 

    结果两个队列都分别收到数据

    {"data":[{"id":"1","name":"3234234","age":"10","sex":"1","created_at":"2010-09-09 11:11:11","updated_at":"2020-08-15 00:56:53"}],"database":"test","es":1597424213000,"id":2,"isDdl":false,"mysqlType":{"id":"int(11)","name":"varchar(255)","age":"int(11)","sex":"int(255)","created_at":"timestamp","updated_at":"timestamp"},"old":[{"name":"sdsf","updated_at":"2020-08-15 00:39:33"}],"pkNames":["id"],"sql":"","sqlType":{"id":4,"name":12,"age":4,"sex":4,"created_at":93,"updated_at":93},"table":"user","ts":1597424213307,"type":"UPDATE"}
     
     
    {"data":[{"id":"2","name":"sdsdf","age":"10","sex":"1","created_at":"2010-09-09 11:11:11","updated_at":"2020-08-15 00:57:29"}],"database":"test","es":1597424249000,"id":3,"isDdl":false,"mysqlType":{"id":"int(11)","name":"varchar(255)","age":"int(11)","sex":"int(255)","created_at":"timestamp","updated_at":"timestamp"},"old":[{"name":"wersdf","updated_at":"2020-07-25 09:27:35"}],"pkNames":["id"],"sql":"","sqlType":{"id":4,"name":12,"age":4,"sex":4,"created_at":93,"updated_at":93},"table":"tests","ts":1597424249772,"type":"UPDATE"}
      

    参考 https://blog.csdn.net/hyx1990/article/details/52524115

  • 相关阅读:
    .Net常用的命名空间
    Jquery测试纠错笔记
    第一章 学习总结
    Java和C++引用的区别
    gin的墙内开发艺术
    golang几个环境变量的问题
    Leetcode240_搜索二维矩阵II
    Leetcode1358_包含所有三种字符的子字符串数目
    Leetcode1354_多次求和构造目标数组
    Leetcode1353_最多可以参加的会议数目
  • 原文地址:https://www.cnblogs.com/brady-wang/p/13507270.html
Copyright © 2011-2022 走看看