我試圖通過Java運行Pig腳本。下面是我的代碼看起來像現在:試圖通過Java運行Pig時出現ERROR 4010
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的網站下載到Applications
和pig-0.10.1
文件夾在我的~/.bash_profile
中添加了export PIG_HOME=/Applications/pig-0.10.1
。
當我登錄到<some-value>:8020
服務器時,我可以運行Pig腳本。
我下載的Hadoop從'HTTP:// mirrors.sonic.net/apache/hadoop/common/hadoop-1.0.4/hadoop-1.0.4.tar.gz'並將該文件夾移動到'Applications'中。我通過Eclipse運行我的程序。我的'.bash_profile'有這兩行'export JAVA_HOME =/usr/lib/java:$ JAVA_HOME'和'export PIG_HOME =/Applications/pig-0.10.1' – FilmiHero
我不知道你的機器是如何設置的。你必須找到hadoop配置目錄。看看你的'Applications'文件夾。 –
好吧,我通過'brew'安裝了'hadoop'和'pig',然後將'core-site.xml'文件複製到了我的Java項目的類路徑中,從而解決了這個問題。現在,當我嘗試運行該程序時,出現了其他一些錯誤。 :( – FilmiHero