Description:Hadoop installation, a total of three deployment methods, respectively, are local deployment, pseudo-distributed deployment, cluster deployment. Here we take the pseudo-distribution pattern as an example to explain.
software:myeclipse-2014-ga, Hadoop-2.5.1.tar.gz,hadoop-eclipse-plugin-2.5.0.jar
Software: Link: http://pan.baidu.com/s/1ntuUhux Password: Stok
1, first copy the Hadoop-eclipse-plugin-2.5.0.jar to the MyEclipse plug-in directory inside
2. Start MyEclipse and see if the plug-in is installed successfully
3, configuration plug-in information,:
Note: Host is a cluster host ip,port:50020 is the default, the right port is the information configured in the cluster core-site.xml
4, after the configuration is complete, create a new project, here I built a Java project
1 PackageHadoop;2 3 Importjava.io.IOException;4 ImportJava.text.DateFormat;5 Importjava.util.Date;6 7 Importorg.apache.hadoop.conf.Configuration;8 ImportOrg.apache.hadoop.fs.FileStatus;9 ImportOrg.apache.hadoop.fs.FileSystem;Ten ImportOrg.apache.hadoop.fs.Path; One A Public classHadooptest { - Public Static voidMain (string[] args)throwsIOException { -System.out.println ("12"); theConfiguration conf =NewConfiguration (); -Conf.set ("Fs.defaultfs", "hdfs://192.168.0.204:9000"); -FileSystem fs =filesystem.get (conf); -Filestatus[] s = fs.liststatus (NewPath ("/")); + for(inti = 0; i < s.length; i++) { -Filestatus f =S[i]; + System.out.println (F.getpath (). GetName ()); A System.out.println (F.getlen ()); at System.out.println (F.getmodificationtime ()); -Date Date =NewDate (F.getmodificationtime ()); -String d =dateformat.getdateinstance (). Format (date); - System.out.println (d); - } - fs.close (); in } -}
View Code
5. After successful operation, the file information obtained from the cluster will be displayed.
003, Java connection Hadoop2.5.1 get file system Information