debezium - 架构注册表问题 [英] debezium - schema registry issue

查看:33
本文介绍了debezium - 架构注册表问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 debezium 使用 AWS 架构注册表.

Im using AWS schema registry for debezium.

在 debezium 中,我提到服务器名称为 mysql-db01.因此,debezium 将使用此服务器名称创建一个主题,以添加一些有关服务器和架构更改的元数据.

In the debezium I mentioned the server name as mysql-db01. So debezium will create a topic with this server name to add some metadata about the server and schema changes.

当我部署连接器时,在架构注册表中我得到了这样的架构.

When I deployed the connector, in the schema registry I got the schema like this.

{
  "type": "record",
  "name": "SchemaChangeKey",
  "namespace": "io.debezium.connector.mysql",
  "fields": [
    {
      "name": "databaseName",
      "type": "string"
    }
  ],
  "connect.name": "io.debezium.connector.mysql.SchemaChangeKey"
}

然后立即像这样创建了另一个版本.

Then immediately another version got created like this.

{
  "type": "record",
  "name": "SchemaChangeValue",
  "namespace": "io.debezium.connector.mysql",
  "fields": [
    {
      "name": "source",
      "type": {
        "type": "record",
        "name": "Source",
        "fields": [
          {
            "name": "version",
            "type": "string"
          },
          {
            "name": "connector",
            "type": "string"
          },
          {
            "name": "name",
            "type": "string"
          },
          {
            "name": "ts_ms",
            "type": "long"
          },
          {
            "name": "snapshot",
            "type": [
              {
                "type": "string",
                "connect.version": 1,
                "connect.parameters": {
                  "allowed": "true,last,false"
                },
                "connect.default": "false",
                "connect.name": "io.debezium.data.Enum"
              },
              "null"
            ],
            "default": "false"
          },
          {
            "name": "db",
            "type": "string"
          },
          {
            "name": "sequence",
            "type": [
              "null",
              "string"
            ],
            "default": null
          },
          {
            "name": "table",
            "type": [
              "null",
              "string"
            ],
            "default": null
          },
          {
            "name": "server_id",
            "type": "long"
          },
          {
            "name": "gtid",
            "type": [
              "null",
              "string"
            ],
            "default": null
          },
          {
            "name": "file",
            "type": "string"
          },
          {
            "name": "pos",
            "type": "long"
          },
          {
            "name": "row",
            "type": "int"
          },
          {
            "name": "thread",
            "type": [
              "null",
              "long"
            ],
            "default": null
          },
          {
            "name": "query",
            "type": [
              "null",
              "string"
            ],
            "default": null
          }
        ],
        "connect.name": "io.debezium.connector.mysql.Source"
      }
    },
    {
      "name": "databaseName",
      "type": [
        "null",
        "string"
      ],
      "default": null
    },
    {
      "name": "schemaName",
      "type": [
        "null",
        "string"
      ],
      "default": null
    },
    {
      "name": "ddl",
      "type": [
        "null",
        "string"
      ],
      "default": null
    },
    {
      "name": "tableChanges",
      "type": {
        "type": "array",
        "items": {
          "type": "record",
          "name": "Change",
          "namespace": "io.debezium.connector.schema",
          "fields": [
            {
              "name": "type",
              "type": "string"
            },
            {
              "name": "id",
              "type": "string"
            },
            {
              "name": "table",
              "type": {
                "type": "record",
                "name": "Table",
                "fields": [
                  {
                    "name": "defaultCharsetName",
                    "type": [
                      "null",
                      "string"
                    ],
                    "default": null
                  },
                  {
                    "name": "primaryKeyColumnNames",
                    "type": [
                      "null",
                      {
                        "type": "array",
                        "items": "string"
                      }
                    ],
                    "default": null
                  },
                  {
                    "name": "columns",
                    "type": {
                      "type": "array",
                      "items": {
                        "type": "record",
                        "name": "Column",
                        "fields": [
                          {
                            "name": "name",
                            "type": "string"
                          },
                          {
                            "name": "jdbcType",
                            "type": "int"
                          },
                          {
                            "name": "nativeType",
                            "type": [
                              "null",
                              "int"
                            ],
                            "default": null
                          },
                          {
                            "name": "typeName",
                            "type": "string"
                          },
                          {
                            "name": "typeExpression",
                            "type": [
                              "null",
                              "string"
                            ],
                            "default": null
                          },
                          {
                            "name": "charsetName",
                            "type": [
                              "null",
                              "string"
                            ],
                            "default": null
                          },
                          {
                            "name": "length",
                            "type": [
                              "null",
                              "int"
                            ],
                            "default": null
                          },
                          {
                            "name": "scale",
                            "type": [
                              "null",
                              "int"
                            ],
                            "default": null
                          },
                          {
                            "name": "position",
                            "type": "int"
                          },
                          {
                            "name": "optional",
                            "type": [
                              "null",
                              "boolean"
                            ],
                            "default": null
                          },
                          {
                            "name": "autoIncremented",
                            "type": [
                              "null",
                              "boolean"
                            ],
                            "default": null
                          },
                          {
                            "name": "generated",
                            "type": [
                              "null",
                              "boolean"
                            ],
                            "default": null
                          }
                        ],
                        "connect.name": "io.debezium.connector.schema.Column"
                      }
                    }
                  }
                ],
                "connect.name": "io.debezium.connector.schema.Table"
              }
            }
          ],
          "connect.name": "io.debezium.connector.schema.Change"
        }
      }
    }
  ],
  "connect.name": "io.debezium.connector.mysql.SchemaChangeValue"

这 2 个架构不匹配,因此 AWS 架构注册表不允许连接器注册第二个版本.但第二个版本是连接器的实际架构.

These 2 schemas are not matching, so the AWS schema registry is not allowing the connector to register the 2nd version. But the 2nd version is the actual schema for the connector.

为了解决这个问题,我删除了架构(在架构注册表中).然后删除了连接器,重新部署了连接器,然后就成功了.

To solve this issue, I deleted the schema(in the schema registry). Then deleted the connector, re-deployed the connector, then It worked.

但我试图理解为什么第一次架构有不同的版本.

But I'm trying to understand why the very first time the schema has different versions.

推荐答案

我在源连接器和接收器连接器上使用了以下键/值转换器来使其工作.

I have used the following key/value convertors on the source and sink connectors to make it work.

        "key.converter": "org.apache.kafka.connect.storage.StringConverter",
        "key.converter.schemas.enable": "false",
        "internal.key.converter": "com.amazonaws.services.schemaregistry.kafkaconnect.AWSKafkaAvroConverter",
        "internal.key.converter.schemas.enable": "false",
        "internal.value.converter": "com.amazonaws.services.schemaregistry.kafkaconnect.AWSKafkaAvroConverter",
        "internal.value.converter.schemas.enable": "false",
        "value.converter": "com.amazonaws.services.schemaregistry.kafkaconnect.AWSKafkaAvroConverter",
        "value.converter.schemas.enable": "true",
        "value.converter.region": "ap-south-1",
        "key.converter.schemaAutoRegistrationEnabled": "true",
        "value.converter.schemaAutoRegistrationEnabled": "true",
        "key.converter.avroRecordType": "GENERIC_RECORD",
        "value.converter.avroRecordType": "GENERIC_RECORD",
        "key.converter.registry.name": "bhuvi-debezium",
        "value.converter.registry.name": "bhuvi-debezium",

这篇关于debezium - 架构注册表问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