canal部署及相关配置详解

1.拷贝文件到指定目录下

mkdir /home/test/canal 

2.解压缩

tar zxvf canal.deployer-1.0.0.tar.gz

3.对文件canal文件夹进行授权

chmod –R 777 canal

 

4.修改配置canal.properties

     a.进入到/home/test/canal/conf找到canal.properties

#################################################
#########               common argument           #############
#################################################
canal.id= 1
canal.ip=127.0.0.1            #修改为部署的canal服务器地址
canal.port=22222                                #为canal端口,默认为11111
canal.metrics.pull.port=11112
canal.zkServers=

# flush data to zk
canal.zookeeper.flush.period = 1000
canal.withoutNetty = false

# flush meta cursor/parse position to file
canal.file.data.dir = ${canal.conf.dir}
canal.file.flush.period = 1000

## memory store RingBuffer size, should be Math.pow(2,n)
canal.instance.memory.buffer.size = 16384
## memory store RingBuffer used memory unit size , default 1kb
canal.instance.memory.buffer.memunit = 1024
## meory store gets mode used MEMSIZE or ITEMSIZE
canal.instance.memory.batch.mode = MEMSIZE

## detecing config
canal.instance.detecting.enable = true           #是否开启心跳检查 默认为false
#canal.instance.detecting.sql = insert into retl.xdual values(1,now()) on duplicate key update x=now()
canal.instance.detecting.sql = select 1
canal.instance.detecting.interval.time = 3
canal.instance.detecting.retry.threshold = 3
canal.instance.detecting.heartbeatHaEnable = true     #心跳检查失败后,是否开启自动mysql自动切换说明:比如心跳检查失败超过阀值后,如果该配置为true,canal就会自动链到mysql备库获取binlog数据

# support maximum transaction size, more than the size of the transaction will be cut into multiple transactions delivery
canal.instance.transaction.size =  1024
# mysql fallback connected to new master should fallback times
canal.instance.fallbackIntervalInSeconds = 60

# network config
canal.instance.network.receiveBufferSize = 16384
canal.instance.network.sendBufferSize = 16384
canal.instance.network.soTimeout = 30

# binlog filter config
canal.instance.filter.druid.ddl = true
canal.instance.filter.query.dcl = false
canal.instance.filter.query.dml = false
canal.instance.filter.query.ddl = false
canal.instance.filter.table.error = false
canal.instance.filter.rows = false
canal.instance.filter.transaction.entry = false

# binlog format/image check
canal.instance.binlog.format = ROW,STATEMENT,MIXED
canal.instance.binlog.image = FULL,MINIMAL,NOBLOB

# binlog ddl isolation
canal.instance.get.ddl.isolation = false

# parallel parser config
canal.instance.parser.parallel = true
## concurrent thread number, default 60% available processors, suggest not to exceed Runtime.getRuntime().availableProcessors()
#canal.instance.parser.parallelThreadSize = 16
## disruptor ringbuffer size, must be power of 2
canal.instance.parser.parallelBufferSize = 256

# table meta tsdb info
canal.instance.tsdb.enable=false            # v1.0.25版本新增,是否开启table meta的时间序列版本记录功能默认为true改为false
canal.instance.tsdb.dir=${canal.file.data.dir:../conf}/${canal.instance.destination:}
canal.instance.tsdb.url=jdbc:h2:${canal.instance.tsdb.dir}/h2;CACHE_SIZE=1000;MODE=MYSQL;
canal.instance.tsdb.dbUsername=canal
canal.instance.tsdb.dbPassword=canal

# rds oss binlog account
canal.instance.rds.accesskey =
canal.instance.rds.secretkey =

#################################################
#########               destinations              #############
#################################################
canal.destinations= example           #当前server上部署的instance列表 默认为example
# conf root dir
canal.conf.dir = ../conf
# auto scan instance dir add/remove and start/stop instance
canal.auto.scan = true
canal.auto.scan.interval = 5

canal.instance.tsdb.spring.xml=classpath:spring/tsdb/h2-tsdb.xml
#canal.instance.tsdb.spring.xml=classpath:spring/tsdb/mysql-tsdb.xml

canal.instance.global.mode = spring
canal.instance.global.lazy = false
#canal.instance.global.manager.address = 127.0.0.1:1099
#canal.instance.global.spring.xml = classpath:spring/memory-instance.xml
canal.instance.global.spring.xml = classpath:spring/file-instance.xml
#canal.instance.global.spring.xml = classpath:spring/default-instance.xml

    

5.修改instance.properties 

      a.配置MySQL的配置文件(my.ini),增加如下配置:

[mysqld]
log-bin=mysql-bin #开启日志监控
binlog-format=ROW #监控模式为ROW
server_id=1 #配置mysql replaction需要定义,不能和canal的slaveId重复

 

      b. 连接到数据库,执行如下语句:        

CREATE USER canal IDENTIFIED BY 'canal'; 
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
-- GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%' ;
FLUSH PRIVILEGES;

         备注:Canal的原理是模拟自己为MySQL Slave,所以这里一定需要做为MySQL Slave的相关权限

     c.进入到/home/iflytekde/canal/conf/example找到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
canal.instance.master.address=127.0.0.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=false                               #默认为true,改为false
#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=canal                    #用授权后的canal密码
canal.instance.defaultDatabaseName = test1                 #数据库库名
canal.instance.connectionCharset=UTF-8                                  #数据库字符集

# table regex
canal.instance.filter.regex=test1\\..*                                 #正则匹配默认.*\\..*,其中前面.*代表库名,后面.*代表表名
# table black regex
canal.instance.filter.black.regex=
#################################################

 

6.执行启动或停止

启动/home/test/canal/bin/startup.bat 或者 bin/startup.sh

停止/home/test/canal/bin/stop.bat 或者 bin/ stop.sh

 

注意:停止后需要删除以下文件/home/test/canal/conf/example/meta.dat文件和/home/test/canal/logs下面的文件

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值