cq连接mongodb的问题及处理反馈

这几天线上遇见的mongodb连接的问题,
mongodb账号如下:

db.createUser({user:“query_user”,pwd:“query”,roles:[{role:“readAnyDatabase”,db:“admin”}]})

现象是测试连接可以 显示连接可用,

但是双击连接、新建查询和终端查询的时候都不可以,页面报错如下:

mongodb报错:
Unauthorized: not authorized on admin to execute command { listDatabases: 1, nameOnly: true 。

然后查看了cq的日志 里面显示如下:
INFO 1 — [168.2.183:27170] org.mongodb.driver.cluster: Monitor thread successfully connected to server with description ServerDescription{address=192.168.2.183:27170, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 4, 7]}, minWireVersion=0, maxWireVersion=5, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=439119, setName=‘xxx’, canonicalAddress=192.168.2.183:27170, hosts=[192.168.2.182:27170, 192.168.2.183:27170], passives=[], arbiters=[192.168.2.181:27170], primary=‘192.168.2.182:27170’, tagSet=TagSet{[]}, electionId=null, setVersion=1, lastWriteDate=Mon Jul 12 16:15:10 CST 2021, lastUpdateTimeNanos=879375583906265}

ERROR 1 — [nio-9001-exec-4] c.b.c.d.s.impl.ConnectionServerImpl : 打开{%s}数据源连接异常com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): ‘not authorized on admin to execute command { listDatabases: 1, nameOnly: true }’ on server 192.168.2.183:27170. The full response is {“ok”: 0.0, “errmsg”: “not authorized on admin to execute command { listDatabases: 1, nameOnly: true }”, “code”: 13, “codeName”: “Unauthorized”}

接下来一直反复测试这个问题也没好用。

cq群里反馈问题后,官方很快就配合一起测试,感谢一下 官方小哥哥:WEI
辛苦搭建mongodb多个版本的环境和副本集群,配合我测试了两天,排除了mongo驱动版本问题、mongodb版本问题,后面在指导下删除连接,根据指导新建了连接,已经正常可用了。
查看cq的日志,显示如下:
INFO 1 — [168.2.183:27170] org.mongodb.driver.cluster: Monitor thread successfully connected to server with description ServerDescription{address=192.168.2.183:271
70, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 4, 7]}, minWireVersion=0, maxWireVersion=5, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=232923, setName=
‘xxx’, canonicalAddress=192.168.2.183:27170, hosts=[192.168.2.182:27170, 192.168.2.183:27170], passives=[], arbiters=[192.168.2.181:27170], primary=‘192.168.2.182:27170’, tagSet=TagSet{[]}, electionId=null, setVersion=1, lastWriteDat
e=Wed Jul 14 16:24:29 CST 2021, lastUpdateTimeNanos=1052733988205536}
INFO 1 — [ool-4-thread-52] org.mongodb.driver.connection: Opened connection [connectionId{localValue:94, serverValue:744206}] to 192.168.2.183:27170

再次感谢小哥哥:WEI
感受到了官方对每个用户的重视和用心 :revolving_hearts:

3赞

把用户放在第一位是 CloudQuery社区的初心和宗旨! :heart: