映射器无法让 pig 将数据插入 MongoDB

Mappers fail for pig to insert data into MongoDB

我正在尝试使用带有 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 秒后超时。

猪脚本如下

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 错误! 对于超时,我在注册罐子后添加了这个:

SET mapreduce.task.timeout 1800000

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

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