为了账号安全,请及时绑定邮箱和手机立即绑定

【Hadoop脱坑】基于HPC集群节点的Hadoop完全分布式环境搭建以及Hadoop编程

标签:
Hadoop

正文之前

上一篇文章就说过了,实验室的温暖我终于感受到了~借到了来自实验室的HPC集群的两个节点。。虽然只有两个,但是也很棒了!!

申请机器配置要求:集群节点配置,2*8核CPU,64GBDDR3内存,300GB本地SAS磁盘,千兆以太网卡,InfiniBand网卡,Lustre文件系统,RedHat Enterprise Linux6.2,内核版本2.6.32

webp

正文

搭建好的集群节点就是好使,什么免密登陆?什么虚拟机?都不存在的,直接就是已经配置好了的。而且因为文件系统比较牛叉?反正放/home/目录下就是通用,什么软件这个节点一装,另外的节点自动就有了。简直美滋滋!!

这不,弄好了JDK之后,我就直接从镜像站下载了一个hadoop2.9.1的安装包,丢到家目录下,然后设置下就OK了!简直没法更美了!

webp

最近在官网找Hadoop的下载连接真的是找的人鸡儿疼,所以我搜了不少地方,最后发现我们学校的镜像站居然是最优秀的???

http://mirrors.hust.edu.cn/apache/hadoop/common/hadoop-2.9.1/hadoop-2.9.1.tar.gz

如果你要更改版本,直接把链接里面的版本改一下就可以。。

webp

我科镜像站

我也没搞太多。基本就修改了下/home/下面的几个配置文件,然后再按照教程修改了hadoop的五个文件内容就OK了!

教程如下:

Hadoop集群安装配置教程_Hadoop2.6.0_Ubuntu/CentOS

然后我把我的配置文件和修改之后的文件都丢一下,大家自行领悟,记得source!!!!!!千万记得!!!:

/home/.bashrc:

[zbzhang@node61 ~]$ cat .bashrc# .bashrc# Source global definitionsif [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi# User specific aliases and functionsexport PATH=$PATH:/home/zbzhang/hadoop/bin:/home/zbzhang/hadoop/sbin#alias sudo='sudo env PATH=$PATH'export HADOOP_HOME=/home/zbzhang/hadoop

export JAVA_HOME=/home/zbzhang/jdk1.8.0_171
export JAVA_BIN=$JAVA_HOME/bin
export JAVA_LIB=$JAVA_HOME/lib
export CLASSPATH=.:$JAVA_LIB/tools.jar:$JAVA_LIB/dt.jar
export PATH=$JAVA_BIN:$PATH

.bash_profile 这个不知道有没有用,反正我写了挺好的

[zbzhang@node61 ~]$ cat .bash_profile# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi# User specific environment and startup programsexport JAVA_HOME=/home/zbzhang/jdk1.8.0_171
export JAVA_BIN=$JAVA_HOME/bin
export JAVA_LIB=$JAVA_HOME/lib
export CLASSPATH=.:$JAVA_LIB/tools.jar:$JAVA_LIB/dt.jar

PATH=$PATH:$HOME/bin:$JAVA_HOME:/bin#PATH=$JAVA_HOME/bin:$PATH:$HOME/binexport PATH

然后修改图中的6个文件:

webp

最右边那个如果没有文件,那就是有一个临时文件,改下名字就OK!我的两个节点一个是node61 一个是node39  我用node61做主机,node39做从机。所以是下面的配置,你们对应的内容要改,主要是主机名

第一个,把所有的数据节点的名字加上去,我只有一个,所以就是node39:

webp

第二个,这个文件主要是要


webp

<?xml version="1.0"?><!--
  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.
--><!-- <configuration>

Site specific YARN configuration properties

</configuration>
 -->

 <configuration>
        <property>
                <name>yarn.resourcemanager.hostname</name>
                <value>node61</value>
        </property>
        <property>
                <name>yarn.nodemanager.aux-services</name>
                <value>mapreduce_shuffle</value>
        </property></configuration>

