debezium没有为mysql的嵌入式版本提供cdc

zwghvu4y  于 2021-06-17  发布在  Mysql
关注(0)|答案(1)|浏览(352)

我正在使用以下依赖项,

<dependency>
        <groupId>io.debezium</groupId>
        <artifactId>debezium-connector-oracle</artifactId>
        <version>${version.debezium}</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.debezium/debezium-connector-mysql -->
    <dependency>
        <groupId>io.debezium</groupId>
        <artifactId>debezium-connector-mysql</artifactId>
        <version>${version.debezium}</version>
    </dependency>

<version.debezium>0.8.3.Final</version.debezium>

下面是我的java方法,

public void runMysqlParsser() {

    Configuration config = Configuration.create()
            /* begin engine properties */
            .with("connector.class",
                    "io.debezium.connector.mysql.MySqlConnector")
            .with("offset.storage",
                    "org.apache.kafka.connect.storage.FileOffsetBackingStore")
            .with("offset.storage.file.filename",
                    "/home/mohit/tmp/offset.dat")
            .with("offset.flush.interval.ms", 60000)
            /* begin connector properties */
            .with("name", "my-sql-connector")
            .with("database.hostname", "localhost")
            .with("database.port", 3306)
            .with("database.user", "root")
            .with("database.password", "root")
            .with("server.id", 1)
            .with("database.server.name", "my-app-connector")
            .with("database.history",
                    "io.debezium.relational.history.FileDatabaseHistory")
            .with("database.history.file.filename",
                    "/home/mohit/tmp/dbhistory.dat")
            .with("database.whitelist", "mysql")
            .with("table.whitelist", "mysql.customers")
            .build();
    EmbeddedEngine engine = EmbeddedEngine.create()
            .using(config)
            .notifying(this::handleEvent)
            .build();
    Executor executor = Executors.newSingleThreadExecutor();
    executor.execute(engine);
}

    private void handleEvent(SourceRecord sourceRecord) {
    try {
        LOG.info("Got record :" + sourceRecord.toString());
    } catch (Exception ex) {
        LOG.info("exception in handle event:" + ex);
    }

我的sql配置。

general_log_file = /var/log/mysql/mysql.log
general_log = 1
server-id               = 1
log_bin                 = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
max_binlog_size   = 100M
binlog_format     = row
binlog_row_image  = full
binlog_rows_query_log_events = on
gtid_mode        =  on
enforce_gtid_consistency   = on

当我运行这段代码时,我得到了历史日志的偏移量,mysql.log文件也得到了添加到其中的偏移量。但是,当我对表执行任何update语句时,它不会给我任何日志,即handleevent方法没有被调用。有人能告诉我代码或配置有什么问题吗?
下面是运行java代码后的日志,

$$ java -jar debezium-gcp-1.0-SNAPSHOT-jar-with-dependencies.jar

log4j:warn找不到logger的appender(org.apache.kafka.connect.json.jsonverterconfig)。log4j:warn请正确初始化log4j系统。
log4j:请参阅http://logging.apache.org/log4j/1.2/faq.html#noconfig 更多信息。2018年11月28日下午1:29:47 com.debezium.gcp.samplemysqlembeddedbezium handleevent info:got record:sourcerecord{sourcepartition={server=my app connector},sourceoffset={file=mysql-bin.000002,pos=980,gtids=31b708c7-ee22-11e8-b8a3-080027fbf50e:1-17,snapshot=true}}connectrecord{topic my-app-connector',kafkapartition=0,key=struct{databasename=},value=struct{source=struct{version=0.8.3.final,name=my app connector,server\u id=0,ts\u sec=0,file=mysql bin.000002,pos=980,row=0,snapshot=true},databasename=,ddl=set character\u set\u server=latin1,collation\u server=latin1\u swedish\u ci;},timestamp=null,headers=connectheaders(headers=)}2018年11月28日下午1:29:47 com.github.shyiko.mysql.binlog.binarylogclient连接信息:已连接到localhost:3306 at 31b708c7-ee22-11e8-b8a3-080027fbf50e:1-17(sid:6326, cid:21)

pgx2nnw8

pgx2nnw81#

您是否在白名单中列出正确的数据库/表?
你能看看这个演示吗-https://github.com/debezium/debezium-examples/tree/master/kinesis 只需删除与动觉相关的代码,只打印到控制台。同时检查 table.ignore.builtin 配置选项。伊姆霍 mysql 数据库属于内置数据库,默认情况下会被过滤掉。

相关问题