mongodb - 映射器无法让Pig将数据插入MongoDB

标签 mongodb hadoop apache-pig

我正在尝试使用带有PIG的MongoInsertStorage将文件从HDFS导入到MongoDB。文件很大,大约5GB。当我在本地模式下运行脚本时,脚本运行良好

 pig -x local example.pig

但是,如果我以mapreduce模式运行它,则大多数映射器都会失败,并出现以下错误:
 Error: com.mongodb.ConnectionString.getReadConcern()Lcom/mongodb/ReadConcern; 
 Container killed by the ApplicationMaster. 
 Container killed on request. 
 Exit code is 143 Container exited with a non-zero exit code 143

有人可以帮我解决这个问题吗?我还增加了分配给YARN容器的内存,但这没有帮助。

一些映射器也在300秒后超时。

pig 脚本如下
REGISTER mongo-java-driver-3.2.2.jar  
REGISTER mongo-hadoop-core-1.4.0.jar
REGISTER mongo-hadoop-pig-1.4.0.jar
REGISTER mongodb-driver-3.2.2.jar

DEFINE MongoInsertStorage com.mongodb.hadoop.pig.MongoInsertStorage();

SET mapreduce.reduce.speculative true
BIG_DATA = LOAD 'hdfs://example.com:8020/user/someuser/sample.csv' using PigStorage(',') As (a:chararray,b:chararray,c:chararray); 

STORE BIG_DATA INTO 'mongodb://insert.some.ip.here:27017/test.samplecollection' USING MongoInsertStorage('', '')

最佳答案

找到了解决方案。

对于错误

Error: com.mongodb.ConnectionString.getReadConcern()Lcom/mongodb/ReadConcern; 
 Container killed by the ApplicationMaster. 
 Container killed on request. 
 Exit code is 143 Container exited with a non-zero exit code 143

我将JAR版本-hadoopcore和hadooppig从1.4.0更改为2.0.2,并将Mongo Java驱动程序从3.2.2更改为3.4.2。这消除了映射器上的ReadConcern错误!
对于超时,我在注册 jar 后添加了它:
SET mapreduce.task.timeout 1800000

我一直在使用SET mapred.task.timeout,但没有用

希望这对遇到类似问题的人有所帮助!

关于mongodb - 映射器无法让Pig将数据插入MongoDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43057640/

相关文章:

有或没有 "implements"的 Hadoop 映射方法?

apache-pig - 在 Apache Pig 中的排名

apache-pig - 在哪里贡献 Apache Pig UDF?

sql - 如何计算 Impala 中两个时间戳之间的秒数?

node.js - MongoDB 值增加一次后不再增加

mongodb - 如何使用 mgo 从文档中解码命名类型别名?

c# - 当我们使用 ASP.NET API Core 2.1 时如何在 MongoDB 中使用多集合进行操作

hadoop - 使用 sqoop 将数据传输到 hdfs 时出错

hadoop - 未指定LOCATION创建托管表时,表数据的数据位置在哪里?

javascript - MongoDB 查询超过 30 秒的文档