canal配置

数据库 waitig 1432℃ 百度已收录 0评论

安装canal

下载canal:
https://github.com/alibaba/canal/releases/download/canal-1.0.24/canal.deployer-1.0.24.tar.gz

确认mysql启用bin-log

mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin       | OFF   |
+---------------+-------+
1 row in set (0.00 sec)

OFF表示未开启。
在 /etc/my.cnf 中加入下面内容(要加到mysqld配置中)

log-bin = mysql-bin #开启binlog
binlog-format = ROW #选择row模式
server_id = 1 #配置mysql replication需要定义,不能喝canal的slaveId重复

建立用户,分配权限

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

修改配置

mysql> flush logs;
Query OK, 0 rows affected (0.07 sec)

mysql> show master status;
+------------------+----------+--------------+------------------+--------------------------------------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                                |
+------------------+----------+--------------+------------------+--------------------------------------------------+
| mysql-bin.000002 |      154 |              |                  | b045dc0b-2991-11e7-9e59-005056a48244:1-206877394 |
+------------------+----------+--------------+------------------+--------------------------------------------------+
1 row in set (0.00 sec)

配置信息,参照官方example配置。(可以看出一个canal可以配置多个同步)

#################################################
## mysql serverId
canal.instance.mysql.slaveId = 1234

# position info,就是以上查询的Position结果
canal.instance.master.address = 127.0.0.1:3306
canal.instance.master.journal.name = 
canal.instance.master.position = 154
canal.instance.master.timestamp = 

#canal.instance.standby.address = 
#canal.instance.standby.journal.name =
#canal.instance.standby.position = 
#canal.instance.standby.timestamp = 

# username/password
canal.instance.dbUsername = root
canal.instance.dbPassword = password
canal.instance.defaultDatabaseName =
canal.instance.connectionCharset = UTF-8

# table regex
canal.instance.filter.regex = .*\\..*
# table black regex
canal.instance.filter.black.regex =  

#################################################

本文由【waitig】发表在等英博客
本文固定链接:canal配置
欢迎关注本站官方公众号,每日都有干货分享!
等英博客官方公众号
点赞 (0)分享 (0)