Canal使用入门服务端
1.配置MySQL的配置文件(my.ini),增加如下配置:
[mysqld]log-bin=mysql-bin #开启日志监控
binlog-format=ROW #监控模式为ROW
server_id=1 #配置mysql replaction需要定义,不能和canal的slaveId重复
2.连接到数据库,执行如下语句:
[mysqld]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的相关权限。3.配置Canal的配置文件(conf/example/instance.properties),增加如下配置:
#数据库配置canal.instance.master.address = 127.0.0.1:3306
canal.instance.master.journal.name =
canal.instance.master.position =
canal.instance.master.timestamp =
#主数据库
canal.instance.dbUsername = canal #帐号
canal.instance.dbPassword = canal #密码
canal.instance.defaultDatabaseName = #监听的数据库名称
canal.instance.connectionCharset = UTF-8 #字符集
#备份数据库(可以不配置)
#canal.instance.standby.address =
#canal.instance.standby.journal.name =
#canal.instance.standby.position =
#canal.instance.standby.timestamp =
4.执行启动文件(bin/startup.bat 或者 bin/startup.sh)。
5.检查日志:
logs/canal/canal.log
com.alibaba.otter.canal.deployer.CanalLauncher - ## start the canal server.com.alibaba.otter.canal.deployer.CanalController - ## start the canal server[127.0.0.1:11111]
com.alibaba.otter.canal.deployer.CanalLauncher - ## the canal server is running now ......
logs/example/example.log
c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path resource [canal.properties]c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path resource [example/instance.properties]
c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start CannalInstance for 1-example
c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start successful....
以上是 Canal使用入门服务端 的全部内容, 来源链接: utcz.com/z/512993.html