我正在尝试通过java运行pig脚本。下面是我的代码现在的样子:
public static void main(String[] args) throws JSONException, InterruptedException, IOException {
Properties props = new Properties();
props.setProperty("fs.default.name", "hdfs://<some-value>:8020");
props.setProperty("mapred.job.tracker", "<some-value>:54311");
PigServer pigServer = new PigServer(ExecType.MAPREDUCE, props);
Map<String, String> params = new LinkedHashMap<String, String>();
params.put("INPUT_PATH", "hdfs://<some-input-value>");
params.put("OUTPUT_FILE", "hdfs:///user/<some-username>/last-login-out");
pigServer.registerScript("last-login-by-userid.pig", params);
}
但每当我运行程序时,我会得到:
Exception in thread "main" org.apache.pig.backend.executionengine.ExecException: ERROR 4010: Cannot find hadoop configurations in classpath (neither hadoop-site.xml nor core-site.xml was found in the classpath). If you plan to use local mode, please put -x local option in command line.
我已经把房子搬走了 pig-0.10.1
我从apache网站下载到的文件夹 Applications
并添加了 export PIG_HOME=/Applications/pig-0.10.1
在我的 ~/.bash_profile
.
当我登录到 <some-value>:8020
服务器,我可以运行Pig脚本很好。
2条答案
按热度按时间eqzww0vc1#
你的hadoop安装在哪里?在我的系统上,配置在
/etc/hadoop/conf
. 将其添加到java程序的类路径中。例如,由于各种原因,我不使用已安装的
pig
bash脚本;我就叫Pig吧Main
像这样的班级:zlwx9yxi2#
我在从java运行pig时遇到了同样的异常。在将hadoop conf目录的路径添加到项目属性库add jar/文件夹之后,这个问题就解决了
裁判:http://helpmetocode.blogspot.in/2012/04/exception-in-thread-main.html
谢谢,
卡莱