我正在尝试通过 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 脚本。