第三个,注意的地方我都圈出来了:

webp

<?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>fs.defaultFS</name>
                <value>hdfs://node61:9000</value>
        </property>
        <property>
                <name>hadoop.tmp.dir</name>
                <value>file:/home/zbzhang/hadoop/tmp</value>
                <description>Abase for other temporary directories.</description>
        </property></configuration>

第四个,我圈出来了:

webp

第五个,文件系统的内容可以说是要改的最多的了。。

webp

第一个改下主机名,然后第二个是数据节点的个数,我是一个。第三、四个是临时文件的地址,自己选,但是hadoop后面的都不要动了!

<?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>node61:50090</value>
        </property>
        <property>
                <name>dfs.replication</name>
                <value>1</value>
        </property>
        <property>
                <name>dfs.namenode.name.dir</name>
                <value>file:/home/zbzhang/hadoop/tmp/dfs/name</value>
        </property>
        <property>
                <name>dfs.datanode.data.dir</name>
                <value>file:/home/zbzhang/hadoop/tmp/dfs/data</value>
        </property></configuration>

最后一个,改下主机名就OK!

webp

<?xml version="1.0"?><?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>mapreduce.framework.name</name>
                <value>yarn</value>
        </property>
        <property>
                <name>mapreduce.jobhistory.address</name>
                <value>node61:10020</value>
        </property>
        <property>
                <name>mapreduce.jobhistory.webapp.address</name>
                <value>node61:19888</value>
        </property></configuration>

OK,这些改好了之后,其实你就基本配置好了。。


配置到此为止,下面进入编程环节:

命令大家伙都知道撒:

hdfs namenode -format       # 首次运行需要执行初始化,之后不需要
start-dfs.sh
start-yarn.sh
mr-jobhistory-daemon.sh start historyserver

跑完之后jps看看。。

webp

然后到从机看看

webp

也可以在主机看有几个数据节点来判断是否数据节点没毛病:

hdfs dfsadmin -report
[zbzhang@node61 ~]$ hdfs dfsadmin -report
18/06/11 10:43:34 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
具体配置我还是不泄露了。。。反正容量的话。。大概几百个大号移动硬盘的容量吧。。

-------------------------------------------------
Live datanodes (1):

Name: 11.11.0.39:50010 (node39)
Hostname: node39
Decommission Status : Normal
DFS Used%: 0.00%
DFS Remaining%: 87.81%
Configured Cache Capacity: 0 (0 B)
Cache Used: 0 (0 B)
Cache Remaining: 0 (0 B)
Cache Used%: 100.00%
Cache Remaining%: 0.00%
Xceivers: 1
Last contact: Mon Jun 11 10:43:35 CST 2018
Last Block Report: Mon Jun 11 07:25:46 CST 2018
[zbzhang@node61 ~]$ cat test.sh
hdfs dfs -mkdir -p /input
hdfs dfs -mkdir /output
hdfs dfs -put /test1.txt /input/
hdfs dfs -put /test2.txt /input/
hdfs dfs -rm /output/result/*
hdfs dfs -rmdir /output/result
hadoop jar hadoopClear.jar hadoopClear /input/ /output/result
hdfs dfs -cat /output/result/*

这是我写的一个测试脚本,还可以的。。。

webp

webp

最后出现的是这个。。也就是我写的那个软件包的运行结果:

webp

具体的后面讲吧。。。。我得先写毕业设计论文了。。。赶紧扯淡补上去!!

正文之后

阿西吧!今天老板叫我过去,然后跟我说以后多看数据流的方向。。。然后分配座位的老师让我下周过去看看有没有。。。我心里苦啊。。。我还要流浪啊!!不过金总跟我说要我去报备年会!!嘿嘿~~~有组织就是不一样,还有衣服发!!



作者:HustWolf
链接:https://www.jianshu.com/p/20bc581200e7


点击查看更多内容
1人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消