Docker 安装Canal
(1)查看是否打开binlog模式 show variables like 'log_bin' (2)查看binlog日志文件列表 show binary logs (3)查看当前正在写入的binlog文件 show master status
①拉取canal镜像(版本:2019年发布的v1.1.4)
docker pull canal/canal-server:v1.1.4
②启动镜像
docker run --name canal -d canal/canal-server
③将容器内部配置文件拷贝到外部
docker cp [容器索引]:[内部路径] [外部路径]
docker cp canal:/home/admin/canal-server/conf/canal.properties /xs/canal
docker cp canal:/home/admin/canal-server/conf/example/instance.properties /xs/canal
④修改外部配置文件instance.properties
#################################################
## mysql serverId , v1.0.26+ will autoGen
# canal.instance.mysql.slaveId=0
# enable gtid use true/false
canal.instance.gtidon=false
# 数据库地址
canal.instance.master.address=127.0.0.1:3306
# binlog日志名称
canal.instance.master.journal.name=
# mysql主库链接时起始的binlog偏移量
canal.instance.master.position=
# mysql主库链接时起始的binlog的时间戳
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=
# 在MySQL服务器授权的账号密码
canal.instance.dbUsername=
canal.instance.dbPassword=
# 字符集
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=.*\\..*
# mysql 数据解析表的黑名单,多个表用,隔开
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=mytest1.user,mytest2\\..*,.*\\..*
canal.mq.partition=0
# hash partition config
#canal.mq.partitionsNum=3
#canal.mq.partitionHash=test.table:id^name,.*\\..*
#################################################
⑤关闭移除容器
#关闭容器
docker stop canal
#移除容器
docker rm canal
⑥#启动新的 这里-v是将外部的文件挂载到容器内部 这样就不用每次启动都要配置参数了
docker run --name canal -p 11111:11111 -d -v /xs/canal/instance.properties:/home/admin/canal-server/conf/example/instance.properties -v /xs/canal/canal.properties:/home/admin/canal-server/conf/canal.properties canal/canal-server:v1.1.4
参考: https://www.cnblogs.com/winter-shadow/p/14238359.html https://blog.csdn.net/yehongzhi1994/article/details/107880162?spm=1001.2014.3001.5506
|