当dba操作ddl时,例如新增一个字段,如果在命令前有注释的话,canal最终解析不到这个事件。 但是如果没有前面这行注释,就能解析到这条binlog, /** * optional bool isDdl = 10 [default = false];
* *
** 标识是否是ddl语句 * **/ public boolean getIsDdl() { return isDdl_; }
也就是说,如果执行ddl时指定了注释:
`# at 708574121 #180403 0:33:33 server id 248037 end_log_pos 708574490 CRC32 0x0e8bdfed Query thread_id=15086636 exec_time=1647 error_code=0 SET TIMESTAMP=1522686813/!/; -- 注释注释 ALTER TABLE on_ord_act_paid03 ADD receivables_mch_id VARCHAR(50) DEFAULT NULL COMMENT 'Foo', MODIFY COLUMN payment_method SMALLINT NOT NULL COMMENT 'Bar' /!/;
#180403 1:01:00 server id 248037 end_log_pos 708574578 CRC32 0x51d11ba5 Query thread_id=15086688 exec_time=0 error_code=0 SET TIMESTAMP=1522688460/!/;` 那么这条binlog的rowChange.getIsDdl()应该目前是返回的false。 如果去掉“-- 注释注释 ”,则返回true。
当前数据库相关信息: Server version: 5.6.21-log Source distribution innodb_version 5.6.21 当前实例的binlog配置信息:
| binlog_cache_size | 2097152 | | binlog_checksum | CRC32 | | binlog_direct_non_transactional_updates | OFF | | binlog_format | ROW | | binlog_max_flush_queue_time | 0 | | binlog_order_commits | ON | | binlog_row_image | FULL | | binlog_rows_query_log_events | OFF | | binlog_stmt_cache_size | 2097152 | | binlogging_impossible_mode | IGNORE_ERROR | | innodb_api_enable_binlog | OFF | | innodb_locks_unsafe_for_binlog | OFF | | log_bin | ON | | log_bin_basename | /data/mysql_3306/mysql-bin | | log_bin_index | /data/mysql_3306/mysql-bin.index | | log_bin_trust_function_creators | OFF | | log_bin_use_v1_row_events | OFF | | max_binlog_cache_size | 18446744073709547520 | | max_binlog_size | 1073741824 | | max_binlog_stmt_cache_size | 18446744073709547520 | | simplified_binlog_gtid_recovery | OFF | | sql_log_bin | ON | | sync_binlog | 100 |
mysql.conf
[mysqld] basedir=/usr/local/mysql datadir=/data/mysql_3306 socket=/data/mysql_3306/mysql.sock
port=3306 server_id=248037
log-bin=mysql-bin binlog_format = ROW relay-log=mysqld-relay-bin sync_binlog = 100 relay_log_purge=0
log_slave_updates
query_cache_type = 0 query_cache_size = 0
table_definition_cache = 2048 table_open_cache = 4096 table_open_cache_instances = 8
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
skip-name-resolve back_log = 100 max_connections = 1000 max_connect_errors = 100000 max_allowed_packet = 16M binlog_cache_size = 2M binlog_stmt_cache_size = 2M max_heap_table_size = 256M tmp_table_size = 8M sort_buffer_size = 8M thread_cache_size = 256 ft_min_word_len = 4 thread_stack = 192K long_query_time = 3 tmpdir = /tmp
key_buffer_size = 8M read_buffer_size = 8M join_buffer_size = 8M read_rnd_buffer_size = 8M bulk_insert_buffer_size = 8M
character_set_server = utf8 collation_server = utf8_general_ci transaction_isolation = REPEATABLE-READ
default_storage_engine = InnoDB default_tmp_storage_engine = InnoDB
innodb_buffer_pool_size = 30G innodb_file_per_table = 1 innodb_file_io_threads = 4 innodb_thread_concurrency = 32 innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 256M innodb_log_file_size = 512M innodb_log_files_in_group = 3 innodb_flush_method = O_DIRECT innodb_lock_wait_timeout = 120 innodb_open_files = 32768 innodb_online_alter_log_max_size = 32G
slow_query_log = on long_query_time = 0.5 slow_query_log_file = mysql-slow
[mysql] default-character-set=utf8 sock = /data/mysql_3306/mysql.sock
[mysqld_safe] log-error=/data/mysql_3306/mysqld.err pid-file=/data/mysql_3306/mysqld.pid
原提问者GitHub用户yangyongzhi7
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。