如何使Apache pig连接到需要身份验证的mongodb

时间:2016-02-26 01:58:12

标签: mongodb apache-pig etl

这是关于如何让猪读取或插入mongodb的文件:https://github.com/mongodb/mongo-hadoop/wiki/Pig-Usage

但是本指南没有说明如何连接到需要身份验证的mongodb。有人可以帮我吗 ? ;)

1 个答案:

答案 0 :(得分:0)

我找到了方法。这是mongodb网站的指南:https://docs.mongodb.org/manual/reference/connection-string/

如果收到错误:

org.apache.pig.backend.executionengine.ExecException: ERROR 2118: Unable to calculate input splits: unauthorized

然后阅读这些指南:

https://groups.google.com/forum/#!topic/mongodb-user/iWRGA_HKQDM
https://groups.google.com/forum/#!msg/mongodb-user/wKTPri2rnSk/BCdaOgCAWNUJ

这是我的工作脚本:

mongo_data = LOAD 'mongodb://username:password@xxx.xxx.xxx.xxx:27017/test.test_1?authSource=admin' USING com.mongodb.hadoop.pig.MongoLoader(...);