Debezium 无法授权 Mongodb 分片

问题描述 投票:0回答:1

我创建了一个包含 2 个分片的 MongoDb 分片集群,其中一个分片位于另一台来宾计算机中。集群已启用授权。为了解决这个问题,我创建了一个具有 root 角色的超级用户。我尝试的是通过此配置创建连接器并创建我的主题;

            {
            "name": "pms-20",
            "config": {
                "connector.class": "io.debezium.connector.mongodb.MongoDbConnector",
                "mongodb.connection.string":"mongodb://user2:[email protected]:27030/?authMechanism=SCRAM-SHA-256&authSource=admin&directConnection=true",
                "topic.prefix": "eys",
                "mongodb.poll.interval.ms": "5000",
                "database.history.kafka.bootstrap.servers": "192.168.2.4:29092",
                "heartbeat.interval.ms": "5000",
                "collection.include.list": "wins.business,wins.tasks",
                "capture.mode": "change_streams_with_pre_image"
            }
        }

我的 mongos 在 27030 上暴露。但是当我将此请求发送到 debezium 时,我收到这些错误

Caused by: com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): 'command aggregate requires authentication' on server 192.168.2.5:27023. The full response is {"ok": 0.0, "errmsg": "command aggregate requires authentication", "code": 13, "codeName": "Unauthorized", "lastCommittedOpTime": {"$timestamp": {"t": 1709881534, "i": 1}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1709881541, "i": 2}}, "signature": {"hash": {"$binary": {"base64": "7fJJ7z0jglTmQUik3fL7bAndAxk=", "subType": "00"}}, "keyId": 7343563481024561176}}, "operationTime": {"$timestamp": {"t": 1709881534, "i": 1}}}

Caused by: com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): 'command aggregate requires authentication' on server 192.168.2.4:27020. The full response is {"ok": 0.0, "errmsg": "command aggregate requires authentication", "code": 13, "codeName": "Unauthorized", "lastCommittedOpTime": {"$timestamp": {"t": 1709881535, "i": 1}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1709881541, "i": 2}}, "signature": {"hash": {"$binary": {"base64": "7fJJ7z0jglTmQUik3fL7bAndAxk=", "subType": "00"}}, "keyId": 7343563481024561176}}, "operationTime": {"$timestamp": {"t": 1709881535, "i": 1}}}

我尝试了各种角色和特权,但可惜没有成功。 Debezium版本:2.4 蒙戈数据库版本:6.0 他们都是码头化的。 非常感谢任何帮助。

mongodb debezium cdc
1个回答
0
投票

原来我需要指定分片的连接模式。我以为它会发现这个星团,但我错了。分片的端口让我开始思考,我问自己为什么它要尝试连接到分片,有一个 mongo 服务器正在运行。然后我再次查看文档看到了

replica_set: The connector establishes individual connections to the replica set for each shard.
sharded: The connector establishes a single connection to the database, based on the value of the mongodb.connection.string.

其默认设置为replica_set,并尝试连接到每个分片。当我添加这一行时它工作得很好

"mongodb.connection.mode":"sharded",

它现在可以工作,但我需要找出哪个角色和特权适合我的需要。

© www.soinside.com 2019 - 2024. All rights reserved.