我正在尝试将 MongoDB 作为源连接到 Kafka 连接服务器,但是当我运行 CURL POST 命令来注册 Mongo 源连接器时。我成功验证了 kafka-connect 连接器插件中连接器的存在,所以我不明白为什么会出现这些错误
ERROR Plugin class loader for connector: 'com.mongodb.kafka.connect.MongoSourceConnector' was not found. Returning: org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader@7915bca3 (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
和
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=172.20.0.3:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}, {address=172.0.0.2:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}]
这是我的 docker-compose 配置
version: '3.5'
services:
zookeeper:
image: confluentinc/cp-zookeeper:5.0.0
hostname: zookeeper
container_name: zookeeper
ports:
- 2181:2181
networks:
- es-network
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
kafka:
image: confluentinc/cp-kafka:5.0.0
hostname: kafka
container_name: kafka
depends_on:
- zookeeper
ports:
- 29092:29092
- 9092:9092
networks:
- es-network
environment:
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_BROKER_ID: 1
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
schema-registry:
image: confluentinc/cp-schema-registry:5.0.0
hostname: schema-registry
container_name: schema-registry
networks:
- es-network
ports:
- 8081:8081
environment:
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: zookeeper:2181
SCHEMA_REGISTRY_HOST_NAME: schema-registry
depends_on:
- zookeeper
- kafka
kafka-connect:
image: confluentinc/cp-kafka-connect
hostname: kafka-connect
container_name: kafka-connect
networks:
- es-network
ports:
- 8083:8083
environment:
CONNECT_BOOTSTRAP_SERVERS: kafka:9092
CONNECT_REST_ADVERTISED_HOST_NAME: connect
CONNECT_REST_PORT: 8083
CONNECT_GROUP_ID: compose-connect-group
CONNECT_CONFIG_STORAGE_TOPIC: docker-connect-configs
CONNECT_OFFSET_STORAGE_TOPIC: docker-connect-offsets
CONNECT_STATUS_STORAGE_TOPIC: docker-connect-status
CONNECT_KEY_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_VALUE_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_INTERNAL_KEY_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_INTERNAL_VALUE_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: 1
CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: 1
CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: 1
CONNECT_PLUGIN_PATH: '/usr/share/java,/etc/kafka-connect/jars'
CONNECT_CONFLUENT_TOPIC_REPLICATION_FACTOR: 1
volumes:
- /home/xroot/Desktop/docker_env/confluent_env/confluent_on_docker/jars:/etc/kafka-connect/jars
depends_on:
- zookeeper
- kafka
- schema-registry
# MongoDB Replica Set
mongo1:
hostname: mongo1
image: mongo
container_name: mongo1
networks:
- es-network
ports:
- 27018:27017
restart: always
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
mongo2:
hostname: mongo2
image: mongo
container_name: mongo2
networks:
- es-network
ports:
- 27017:27017
restart: always
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
networks:
es-network:
attachable: true