![](/img/trans.png)
[英]Apache Pig: unable to run my own pig.jar and pig-withouthadoop.jar
[英]Unable to run Pig jar using java command
我正在嘗試簡單的豬代碼,但它給了我一些許可。 這是我的示例豬代碼
import java.io.IOException;
import org.apache.pig.PigServer;
import org.apache.pig.ExecType;
import org.apache.hadoop.conf.Configuration;
public class PigTest{
public static void main(String[] args) {
try {
Configuration conf = new Configuration();
conf.set("hdp.version","2.3.0.0-2557");
//PigServer pigServer = new PigServer("mapreduce",conf);
PigServer pigServer = new PigServer(ExecType.MAPREDUCE, conf);
runIdQuery(pigServer, "myfile.txt");
}
catch(Exception e) {
}
}
public static void runIdQuery(PigServer pigServer, String inputFile) throws IOException {
pigServer.registerQuery("A = load '" + inputFile + "' using PigStorage(':');");
pigServer.registerQuery("B = foreach A generate $0 as id;");
pigServer.store("B", "idout");
}
}
我將我的類路徑設置如下
echo $CLASSPATH
.:/usr/hdp/2.3.0.0-2557/hadoop/client/*:/usr/hdp/2.3.0.0-2557/hadoop-hdfs/lib/*:/usr/hdp/2.3.0.0-2557/hadoop-mapreduce/lib/*:/usr/hdp/2.3.0.0-2557/hadoop-yarn/lib/*:/usr/hdp/2.3.0.0-2557/pig/lib/*:/usr/hdp/2.3.0.0-2557/hadoop/conf:/usr/hdp/2.3.0.0-2557/pig/pig-0.15.0.2.3.0.0-2557-core-h2.jar
當我使用java命令運行代碼時,它運行正常,但是當創建了我的代碼罐並嘗試運行時,它給了我以下權限錯誤。
****java -cp /usr/hdp/2.3.0.0-2557/hadoop/client/*;/usr/hdp/2.3.0.0-2557/hadoop-hdfs/lib/*;/usr/hdp/2.3.0.0-2557/hadoop-mapreduce/lib/*;/usr/hdp/2.3.0.0-2557/hadoop-yarn/lib/*;/usr/hdp/2.3.0.0-2557/pig/lib/*;/usr/hdp/2.3.0.0-2557/hadoop/conf;/usr/hdp/2.3.0.0-2557/pig/pig-0.15.0.2.3.0.0-2557-core-h2.jar -jar PigTest.jar****
Error: Could not find or load main class .usr.hdp.2.3.0.0-2557.hadoop.client.activation.jar
-bash: /usr/hdp/2.3.0.0-2557/hadoop-hdfs/lib/asm-3.2.jar: Permission denied
-bash: /usr/hdp/2.3.0.0-2557/hadoop-mapreduce/lib/aopalliance-1.0.jar: Permission denied
-bash: /usr/hdp/2.3.0.0-2557/hadoop-yarn/lib/activation-1.1.jar: Permission denied
-bash: /usr/hdp/2.3.0.0-2557/pig/lib/accumulo-core-1.5.0.jar: Permission denied
-bash: /usr/hdp/2.3.0.0-2557/hadoop/conf: is a directory
-bash: /usr/hdp/2.3.0.0-2557/pig/pig-0.15.0.2.3.0.0-2557-core-h2.jar: Permission denied
我該如何解決?
嘗試以下
/usr/hdp/2.3.0.0-2557/hadoop/client/*
使用/usr/hdp/2.3.0.0-2557/hadoop/client/*.jar
/ *。jar(請參閱結尾的.jar。將所有*替換為* 。罐)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.