Benutzer-Werkzeuge

Webseiten-Werkzeuge


nosql:hadoop_connect_from_windows

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
nosql:hadoop_connect_from_windows [2014/08/06 21:28] – [Hadoop local mit cygwin auf einen Windows 7 Rechner aufrufen] gpipperrnosql:hadoop_connect_from_windows [2014/09/24 14:30] (aktuell) – [Hadoop local mit cygwin auf einen Windows 7 Rechner aufrufen] gpipperr
Zeile 1: Zeile 1:
 +=====HDFS Files remote lesen - Mit MS Windows Clients mit Hadoop arbeiten=====
  
 +
 +=== HDFS Zugriff über Windows ===
 +
 +Software Clients:
 +  * http://bigdata.red-gate.com/hdfs-explorer.html
 +
 +
 +=== Java Klasse um vom Windows Host auf das HDFS zuzugreifen===
 +
 +
 +<code java>
 +package gpi.hadoop;
 +
 +/**
 +see main code:
 +https://sites.google.com/site/hadoopandhive/home/hadoop-how-to-read-a-file-from-hdfs
 +*/
 +
 +import java.io.*;
 +import org.apache.hadoop.fs.*;
 +import org.apache.hadoop.conf.*;
 +
 +public class ReadHDFS {
 +
 +    public static void main(String[] args) throws Exception {
 +        try {
 +            //configuration
 +            Configuration conf = new Configuration();
 +            Path path = new Path("hdfs://nosqldb01:9000/data/gpi/README.txt");
 +            
 +            //handle to the file
 +            FileSystem fs = FileSystem.get(path.toUri(), conf);
 +            FSDataInputStream inputStream = fs.open(path);
 +
 +            //read the file
 +            BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
 +            String line;
 +            line = br.readLine();
 +            while (line != null) {
 +                System.out.println(line);
 +                line = br.readLine();
 +            }
 +            
 +        } catch (Exception e) {
 +            System.out.println(e.toString());
 +        }
 +
 +    }
 +}
 +
 +</code>
 +
 +== Fehler beim ersten Versuch: ==
 +<code>
 +2014-07-13 13:16:34,686 ERROR [main] util.Shell (Shell.java:getWinUtilsPath(336)) - Failed to locate the winutils binary in the hadoop binary path
 +java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.
 +
 +</code>
 +
 +Lösung:
 +
 +Hadoop Home Directory setzen: Java Parameter **hadoop.home.dir** wie z.B: "-Dhadoop.home.dir=D:\entwicklung\libraries\hadoop-2.4.1"
 +
 +**UND**
 +
 +Die Libraries für Windows übersetzen siehe => https://wiki.apache.org/hadoop/Hadoop2OnWindows oder alternativ hier eine übersetze Version der Libraries laden => http://www.srccodes.com/p/article/39/error-util-shell-failed-locate-winutils-binary-hadoop-binary-path .
 +
 +
 +
 +==== Hadoop local mit cygwin auf einen Windows 7 Rechner aufrufen ====
 +
 +
 +Cygwin installieren und Umgebung wie unter Linux in der .bashrc setzen:
 +
 +<code bash>
 +
 +#Hadoop Home
 +export HADOOP_HOME=/cygdrive/d/entwicklung/libraries/hadoop-2.4.1
 + 
 +# Avoid Java Lib errros
 +export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
 +export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib -Dhadoop.home.dir=D:\entwicklung\libraries\hadoop-2.4.1"
 + 
 +# Hadoop environment Variables
 +export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
 +export HADOOP_MAPRED_HOME=$HADOOP_HOME
 +export HADOOP_COMMON_HOME=$HADOOP_HOME
 + 
 + 
 +#JAVA
 +export JAVA_HOME=/cygdrive/d/entwicklung/java/jdk1.7.0_45
 +
 +#fix CLASSPATH
 +export HADOOP_CLASSPATH=$(cygpath -pw $($HADOOP_HOME/bin/hadoop classpath)):$HADOOP_CLASSPATH
 +
 + 
 +#Defaults
 +export PATH=$HADOOP_HOME/bin:$PATH
 +
 +</code>
 +
 +Beim ersten Test des ausgepackten Hadoop wird folgender Fehler mit dem Classpath geworfen:
 +
 +<code bash>
 +$ ./hadoop version
 +Fehler: Hauptklasse org.apache.hadoop.util.VersionInfo konnte nicht gefunden oder geladen werden
 +</code>
 +
 +
 +Lösung:
 +Umgebung anpassen oder im Script den Aufbau vom Klassenpfad anpassen:
 +<code bash>
 +export HADOOP_CLASSPATH=$(cygpath -pw $($HADOOP_HOME/bin/hadoop classpath)):$HADOOP_CLASSPATH
 +</code>
 +
 +Hadoop Konfigurationsdateien auf den Windows Rechner kopieren.
 +
 +
 +Test:
 +
 +<code bash>
 +hdfs dfs -ls /
 +</code>
 +
 +
 +Fehler:
 +
 +<code>
 +2014-08-06 20:06:25,222 ERROR [main] util.Shell (Shell.java:getWinUtilsPath(336)                                                                                                                                                             ) - Failed to locate the winutils binary in the hadoop binary path
 +java.io.IOException: Could not locate executable null\bin\winutils.exe in the Ha                                                                                                                                                             doop binaries.
 +        at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:318)
 +
 +</code>
 +
 +Lösung:
 +Auch hier scheint ein Problem mit den Pfaden in Cygwin vorzuliegen, siehe dieses Jira Ticket https://issues.apache.org/jira/browse/HADOOP-10133
 +Datei $HADOOP_HOME\libexec\hadoop-config.sh anpassen:
 +<code bash>
 +# nach allen anderen HADOOP_OPTS das so setzen:
 +HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.home.dir="$(cygpath -pw "$HADOOP_PREFIX")""
 +</code>
 +
 +
 +Nächster Fehler:
 +
 +<code bash>
 +Exception in thread "main" java.lang.RuntimeException: core-site.xml not found
 +        at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:                       
 +</code>
 +
 +<note important>Lösung noch nicht gefunden, für jeden Tipp dankbar :-(</note>
nosql/hadoop_connect_from_windows.txt · Zuletzt geändert: 2014/09/24 14:30 von gpipperr