代码拉取完成,页面将自动刷新
名称:binlogreader
MySQL5.1.5及以上
binlog_format需要修改为 ROW 格式,在/etc/my.cnf文件里[mysqld]下添加下列配置
server_id=109
log_bin = /var/lib/mysql/mysql-bin
binlog_format = ROW
expire_logs_days = 30
mysql binlog权限需要三个权限 SELECT, REPLICATION SLAVE, REPLICATION CLIENT
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%' IDENTIFIED BY 'canal';
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Access denied for user 'canal'@'%' to database 'binlog'
java.io.IOException:
Error When doing Register slave:ErrorPacket [errorNumber=1045, fieldCount=-1, message=Access denied for user 'canal'@'%'
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation
binlog为什么需要这些权限:
_.*_
canal\..*
canal\.canal.*
canal\.test1
{
"type":"update",
"schema":"test",
"table":"tb1",
"ts":6760525407742726144,
"before_id":1,
"after_id":2
}
pavingData为false时:
{
"message":{
"type":"update",
"schema":"test",
"table":"tb1",
"ts":6760525407742726144,
"before":{
"id":1
},
"after":{
"id":2
}
}
}
long id = Long.parseLong("6760525407742726144");
long res = id >> 22;
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(res)); //2021-01-28 19:54:21
{
"job": {
"content": [
{
"reader": {
"parameter": {
"table": ["table"],
"password": "passwd",
"database": "database",
"port": 3306,
"cat": "DELETE,INSERT,UPDATE",
"host": "host",
"jdbcUrl": "jdbc:mysql://host:port/schema",
"pavingData": true,
"username": "name"
},
"name": "binlogreader"
},
"writer": {
"parameter": {
"print": true
},
"name": "streamwriter"
}
}
],
"setting": {
"restore": {
"isStream": true
},
"speed": {
"channel": 1
}
}
}
}
{
"job": {
"content": [
{
"reader": {
"parameter": {
"table": ["table1","table2"],
"password": "passwd",
"database": "database",
"port": 3306,
"cat": "DELETE,INSERT,UPDATE",
"host": "host",
"jdbcUrl": "jdbc:mysql://host:port/schema",
"pavingData": true,
"username": "name"
},
"name": "binlogreader"
},
"writer": {
"parameter": {
"print": true
},
"name": "streamwriter"
}
}
],
"setting": {
"restore": {
"isStream": true
},
"speed": {
"channel": 1
}
}
}
}
{
"job": {
"content": [
{
"reader": {
"parameter": {
"filter": "schema\\..*",
"password": "passwd",
"database": "database",
"port": 3306,
"cat": "DELETE,INSERT,UPDATE",
"host": "host",
"jdbcUrl": "jdbc:mysql://host:port/schema",
"pavingData": true,
"username": "name"
},
"name": "binlogreader"
},
"writer": {
"parameter": {
"print": true
},
"name": "streamwriter"
}
}
],
"setting": {
"restore": {
"isStream": true
},
"speed": {
"channel": 1
}
}
}
}
{
"job": {
"content": [
{
"reader": {
"parameter": {
"filter": "schema\\..*",
"password": "passwd",
"database": "database",
"port": 3306,
"start" : {
"journalName": "binlog.000031",
"position": 4
},
"cat": "DELETE,INSERT,UPDATE",
"host": "host",
"jdbcUrl": "jdbc:mysql://host:port/schema",
"pavingData": true,
"username": "name"
},
"name": "binlogreader"
},
"writer": {
"parameter": {
"print": true
},
"name": "streamwriter"
}
}
],
"setting": {
"restore": {
"isStream": true
},
"speed": {
"channel": 1
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。