springboot+canal+rabbitmq整合

一、前提是mysql,rabbitmq已经安装完成
1、打开mysql的binlog,修改my.cnf

[mysqld]
log-bin=mysql-bin #开启binlog
binlog-format=ROW #选择ROW模式
server_id=1

2、上传canal.admin-1.1.5.tar.gz
2.1、修改application.yml文件

server:
  port: 8089
spring:
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8

spring.datasource:
  address: 127.0.0.1:3306#修数据库连接
  database: canal_manager#创建数据库
  username: root
  password: Zzy!!2019
  driver-class-name: com.mysql.jdbc.Driver
  url: jdbc:mysql://${spring.datasource.address}/${spring.datasource.database}?useUnicode=true&characterEncoding=UTF-8&useSSL=false
  hikari:
    maximum-pool-size: 30
    minimum-idle: 1

canal:
  adminUser: admin
  adminPasswd: 123456#修改密码

2.2、执行canal_manager.sql文件
2.3、./bin/start.sh 启动即可
2.4、访问地址http://192.168.75.150:8089/

image.png

3、上传canal.deployer-1.1.5.tar.gz
下载地址https://github.com/alibaba/canal/releases
修改conf/cabal.properties文件

# canal admin config
canal.admin.manager = 192.168.75.150:8089#启动的canal-admin的ip
canal.admin.port = 11110
canal.admin.user = admin
canal.admin.passwd = 6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
# admin auto register
canal.admin.register.auto = true
#canal.admin.register.cluster =
#canal.admin.register.name =

4、进入admin管理界面进行配置
4.1、主配置

##################################################
#########           RabbitMQ         #############
##################################################
rabbitmq.host =192.168.75.150:5672#修改成自己的MQ地址
rabbitmq.virtual.host =/
rabbitmq.exchange =canal.mall.exchange
rabbitmq.username =guest
rabbitmq.password =guest
rabbitmq.deliveryMode =

4.2、修改instance.properties

#################################################
## mysql serverId , v1.0.26+ will autoGen
# canal.instance.mysql.slaveId=0

# enable gtid use true/false
canal.instance.gtidon=false

# position info
#修改成需要监听binlog的数据库url
canal.instance.master.address=192.168.75.150: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=root
canal.instance.connectionCharset = UTF-8
# enable druid Decrypt database password
canal.instance.enableDruid=false
#canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiNdH1FWgGCpUfircSwlWKUCAwEAAQ==

# table regex过滤需要监听的表例如:database.tablname
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
#修改成rabbitmq的routingKey
canal.mq.topic=canal.mall.routing
# 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,.*\\..*
#################################################

你可能感兴趣的:(springboot+canal+rabbitmq整合)