码迷,mamicode.com
首页 > 其他好文 > 详细

Hadoop(十):本地IDEA链接远程Hadoop

时间:2020-04-05 00:24:45      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:path   address   home   apr   安装   color   you   reduce   ado   

本文使用的Hadoop为2.7.7,版本如果不同要下载相应版本的文件

  1. 配置本地的Hadoop库(不需完整安装,但是要有环境支持)

下载文件

https://github.com/speedAngel/hadoop2.7.7

  1. 解压到任意路径,没有中文字符和空格

技术图片

 

 

  1. 把解压包的bin替换到解压路径

  2. 把bin中的Hadoop.dll复制到C:\Windows\System32

  3. 配置环境变量

HADOOP_HOME  D:\Environment\hadoop-2.7.7
HADOOP_CONF_DIR  D:\Environment\hadoop-2.7.7\etc\hadoop
YARN_CONF_DIR  %HADOOP_CONF_DIR%
PATH  %HADOOP_HOME%\bin

 

  1. IDEA设置本地Hadoop路径

技术图片

 

 

  1. 导入依赖(注意版本一致)

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
?
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <version>2.7.7</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-hdfs</artifactId>
            <version>2.7.7</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-mapreduce-client-core -->
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-mapreduce-client-core</artifactId>
            <version>2.7.7</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-mapreduce-client-jobclient</artifactId>
            <version>2.7.7</version>
        </dependency>
        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>1.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
            <version>2.7.7</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.19</version>
        </dependency>
        <!--工具类,可以复制对象-->
        <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.4</version>
        </dependency>
    </dependencies>
?

 

  1. 把集群的core-site.xml和hdfs-site.xml文件放到项目resource路径下。修改对应IP地址

  • core-site.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
  <property>
    <name>fs.defaultFS</name>
    <value>hdfs://192.168.98.129:9000</value>
  </property>
  <property>
    <name>hadoop.tmp.dir</name>
    <value>/usr/hop/hadoop-2.7.7/data/hopdata</value>
  </property>
</configuration>
?

 


     
  • hdfs-site.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
?
    http://www.apache.org/licenses/LICENSE-2.0
?
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->
?
<!-- Put site-specific property overrides in this file. -->
?
<configuration>
  <property>
    <name>dfs.namenode.secondary.http-address</name>
    <value>192.168.98.130:50090</value>
  </property>
  <property>
    <name>dfs.replication</name>
    <value>2</value>
  </property>
</configuration>

 


?
  • 运行的Main方法里首行添加

        System.setProperty("HADOOP_USER_NAME","root");
        System.setProperty("HADOOP_USER_PASSWORD","PASSWORD");

 

 

Hadoop(十):本地IDEA链接远程Hadoop

标签:path   address   home   apr   安装   color   you   reduce   ado   

原文地址:https://www.cnblogs.com/renzhongpei/p/12635267.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!