【发布时间】:2020-01-02 02:34:30
【问题描述】:
我正在使用 kubernetes 中的 JDBC sink 连接器构建 Kafka-connect 应用程序。我尝试了独立模式,它正在工作。我想转向分布式模式。 通过运行下面的 yaml 文件,我可以成功构建两个 pod(kafka 连接器):
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
namespace: vtq
name: kafka-sink-postgres-dis
spec:
replicas: 2
template:
metadata:
labels:
app: kafka-sink-postgres-dis
spec:
containers:
- name: kafka-sink-postgres-dis
image: ***
imagePullPolicy: Always
bin/connect-distributed.sh config/worker.properties
bootstrap.servers=***:9092
offset.flush.interval.ms=10000
rest.port=8083
rest.host.name=127.0.0.1
key.converter=org.apache.kafka.connect.storage.StringConverter
value.converter=io.confluent.connect.avro.AvroConverter
value.converter.schema.registry.url=http://schema-registry:8081
# Prevent the connector from pulling all historical messages
auto.offset.reset=latest
# options below may be required for distributed mode
# unique name for the cluster, used in forming the Connect cluster group. Note that this must not conflict with consumer group IDs
group.id=connect-postgres-sink-dis
# Topic to use for storing offsets. This topic should have many partitions and be replicated.
offset.storage.topic=postgres-connect-offsets
offset.storage.replication.factor=3
# Topic to use for storing connector and task configurations; note that this should be a single partition, highly replicated topic.
# You MUST manually create the topic to ensure single partition for the config topic as auto created topics may have multiple partitions.
config.storage.topic=postgres-connect-configs
config.storage.replication.factor=3
# Topic to use for storing statuses. This topic can have multiple partitions and should be replicated.
status.storage.topic=postgres-connect-status
status.storage.replication.factor=3
并在每个 pod 内创建了一个带有 task.max=1 的接收器连接器,这两个连接器监听了同一个主题。原来他们只是重复了。
curl -X POST -H "Content-Type: application/json" --data '{"name": "postgres_sink_dis", "config": {"connector.class":"io.confluent.connect.jdbc.JdbcSinkConnector", "tasks.max":"1", "connection.url":"***","topics":"***"}}' http://127.0.0.1:8083/connectors
但我对 kafka 连接集群、工作程序、连接器和任务的概念感到非常困惑。我从 https://github.com/enfuse/kafka-connect-demo/blob/master/docs/install-connector.md。 他们在配置连接器之前设置端口转发到其余端口。我试过了,在部署服务并创建连接器后, curl -s 172.0.0.1:8083/connectors 没有返回。
谁能给我一个简短的描述我下一步应该做什么,任何相关信息都会非常有帮助。谢谢!
更新: 最后,我弄清楚了问题并解决了问题。 1. 分别部署两个 pods/workers,group.id 相同,rest.port 不同(https://docs.confluent.io/current/connect/userguide.html)。 2. 在 pod 内,创建一个带有任务的连接器。
【问题讨论】:
标签: distributed apache-kafka-connect