資源準(zhǔn)備
- 準(zhǔn)備4臺(tái) Linux 服務(wù)器要求:glibc 版本 >= 2.14
- 192.168.9.1
- 192.168.9.2
- 192.168.9.3
- 192.168.9.4
- 安裝配置 JDK1.7+(詳細(xì)操作)
- 下載:hadoop-2.6.4
服務(wù)器配置
- 4臺(tái)服務(wù)器分別創(chuàng)建用戶hadoop
root@XXX# useradd hadoop
root@XXX# echo 'hadoop' | passwd --stdin hadoop
- 4臺(tái)服務(wù)器分別配置 hosts
root@XXX# vi /etc/hosts
添加內(nèi)容如下:
192.168.9.1 master
192.168.9.2 secmaster
192.168.9.3 slave0
192.168.9.4 slave1
- master 主機(jī)免密碼登陸其他主機(jī)配置
- 在各個(gè)主機(jī)上生成 SSH 密鑰
hadoop@XXX$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
- 在 master 主機(jī)上copy公鑰
hadoop@192.168.9.1$ ssh-copy-id -i secmaster 輸入密碼:hadoop即copy公鑰成功
hadoop@192.168.9.1$ ssh-copy-id -i slave0 輸入密碼:hadoop即copy公鑰成功
hadoop@192.168.9.1$ ssh-copy-id -i slave1 輸入密碼:hadoop即copy公鑰成功
- 測(cè)試ssh免登陸
在192.168.9.1主機(jī)上執(zhí)行如下命令確保 master 可以實(shí)現(xiàn)對(duì)其他主機(jī)的免密碼登陸偏形,首次執(zhí)行需要輸入"yes" 確認(rèn)
hadoop@192.168.9.1$ ssh secmaster
hadoop@192.168.9.1$ ssh slave0
hadoop@192.168.9.1$ ssh slave1
hadoop自身配置
- 在 master(192.168.9.1) 主機(jī)上解壓 hadoop-2.6.4.tar.gz
hadoop@192.168.9.1$ tar xvf hadoop-2.6.4.tar.gz
- 配置 etc/hadoop/core-site.xml
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://master:9000</value>
</property>
<property>
<name>io.file.buffer.size</name>
<value>131072</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/tmp</value>
</property>
<property>
<name>hadoop.proxyuser.u0.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.u0.groups</name>
<value>*</value>
</property>
</configuration>
- 配置 etc/hadoop/hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>secmaster:9001</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/home/hadoop/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/home/hadoop/dfs/data</value>
</property>
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
</configuration>
- 配置 etc/hadoop/mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.jobhistory.address</name>
<value>master:10020</value>
</property>
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>master:19888</value>
</property>
</configuration>
- 配置etc/hadoop/yarn-site.xml
<configuration>
<!-- Site specific YARN configuration properties -->
<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.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>
</configuration>
Master向各個(gè)節(jié)點(diǎn)同步配置完畢后的 hadoop 工程
hadoop@192.168.9.1$ scp -r /home/hadoop/hadoop-2.6.4 hadoop@secmaster:/home/hadoop
hadoop@192.168.9.1$ scp -r /home/hadoop/hadoop-2.6.4 hadoop@slave0:/home/hadoop
hadoop@192.168.9.1$ scp -r /home/hadoop/hadoop-2.6.4 hadoop@slave1:/home/hadoop
格式化 namenode歪沃,啟動(dòng) hadoop 所有組件
[hadoop@192.168.9.1hadoop2.6.4]$ bin/hadoop namenode -format
[hadoop@192.168.9.1hadoop2.6.4]$ sbin/start-all.sh