hadoop的eclipse环境搭建

大数据专栏
上一篇 主目录 下一篇

【前言】


1. eclipse的安装

参见 https://blog.csdn.net/qq_36554582/article/details/81835097

2. 安装hadoop插件

将hadoop-eclipse-plugin-2.7.4.jar放在eclipse的安装目录的dropins下:
在这里插入图片描述
重启eclipse

3. 搭建eclipse开发环境

在eclipse->windows->show view->others->MapReduce Tools
打开Map/ReduceLocations窗口
在这里插入图片描述
new一个hadoop location:
在这里插入图片描述
连接成功:
在这里插入图片描述
附录一段连接虚拟机中hdfs集群的小代码:

import java.net.URI;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

public class MyFirstHDFSDemo {
	public static void main(String[] args) throws Exception {
		URI uri = new URI("hdfs://192.168.65.101:9000/");
		Configuration conf = new Configuration();
		String user = "hadoop";
		FileSystem fs = FileSystem.get(uri,conf,user);
		
		//fs.copyFromLocalFile(new Path("C:\\Users\\47463\\Desktop\\community-master.zip"), new Path("/"));
		fs.copyFromLocalFile(new Path(args[0]), new Path(args[1]));
		boolean exist = fs.exists(new Path("/community-master.zip"));
		if(exist) {
			System.out.println("success");
		}else {
			System.out.println("failed");
		}
		fs.close();
	}
}
发布了180 篇原创文章 · 获赞 149 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/qq_33208851/article/details/104531881