资源准备
- 准备4台 Linux 服务器要求:glibc 版本 >= 2.14
- 192.168.9.1
- 192.168.9.2
- 192.168.9.3
- 192.168.9.4
- 安装配置 JDK1.7+(详细操作)
- 下载:hadoop-2.6.4
服务器配置
- 4台服务器分别创建用户hadoop
root@XXX# useradd hadoop
root@XXX# echo 'hadoop' | passwd --stdin hadoop
- 4台服务器分别配置 hosts
root@XXX# vi /etc/hosts
添加内容如下:
192.168.9.1 master
192.168.9.2 secmaster
192.168.9.3 slave0
192.168.9.4 slave1
- master 主机免密码登陆其他主机配置
- 在各个主机上生成 SSH 密钥
hadoop@XXX$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
- 在 master 主机上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公钥成功
- 测试ssh免登陆
在192.168.9.1主机上执行如下命令确保 master 可以实现对其他主机的免密码登陆,首次执行需要输入"yes" 确认
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) 主机上解压 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向各个节点同步配置完毕后的 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,启动 hadoop 所有组件
[hadoop@192.168.9.1hadoop2.6.4]$ bin/hadoop namenode -format
[hadoop@192.168.9.1hadoop2.6.4]$ sbin/start-all.sh
网友评论