【发布时间】:2019-11-21 22:42:18
【问题描述】:
我对 Hadoop 非常陌生。我的hadoop版本是3.1.1,pig版本是0.17.0。
通过在本地模式下运行此脚本,一切都按预期工作
猪 -x 本地
grunt> student = LOAD '/home/ubuntu/sharif_data/student.txt' USING PigStorage(',') as ( id:int, firstname:chararray, lastname:chararray, phone:chararray, city:chararray );
grunt> DUMP student;
但是对于相同的输入文件和 pig 脚本,mapreduce 模式无法成功。
pig -x mapreduce
grunt> student = LOAD '/pig_data/student.txt' USING PigStorage(',') AS ( id:int, firstname:chararray, lastname:chararray, phone:chararray, city:chararray );
grunt> STORE student INTO '/pig_data/student_out' USING PigStorage (',');
或
grunt> student = LOAD 'hdfs://NND1:9000/pig_data/student.txt' USING PigStorage(',') AS ( id:int, firstname:chararray, lastname:chararray, phone:chararray, city:chararray );
grunt> STORE student INTO 'hdfs://NND1:9000/pig_data/student_out' USING PigStorage (',');
mapreduce 模式的结果 要么 注意:student.txt 已成功上传到 HDFS。
hdfs dfs -ls /pig_data
Found 2 items
-rw-r--r-- 3 ubuntu supergroup 861585 2019-07-12 00:55 /pig_data/en.sahih.txt
-rw-r--r-- 3 ubuntu supergroup 234 2019-07-12 12:25 /pig_data/student.txt
即使在 grunt 下,此命令也会返回正确的 HDFS 文件名。
grunt> fs -cat /pig_data/student.txt
- 为什么当文件存在于 小路?
- 我失踪的可能原因是什么?
感谢任何帮助。
【问题讨论】:
-
你确定不是在本地检查吗?您尚未在 URL 中指定 HDFS。注意这里如何使用完整的 HDFS URL tutorialspoint.com/apache_pig/apache_pig_grunt_shell
-
为什么我需要 hdfs 路径,因为 pig 可以使用 fs 识别它?仅供参考,我也尝试过使用 hdfs 路径:(
-
如果指向本地存储的同一个文件,作业是否运行?
-
是的。在本地模式下,我的本地文件运行成功。唯一的问题是它在 mapreduce 模式下失败并出现如下错误:哎呀!有些工作失败了!如果您希望 Pig 在失败时立即停止,请指定 -stop_on_failure。
标签: hadoop bigdata apache-pig hadoop3