使用docker搭建hadoop集群
Contents
制作基于ubuntu的Hadoop镜像
文中使用的到的docker知识及命令可参考 Docker基础
在开始之前需确保已安装好docker环境
安装JAVA
| |
安装Hadoop
| |
配置Hadoop
分别配置 core-site.xml、hdfs-site.xml、mapred-site.xml三个文件
| |
vim core-site.xml 配置configuration中的property 如下
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/root/soft/hadoop/hadoop-2.6.5/tmp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://master:9000</value>
<final>true</final>
<description>The name of the default file system. A URI whose scheme and authority determine the FileSystem implementation. The uri’s scheme determines the config property (fs.SCHEME.impl) naming the FileSystem implementation class. The uri’s authority is used to determine the host, port, etc. for a filesystem.
</description>
</property>
</configuration>
vim hdfs.site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>2</value>
<final>true</final>
<description>Default block replication.
The actual number of replications can be specified when the file is created.
The default is used if replication is not specified in create time.
</description>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>/root/soft/hadoop/hadoop-2.6.5/namenode</value>
<final>true</final>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/root/soft/hadoop/hadoop-2.6.5/datanode</value>
<final>true</final>
</property>
</configuration>
cp mapred-site.xml.template mapred-site.xml
vim mapred-site.xml
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>master:9001</value>
<description>The host and port that the MapReduce job tracker runs
at. If “local”, then jobs are run in-process as a single map
and reduce task.
</description>
</property>
</configuration>
配置节点认证互信
| |
Hadoop集群实施
基于之前的hadoop的镜像,此时只需new(docker run)多个容器即可创建多个hadoop节点,然后修改其中的配置,配置为Master或Slave
新建hadoop节点
| |
配置Hosts
| |
Master节点设置
| |
启动服务
| |
查看服务状态
#在各节点中执行jps命令查看服务进程
jps #master中信息
1762 NodeManager
3592 Jps
974 NameNode
1563 SecondaryNameNode
336 ResourceManager
1418 DataNode
对于非Toolbox的Docker环境可直接在浏览器中访问master节点 http://172.17.0.4:50070
如果是采用Toolbox安装的Docker,则访问http://192.168.99.100:50070
此中情况需要做端口映射,见开始docker run处,如果没有可在宿主机执行,达到动态修改端口~
iptables -t nat -A PREROUTING -p tcp -m tcp –dport 50070 -j DNAT –to-destination 172.17.0.4:50070

Author ifreer
LastMod 2016-11-19