`
yi_17328214
  • 浏览: 204104 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

Spark 连接 MongoDB

阅读更多
Spark 连接 Mongodb
官方地址:https://www.mongodb.com/products/spark-connector

使用时候遇到一个问题,就是通过MongodbConnector 连接 Mongodb 时候,如果mongodb 是有密码验证的,一直不能通过验证:
一直报错:not authorized on admin to execute command

引用
[WARN ] 2018-03-07 09:53:42,445 com.mongodb.spark.rdd.partitioner.MongoSamplePartitioner - Could not get collection statistics. Server errmsg: Command failed with error 13: 'not authorized on admin to execute command { collStats: "yw_route", $queryOptions: { $readPreference: { mode: "secondaryPreferred" } } }' on server x.x.x.x:x. The full response is { "ok" : 0.0, "errmsg" : "not authorized on admin to execute command { collStats: \"yw_route\", $queryOptions: { $readPreference: { mode: \"secondaryPreferred\" } } }", "code" : 13 }


查找了很长时间,终于找到了解决方法:
配置mongodb uri 如下:

引用
mongodb://USER:PW@HOST:PORT,HOST1:PORT1/DB.COLLECTION?authSource=admin

验证通过,也可以查询数据了
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics