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.
Apache Web サイトからダウンロードしたpig-0.10.1
フォルダーを移動し、.Applications
export PIG_HOME=/Applications/pig-0.10.1
~/.bash_profile
サーバーにログインすると<some-value>:8020
、Pig スクリプトを問題なく実行できます。