canal部署
1.下载canal安装包:
地址:https://github.com/alibaba/canal/releases
2.解压
解压安装包
[root@elasticsearch-010007081120 canal]# mkdir -p /home/middle/canal/
[root@elasticsearch-010007081120 canal]#mv canal.deployer-1.1.5.tar.gz /home/middle/canal/
[root@elasticsearch-010007081120 canal]#cd /home/middle/canal/
[root@elasticsearch-010007081120 canal]#tar -zxvf canal.deployer-1.1.5.tar.gz
3.数据库创建用于canal的账号
grant replication slave, replication client on *.* to 'canal'@'%' identified by 'canal123';
3.修改配置文件
vi /home/middle/canal/conf/example/instance.properties
只需要修改红色部分
[root@elasticsearch-010007081120 example]# more instance.properties
#################################################
## mysql serverId , v1.0.26+ will autoGen
canal.instance.mysql.slaveId=1234
# enable gtid use true/false
canal.instance.gtidon=false
# position info
canal.instance.master.address=10.7.81.122:13306 ##连接主库的数据库信息
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的账号
canal.instance.dbPassword=testtes ##主库用于canal的账号的密码
canal.instance.connectionCharset = UTF-8
# enable druid Decrypt database password
canal.instance.enableDruid=false
#canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiNdH1FWgG
CpUfircSwlWKUCAwEAAQ==
# table regex
canal.instance.filter.regex=.*\\..*
# table black regex
canal.instance.filter.black.regex=mysql\\.slave_.*
# 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.mq.dynamicTopicPartitionNum=test.*:4,mycanal:6
#################################################
[root@elasticsearch-010007081120 example]#
4.启动
/home/middle/canal/bin/startup.sh
查看启动日志
/home/middle/canal/logs/example/example.log
5.查看canal端口
[root@localhost conf]# ss -nlp|grep 11111
tcp LISTEN 0 50 *:11111 *:* users:(("java",pid=109382,fd=89))