具体的就不介绍了,请参考我另一篇文章http://my.oschina.net/lanzp/blog/309078 node
在讲解以前,先声明一点,这篇文章的全部环境都是基于上一篇伪分布的配置文章的基础上再作配置的,若是你没有看过我以前的那篇文章,建议你先去阅读一下。 web
如今网上比较少新版本的配置教程,那么下面我就来分享一下我本身的实战经验,若有不正确的地欢迎指正 :) shell
首先,咱们的节点信息以下: apache
master 192.168.8.184 slave1 192.168.8.183 slave2 192.168.8.178 slave3 192.168.8.190
我是用虚拟机作的,主节点(Master)配置好后做为模板,其余3个从节点(slave一、slave二、slave3)直接作虚拟机拷贝,其中slave1还兼任了第二namenode节点。由于主节点的配置跟从节点的配置是彻底同样的,拷贝完后只须要作两件事:修改hostname、从新生成SSH无口令登录的KEY。拷贝完成后启动若是网络有问题,直接百度谷歌就好了。关于修改hostname对应上面的IP修改为相应的名称就能够了,如192.168.8.184修改为master。而用户名、密码彻底能够不须要修改,固然你要改也是没有问题的,节点多了很差记哦。首先,咱们先来说一下配置,一共要配置6个文件,分别是core-site.xml、hdfs-site.xml、mapred-site.xml、yarn-site.xml、masters、slaves,其中masters文件可能会在配置目录下不存在,本身新建一个就能够了,详细配置以下: 网络
core-site.xml: app
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://192.168.8.184:9000</value> <description>same as fs.default.name</description> </property> <property> <name>hadoop.tmp.dir</name> <value>/usr/mywind/tmp</value> <description>A base for other temporary directories.</description> </property> </configuration>
<configuration> <property> <name>dfs.namenode.name.dir</name> <value>/usr/mywind/name</value> <description>same as dfs.name.dir</description> </property> <property> <name>dfs.datanode.data.dir</name> <value>/usr/mywind/data</value> <description>Comma separated list of paths on the local filesystem of a DataNode where it should store its blocks.If this is a comma-delimited list of directories, then data will be stored in all named directories, typically on different devices.</description> </property> <property> <name>dfs.blocksize</name> <value>268435456</value> <description>HDFS blocksize of 256MB for large file-systems.</description> </property> <property> <name>dfs.namenode.http-address</name> <value>master:50070</value> <description>The address and the base port where the dfs namenode web ui will listen on.</description> </property> <property> <name>dfs.namenode.secondary.http-address</name> <value>slave1:50090</value> <description>The secondary namenode http server address and port.</description> </property> <property> <name>dfs.replication</name> <value>3</value> <description>same as old frame,recommend set the value as the cluster DataNode host numbers!</description> </property> </configuration>
mapred-site.xml: ssh
<configuration> <!--Configurations for MapReduce Applications --> <property> <name>mapreduce.framework.name</name> <value>yarn</value> <description>Execution framework set to Hadoop YARN.</description> </property> <!--Configurations for MapReduce JobHistory Server --> <property> <name>mapreduce.jobhistory.address</name> <value>master:10020</value> <description>MapReduce JobHistory Server host:port.Default port is 10020.</description> </property> <property> <name>mapreduce.jobhistory.webapp.address</name> <value>master:19888</value> <description>MapReduce JobHistory Server Web UI host:port.Default port is 19888.</description> </property> </configuration>
yarn-site.xml: webapp
<configuration> <!-- Configurations for ResourceManager --> <property> <name>yarn.resourcemanager.address</name> <value>master:8032</value> </property> <property> <name>yarn.resourcemanager.scheduler.address</name> <value>master:8030</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address</name> <value>master:8031</value> </property> <property> <name>yarn.resourcemanager.admin.address</name> <value>master:8033</value> </property> <property> <name>yarn.resourcemanager.webapp.address</name> <value>master:8088</value> </property> <!-- Configurations for NodeManager --> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> <description>Configuration to enable or disable log aggregation.Shuffle service that needs to be set for Map Reduce applications.</description> </property> <property> <name>yarn.nodemanager.aux-services.mapreduce_shuffle.class</name> <value>org.apache.hadoop.mapred.ShuffleHandler</value> </property> </configuration>
masters: 分布式
master
slave1 slave2 slave3
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
从节点(slave1、slave2、slave3)执行上面的命令从新生成完KEY以后,主节点须要与从节点创建无密码登录,那么,就须要把主节点的KEY添加到从节点的受权列表中,这样主节点才能不须要输入密码的状况下链接访问从节点。步骤以下: oop
1. 把主节点的公钥复制到从节点中。
2. 从节点把主节点的公钥写入受权列表。
首先,在主节点中切换到/home/a01513目录下(注意:a01513是个人操做系统用户名,实际名称根据你系统的用户名改为相应的名称就能够了):
cd /home/a01513
而后复制,这里我以slave1节点为例:
scp ~/.ssh/id_rsa.pub a01513@192.168.8.183:/home/a01513/
这里可能要你输入slave1(192.168.8.183)的主机密码,输入就能够了,输入完成后到slave1节点终端输入如下命令把主节点的公钥复制到受权列表:
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
回到主节点终端中输入:
ssh slave1
若是不须要输入密码就链接成功的话,证实你配置对了,恭喜!
若是上面的步骤完成了,那么下面进行格式化文件系统:
hdfs namenode -format
而后启动HDFS、YARN、JobHistory进程:
start-dfs.sh start-yarn.sh
注意旧版本的start-all.sh已经被上面两个脚本替代了,不过好像这命令还可能用,建议仍是用上面两个吧。
mr-jobhistory-daemon.sh start historyserver
stop-dfs.sh stop-yarn.sh mr-jobhistory-daemon.sh stop historyserver
至此,咱们的彻底分布式配置已经大功告成!