mongodb - Mongodb 到 Kafka 连接器
问题描述
你能帮忙配置connect-mongo-source.properties吗?
下面是connect-mongo-source.properties
name=mongodb-source-connector
connector.class=io.debezium.connector.mongodb.MongoDbConnector
mongodb.hosts=mongodb://admin:password@ipaddress:27017/test
mongodb.name=mongo_conn
initial.sync.max.threads=1
tasks.max=1
我收到此错误
[2020-04-22 16:26:58,723] ERROR Error while reading the 'shards' collection in the 'config' database: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN,
servers=
[{address=test?authsource=admin&replicaset=quickfoodcluster-shard-0&readpreference=primary&appname=mongodb%20compass%20community&ssl=true:27017, type=UNKNOWN, state=CONNECTING,
exception={com.mongodb.MongoSocketException: test?authsource=admin&replicaset=quickfoodcluster-shard-0&readpreference=primary&appname=mongodb%20compass%20community&ssl=true},
caused by {java.net.UnknownHostException: test?authsource=admin&replicaset=quickfoodcluster-shard-0&readpreference=primary&appname=mongodb%20compass%20community&ssl=true}},
{address=quickfoodcluster-shard-00-01-zxbxk.azure.mongodb.net:27017,
type=UNKNOWN,
state=CONNECTING,
exception={com.mongodb.MongoSocketException: quickfoodcluster-shard-00-01-zxbxk.azure.mongodb.net},
caused by {java.net.UnknownHostException: quickfoodcluster-shard-00-01-zxbxk.azure.mongodb.net}}] (io.debezium.connector.mongodb.ReplicaSetDiscovery)
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN,
servers=[{address=test?authsource=admin&replicaset=quickfoodcluster-shard-0&readpreference=primary&appname=mongodb%20compass%20community&ssl=true:27017,
type=UNKNOWN,
state=CONNECTING,
exception={com.mongodb.MongoSocketException: test?authsource=admin&replicaset=quickfoodcluster-shard-0&readpreference=primary&appname=mongodb%20compass%20community&ssl=true},
caused by {java.net.UnknownHostException: test?authsource=admin&replicaset=quickfoodcluster-shard-0&readpreference=primary&appname=mongodb%20compass%20community&ssl=true}},
{address=quickfoodcluster-shard-00-01-zxbxk.azure.mongodb.net:27017,
type=UNKNOWN, state=CON
NECTING, exception={com.mongodb.MongoSocketException: quickfoodcluster-shard-00-01-zxbxk.azure.mongodb.net}, caused by {java.net.UnknownHostException: quickfoodcluster-shard-00-01-zxbxk.azure.mongodb.net}}]
解决方案
我认为您不能在 中使用 DSN 字符串mongodb.hosts
,应该在此处host:port
文档中提到的单独字段中提供用户和密码。
name=mongodb-source-connector
connector.class=io.debezium.connector.mongodb.MongoDbConnector
mongodb.hosts=ipaddress:27017
mongodb.user=admin
mongodb.password=password
mongodb.name=mongo_conn
initial.sync.max.threads=1
tasks.max=1
推荐阅读
- javascript - 如何在 react-native 的动态列表视图中更改字体大小?
- routing - 如何在 Angular 7 中正确实现命名路由器插座?
- android - android studio中的gradle没有选择安装的sdk
- python - 从字符串中提取小时_不明确的格式
- sql - 当您通过将结果限制为 500 条记录且表没有主键的 API 访问时,如何从表中提取每一行?
- python - 当用户在函数中没有输入任何内容时,如何防止代码崩溃
- python - 已安装 face_recognition,但无法导入。(Python3.64)
- sql - Access-VBA For 循环只执行一次
- javascript - 如何在 React js 中映射和过滤重复值
- webpack - Webpack 4 摇树和模块副作用