前面的文章讲解了hadoop-2.2.0在64位linux系统下的编译步骤,以及zookeeper集群的部署,这篇主要写hadoop集群的部署,因为关于这方面的资料比较多这里就写主要的步骤:
1:主机对应关系
centos01 | 192.168.6.180(master) |
centos02 | 192.168.6.181(slave) |
centos03 | 192.168.6.182(slave) |
centos04 | 192.168.6.183(slave) |
centos05 | 192.168.6.184(slave) |
centos06 | 192.168.6.185(slave) |
2:主要配置文件:
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>fs.default.name</name> <value>hdfs://192.168.6.180:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/data/soft/hadoop/hadoop-2.2.0/tmp</value> </property> </configuration>
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>1</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>/data/soft/hadoop/hadoop-2.2.0/nddir</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>/data/soft/hadoop/hadoop-2.2.0/dddir</value> </property> <property> <name>dfs.permissions</name> <value>false</value> </property> </configuration>
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>mapred.job.tracker</name> <value>centos01:8021</value> <final>true</final> <description>The host and port that the MapReduce JobTracker runs at. </description> </property> <property> <name>mapreduce.cluster.temp.dir</name> <value></value> <description>No description</description> <final>true</final> </property> <property> <name>mapreduce.cluster.local.dir</name> <value></value> <description>No description</description> <final>true</final> </property> </configuration>
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> <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> <property> <name>Yarn.nodemanager.aux-services</name> <value>mapreduce.shuffle</value> </property> <property> <name>yarn.resourcemanager.address</name> <value>centos01:8032</value> </property> <property> <name>yarn.resourcemanager.scheduler.address</name> <value>centos01:8030</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address</name> <value>centos01:8031</value> </property> <property> <name>yarn.resourcemanager.admin.address</name> <value>centos01:8033</value> </property> <property> <name>yarn.resourcemanager.webapp.address</name> <value>centos01:8088</value> </property> </configuration>
slaves
centos02 centos03 centos04 centos05 centos06
3:准备工作
配置SSH免登陆(ssh-keygen -t rsa / ssh-coyp-id -i itcast0x)
配置java环境变量
修改上面的配置文件
分发到从机 scp -r xxx centos0x:/xxx
格式化namenode,hadoop namenode -format
启动集群sbin/start-all.sh
4:结束
上传一个文件:hadoop fs -put /etc/profile /data
启动测试jar:
hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.2.0.jar wordcount /data /out
查看集群界面: http://192.168.6.180:8088