Foreword
Previous describes the build pseudo-distributed cluster, in fact, in our production environment, we are certainly not the only use of a pseudo-distributed cluster of servers among. Next, I will share with you to build a fully distributed cluster!
In fact, the most basic building fully distributed clusters and pseudo-distributed cluster basically no difference, only a small difference.
First, build a fully distributed Hadoop cluster premise
1.1, network
1) If it is installed in a plurality of linux operating system in a virtual machine, you can use NAT or bridge mode are possible. Try Can ping each other!
2) If a local area network among their own more than one computer (each computer to install the same version of linux system) to build, will be the Ubuntu operating system to be used to adjust the network mode to bridge mode.
step:
First: on the label of the virtual machine you want to use right-click, select Settings, select the network adapter, select the bridge mode to determine
Second: After setup is complete, restart the virtual machine
The third is: the fixed IP canceled before re-setting the bridge
Desktop: The graphical interface settings.
Server Edition: in / etc / Network / in the interfaces
iface ens33 inet dhcp
#address ...
Fourth: ifconfig get IP. 172.16.21.xxx
Finally, give it a try can not ping
1.2, install jdk
Each server clusters to be set up will need to install jdk, not presented here, can be viewed on a
1.3. Installation hadoop
Each server clusters to be set up will need to install hadoop, not presented here, can be viewed on one.
Two, Hadoop to build a fully distributed cluster configuration
Configuration / opt / hadoop / etc / hadoop related documents
2.1、hadoop-env.sh
25 line: export JAVA_HOME = $ {JAVA_HOME}
changed: export JAVA_HOME = / opt / jdk
2.2、core-site.xml
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://mip:9000</value> </property> </configuration>
analysis:
mip: mip is their ip in the master node, and all nodes from the mip ip is the master node.
9000: the master node and the slave node are arranged port 9000
2.3、hdfs-site.xml
Note: **: The following configured several directories. Necessary / data directory permissions to use -R 777.
<configuration> <property> <name>dfs.nameservices</name> <value>hadoop-cluster</value> </property> <property> <name>dfs.replication</name> <value>1</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:///data/hadoop/hdfs/nn</value> </property> <property> <name>dfs.namenode.checkpoint.dir</name> <value>file:///data/hadoop/hdfs/snn</value> </property> <property> <name>dfs.namenode.checkpoint.edits.dir</name> <value>file:///data/hadoop/hdfs/snn</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:///data/hadoop/hdfs/dn</value> </property> </configuration>
analysis:
dfs.nameservices: In a fully distributed cluster cluster among the public to the same value
dfs.replication: hadoop having reliability as it backs up a plurality of text, this value refers to the number of backup (less than equal to the number of the nodes)
one question:
dfs.datanode.data.dir: Here I encountered a problem when the configuration is used when the time to get up from the node. When there is change fs.datanode.data.dir used.
But the official documents given this really is it! So very public pool. Because before version 2.0 is only fs
2.4.mapred-site.xml
Note: If immediately after decompression, is not this file, you need to mapred-site.xml.template copy is mapred-site.xml.
<configuration> <property>
<!-指定Mapreduce运行在yarn上--> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration>
2.5、yarn-site.xml
<configuration> <!-- 指定ResourceManager的地址--> <property> <name>yarn.resourcemanager.hostname</name> <value>mip</value> </property> <!-- 指定reducer获取数据的方式--> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <property> <name>yarn.nodemanager.local-dirs</name> <value>file:///data/hadoop/yarn/nm</value> </property>
analysis:
mip: mip is their ip in the master node, and all nodes from the mip ip is the master node.
2.6, create a directory configuration of the above
sudo mkdir -p /data/hadoop/hdfs/nn sudo mkdir -p /data/hadoop/hdfs/dn sudo mkdir -p /data/hadoop/hdfs/snn sudo mkdir -p /data/hadoop/yarn/nm
Must be set to: sudo chmod -R 777 / data
Third, build a fully distributed cluster test
3.1 Operating Environment
There are three ubuntu server (ubuntu 17.04):
Host Name: udzyh1 IP: 1.0.0.5 as a master node (node name)
Host name: server1 IP: 1.0.0.3 as from the node (node data)
Host Name: udzyh2 IP: 1.0.0.7 as from the node (node data)
jdk1.8.0_131
hadoop 2.8.1
Startup and Shutdown 3.2, server clusters
The name of the node, the resource manager: This is turned on or off in the master node.
Data nodes, Node Manager: This is in startup or shutdown from node.
MR job log management: This is to enable or disable the master node.
3.3, the effect
The master node: udzyh1 in
In the slave node: server1 in
In the slave node: udzyh2 in
We control the web page master node: http: 1.0.0.5: 50070 in view from two nodes
Configuration was successful
3.4 Monitoring Platform
Four, Hadoop cluster configuration fully distributed free secret sign-on implementation from the master node to control node
This configuration is to achieve the primary node management (opening and closing) from the function node:
我们只需要在主节点中使用start-dfs.sh/stop-dfs.sh就能开启或关闭namenode和所有的datanode,使用start-yarn.sh/stop-yarn.sh就能开启或关闭resourcemanager和所有的nodemanager。
4.1、配置主从节点之间的免密登录
1)在所有的主从节点中执行
3)在所有的从节点中执行
在从节点1.0.0.7
4)测试
我们可以查看他们是用户名相同的,所以可以直接使用ssh 1.0.0.3远程连接
4.2、实现主节点控制从节点
1)在主节点中
打开vi /opt/hadoop/etc/hadoop/slaves
4.3、测试实现主节点控制从节点
1)在主节点的服务器中执行start-dfs.sh
2)在web监控平台查询
3)在主节点的服务器中执行stop-dfs.sh
3)在主节点的服务器中执行start-yarn.sh
4)在web监控平台查询到
5)在主节点的服务器中执行stop-yarn.sh
五、配置集群中遇到的问题
2)主节点和从节点启动了,但是在主节点的web控制页面查找不到从节点(linux系统安装在不同的物理机上面)
解决方案:
它不能建立IPv6的连接,所以删除了IPv6之后系统会使用IPv4(在主节点上添加从节点的标识的)
4)在主节点的web控制页面查询不到从节点信息(但是使用jps可以查询到)
前言
上一篇介绍了伪分布式集群的搭建,其实在我们的生产环境中我们肯定不是使用只有一台服务器的伪分布式集群当中的。接下来我将给大家分享一下全分布式集群的搭建!
其实搭建最基本的全分布式集群和伪分布式集群基本没有什么区别,只有很小的区别。
一、搭建Hadoop全分布式集群前提
1.1、网络
1)如果是在一台虚拟机中安装多个linux操作系统的话,可以使用NAT或桥接模式都是可以的。试一试可不可以相互ping通!
2)如果在一个局域网当中,自己的多台电脑(每台电脑安装相同版本的linux系统)搭建,将所要使用的Ubuntu操作系统的网络模式调整为桥接模式。
步骤:
一是:在要使用的虚拟机的标签上右键单击,选择设置,选择网络适配器,选择桥接模式,确定
二是:设置完成之后,重启一下虚拟机
三是:再设置桥接之前将固定的IP取消
桌面版:通过图形化界面设置的。
服务器版:在/etc/network/interfaces
iface ens33 inet dhcp
#address ...
四是:ifconfig获取IP。172.16.21.xxx
最后试一试能不能ping通
1.2、安装jdk
每一个要搭建集群的服务器都需要安装jdk,这里就不介绍了,可以查看上一篇
1.3.安装hadoop
每一个要搭建集群的服务器都需要安装hadoop,这里就不介绍了,可以查看上一篇。
二、Hadoop全分布式集群搭建的配置
配置/opt/hadoop/etc/hadoop相关文件
2.1、hadoop-env.sh
25行左右:export JAVA_HOME=${JAVA_HOME}
改成:export JAVA_HOME=/opt/jdk
2.2、core-site.xml
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://mip:9000</value> </property> </configuration>
分析:
mip:在主节点的mip就是自己的ip,而所有从节点的mip是主节点的ip。
9000:主节点和从节点配置的端口都是9000
2.3、hdfs-site.xml
注意:**:下面配置了几个目录。需要将/data目录使用-R给权限为777。
<configuration> <property> <name>dfs.nameservices</name> <value>hadoop-cluster</value> </property> <property> <name>dfs.replication</name> <value>1</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:///data/hadoop/hdfs/nn</value> </property> <property> <name>dfs.namenode.checkpoint.dir</name> <value>file:///data/hadoop/hdfs/snn</value> </property> <property> <name>dfs.namenode.checkpoint.edits.dir</name> <value>file:///data/hadoop/hdfs/snn</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:///data/hadoop/hdfs/dn</value> </property> </configuration>
分析:
dfs.nameservices:在一个全分布式集群大众集群当中这个的value要相同
dfs.replication:因为hadoop是具有可靠性的,它会备份多个文本,这里value就是指备份的数量(小于等于从节点的数量)
一个问题:
dfs.datanode.data.dir:这里我在配置的时候遇到一个问题,就是当使用的这个的时候从节点起不来。当改成fs.datanode.data.dir就有用了。
但是官方给出的文档确实就是这个呀!所以很邪乎。因为只有2.0版本之前是fs
2.4.mapred-site.xml
注意:如果在刚解压之后,是没有这个文件的,需要将mapred-site.xml.template复制为mapred-site.xml。
<configuration> <property>
<!-指定Mapreduce运行在yarn上--> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration>
2.5、yarn-site.xml
<configuration> <!-- 指定ResourceManager的地址--> <property> <name>yarn.resourcemanager.hostname</name> <value>mip</value> </property> <!-- 指定reducer获取数据的方式--> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <property> <name>yarn.nodemanager.local-dirs</name> <value>file:///data/hadoop/yarn/nm</value> </property>
分析:
mip:在主节点的mip就是自己的ip,而所有从节点的mip是主节点的ip。
2.6、创建上面配置的目录
sudo mkdir -p /data/hadoop/hdfs/nn sudo mkdir -p /data/hadoop/hdfs/dn sudo mkdir -p /data/hadoop/hdfs/snn sudo mkdir -p /data/hadoop/yarn/nm
一定要设置成:sudo chmod -R 777 /data
三、全分布式集群搭建测试
3.1、运行环境
有三台ubuntu服务器(ubuntu 17.04):
主机名:udzyh1 IP:1.0.0.5 作为主节点(名字节点)
主机名:server1 IP:1.0.0.3 作为从节点(数据节点)
主机名:udzyh2 IP:1.0.0.7 作为从节点(数据节点)
jdk1.8.0_131
hadoop 2.8.1
3.2、服务器集群的启动与关闭
名字节点、资源管理器:这是在主节点中启动或关闭的。
数据节点、节点管理器:这是在从节点中启动或关闭的。
MR作业日志管理器:这是在主节点中启动或关闭的。
3.3、效果
在主节点:udzyh1中
在从节点:server1中
在从节点:udzyh2中
我们在主节点的web控制页面中:http:1.0.0.5:50070中查看到两个从节点
说明配置成功
3.4、监控平台
四、Hadoop全分布式集群配置免密登录实现主节点控制从节点
配置这个是为了实现主节点管理(开启和关闭)从节点的功能:
我们只需要在主节点中使用start-dfs.sh/stop-dfs.sh就能开启或关闭namenode和所有的datanode,使用start-yarn.sh/stop-yarn.sh就能开启或关闭resourcemanager和所有的nodemanager。
4.1、配置主从节点之间的免密登录
1)在所有的主从节点中执行
3)在所有的从节点中执行
在从节点1.0.0.7
4)测试
我们可以查看他们是用户名相同的,所以可以直接使用ssh 1.0.0.3远程连接
4.2、实现主节点控制从节点
1)在主节点中
打开vi /opt/hadoop/etc/hadoop/slaves
4.3、测试实现主节点控制从节点
1)在主节点的服务器中执行start-dfs.sh
2)在web监控平台查询
3)在主节点的服务器中执行stop-dfs.sh
3)在主节点的服务器中执行start-yarn.sh
4)在web监控平台查询到
5)在主节点的服务器中执行stop-yarn.sh
五、配置集群中遇到的问题
2)主节点和从节点启动了,但是在主节点的web控制页面查找不到从节点(linux系统安装在不同的物理机上面)
解决方案:
It can not establish a connection to IPv6, IPv6 is deleted after the system uses IPv4 (add a logo from a node on the primary node)
4) control the web page can not find the master node node information from (but can use the jps queried)