Hadoop2.x(yarn)分布式安装与配置

(1)服务器准备
192.168.119.130 gp-master # NameNode,ResourceManager
192.168.119.131 gp-slave1 # SecondaryNameNode,NodeManager,DataNode
192.168.119.132 gp-slave2 # NodeManager,DataNode
192.168.119.133 gp-slave3 # NodeManager,DataNode

(2)安装java,及ssh免密配置

(3)新建文件夹
/home/gpadmin/hadoop/data/hdfs/data
/home/gpadmin/hadoop/data/hdfs/name
/home/gpadmin/hadoop/data/hdfs/tmp

(4)解压hadoop
/home/gpadmin/hadoop/hadoop-2.6.0

(5)配置文件修改
修改以下文件的java路径
/home/gpadmin/hadoop/hadoop-2.6.0/etc/hadoop/yarn-env.sh
/home/gpadmin/hadoop/hadoop-2.6.0/etc/hadoop/hadoop-env.sh

修改/home/gpadmin/hadoop/hadoop-2.6.0/etc/hadoop/core-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>hadoop.tmp.dir</name>
<value>file:/home/gpadmin/hadoop/data/hdfs/tmp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>io.file.buffer.size</name>
<value>131072</value>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://gp-master:9000</value>
</property>
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>
<property>
<name>fs.checkpoint.period</name>
<value>60</value>
<description>The number of seconds between two periodic checkpoints.</description>
</property>
<property>
<name>fs.checkpoint.size</name>
<value>67108864</value>
</property>
</configuration>

修改/home/gpadmin/hadoop/hadoop-2.6.0/etc/hadoop/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.replication</name>
<value>3</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/home/gpadmin/hadoop/data/hdfs/name</value>
<final>true</final>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/home/gpadmin/hadoop/data/hdfs/data</value>
<final>true</final>
</property>
<property>
<name>dfs.http.address</name>
<value>gp-master:50070</value>
</property>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>gp-slave1:50090</value>
</property>
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
<property>
<name>dfs.permissions</name>
<value>false</value>
</property>
</configuration>

修改/home/gpadmin/hadoop/hadoop-2.6.0/etc/hadoop/mapred-site.xml


<?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>
</configuration>

修改/home/gpadmin/hadoop/hadoop-2.6.0/etc/hadoop/yarn-site.xml


<?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 -->
<property>
<name>yarn.resourcemanager.address</name>
<value>gp-master:18040</value>
</property>
<property>
<name>yarn.resourcemanager.scheduler.address</name>
<value>gp-master:18030</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address</name>
<value>gp-master:18088</value>
</property>
<property>
<name>yarn.resourcemanager.resource-tracker.address</name>
<value>gp-master:18025</value>
</property>
<property>
<name>yarn.resourcemanager.admin.address</name>
<value>gp-master:18141</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
</configuration>

修改/home/gpadmin/hadoop/hadoop-2.6.0/etc/hadoop/masters
gp-master

修改/home/gpadmin/hadoop/hadoop-2.6.0/etc/hadoop/slaves
gp-slave1
gp-slave2
gp-slave3

(6)运行hadoop,yarn
/home/gpadmin/hadoop/hadoop-2.6.0/bin/hadoop namenode -format
/home/gpadmin/hadoop/hadoop-2.6.0/sbin/start-all.sh
/home/gpadmin/hadoop/hadoop-2.6.0/sbin/stop-all.sh

http://192.168.119.130:50070/dfshealth.html
http://192.168.119.130:18088/cluster
/home/gpadmin/hadoop/hadoop-2.6.0/bin/hadoop dfsadmin -report