Kafka Connect:Debezium Connector远程调试

1. 分析启动脚本

1.1 启动命令
# background running mode
cd /home/lenmom/workspace/software/confluent-community-5.1.0-2.11/ &&./bin/connect-distributed -daemon ./etc/schema-registry/connect-avro-distributed.properties

# or console running mode
cd /home/lenmom/workspace/software/confluent-community-5.1.0-2.11/ &&./bin/connect-distributed ./etc/schema-registry/connect-avro-distributed.properties

可以看到,启动命令是connect-distributed,看下它的内容

#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
...
export CLASSPATH
exec $(dirname $0)/kafka-run-class $EXTRA_ARGS org.apache.kafka.connect.cli.ConnectDistributed "$@"

可以看到connect-distributed.sh启动脚本中其实又运行了kafka-run-class.sh,我们来看看这个脚本

1.2 kafka-run-class
...
# Set Debug options if enabled
if [ "x$KAFKA_DEBUG" != "x" ]; then

    # Use default ports
    DEFAULT_JAVA_DEBUG_PORT="5005"

    if [ -z "$JAVA_DEBUG_PORT" ]; then
        JAVA_DEBUG_PORT="$DEFAULT_JAVA_DEBUG_PORT"
    fi

    # Use the defaults if JAVA_DEBUG_OPTS was not set
    DEFAULT_JAVA_DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=${DEBUG_SUSPEND_FLAG:-n},address=$JAVA_DEBUG_PORT"
    if [ -z "$JAVA_DEBUG_OPTS" ]; then
        JAVA_DEBUG_OPTS="$DEFAULT_JAVA_DEBUG_OPTS"
    fi

    echo "Enabling Java debug options: $JAVA_DEBUG_OPTS"
    KAFKA_OPTS="$JAVA_DEBUG_OPTS $KAFKA_OPTS"
fi
...

因此,我们只要配置环境变量KAFKA_DEBUG,就可以将DEBUG模式打开了,我们在脚本开头加上环境变量KAFKA_DEBUG的配置

export KAFKA_DEBUG=2

...
# Set Debug options if enabled
if [ "x$KAFKA_DEBUG" != "x" ]; then

    # Use default ports
    DEFAULT_JAVA_DEBUG_PORT="5005"

    if [ -z "$JAVA_DEBUG_PORT" ]; then
        JAVA_DEBUG_PORT="$DEFAULT_JAVA_DEBUG_PORT"
    fi

    # Use the defaults if JAVA_DEBUG_OPTS was not set
    DEFAULT_JAVA_DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=${DEBUG_SUSPEND_FLAG:-n},address=$JAVA_DEBUG_PORT"
    if [ -z "$JAVA_DEBUG_OPTS" ]; then
        JAVA_DEBUG_OPTS="$DEFAULT_JAVA_DEBUG_OPTS"
    fi

    echo "Enabling Java debug options: $JAVA_DEBUG_OPTS"
    KAFKA_OPTS="$JAVA_DEBUG_OPTS $KAFKA_OPTS"
fi
...

启动kafka-connect,会看到开启5005端口的相关提示,则表明已开启远程调试。

2. idea配置

话不多说,上图
在这里插入图片描述

参考:
https://www.cnblogs.com/lenmom/p/10943661.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
首先,Kafka是一个分布式流处理平台,用于在高吞吐量的情况下处理大量的实时数据流。Hive是一个基于Hadoop的数据仓库工具,用于存储和查询大规模结构化和半结构化数据。 要将Kafka写入Hive,需要使用Debezium它是一个开源的、基于事件的可信变更数据捕获(CDC)平台。Debezium可以将数据库的变更事件转换为Kafka主题中的实时流,并且可以实时监控数据库中的变动。 要实现Kafka写入Hive,首先需要配置Debezium将数据库的变更事件连接到Kafka中。Debezium会以JSON格式将变更事件转换为Kafka消息,并将其写入指定的主题中。 然后,可以使用Kafka Connect来读取Kafka主题中的消息,并将其写入Hive中。Kafka ConnectKafka提供的一组工具,用于将Kafka主题与外部数据系统进行连接。 在Kafka Connect中,可以使用HDFS Connector来将Kafka消息写入Hive。HDFS Connector会将Kafka消息转换为Hive支持的格式,并将其写入Hive表中。 需要配置HDFS Connector的连接器以指定Kafka主题、Hive表和目标位置。连接器会自动将Kafka消息转换为Hive表的列,并将其写入Hive表中的对应位置。 一旦连接器配置完成并启动,Kafka中的变更事件就会实时地写入Hive表中。可以通过查询Hive表来获取Kafka中的数据,并根据需要进行分析和处理。 总而言之,要将Kafka写入Hive,可以使用Debezium将数据库变更事件转换为Kafka消息,并使用Kafka Connect的HDFS ConnectorKafka消息写入Hive表中。这样就能实现将实时数据流从Kafka写入Hive的目的。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值