能否为单个Kafka Connect配置多个Sink连接器?
Absolutely! Kafka Connect is designed from the ground up to support running multiple independent connectors (both Sink and Source types) on the same cluster or standalone instance. Each connector operates as a separate logical unit, sharing the underlying Connect resources while maintaining its own configuration and task lifecycle.
How to add multiple Sink connectors (using your Cassandra Sink example)
You can use the same kafka-connect-cli tool you're already using to create additional Sink connectors—you just need to ensure each has a unique identifier.
For example, if you already have your cassandra-sink-orders connector set up, you can create a second Cassandra Sink to handle a payments-topic with a new configuration file:
java -jar kafka-connect-cli-0.5-all.jar create cassandra-sink-payments < cassandra-sink-distributed-payments.properties
Key configuration rules to follow:
- Unique
nameproperty: Every connector must have a distinctnamevalue (likecassandra-sink-ordersvscassandra-sink-payments)—this is how Kafka Connect differentiates between connectors. - Isolated topic mappings: Each Sink can target different Kafka topics (via the
topicsproperty) or even overlap topics if your business logic requires it. - Task scaling: Adjust
tasks.maxper connector based on the throughput needs of that specific Sink.
Alternative: Using the Kafka Connect REST API (distributed mode preferred)
In distributed Kafka Connect mode, the REST API is the standard way to manage connectors. To add a second Sink, you can send a POST request with your new connector's JSON configuration:
curl -X POST -H "Content-Type: application/json" --data @cassandra-sink-payments.json http://your-connect-cluster-host:8083/connectors
Things to keep in mind:
- Ensure your Kafka Connect cluster has enough memory and CPU resources to handle the combined load of all connectors and their tasks.
- Verify that each Sink's configuration (like Cassandra connection details, table mappings) doesn't conflict with others (e.g., if targeting the same Cassandra cluster, make sure table schemas align with the incoming topic data).
- You can check the status of all running connectors at any time with:
curl http://your-connect-cluster-host:8083/connectors
内容的提问来源于stack exchange,提问作者el323

