title: Hadoop2.7.2集群搭建
date: 2016-08-15 17:26:16
tags: Hadoop
categories: 大數(shù)據(jù)
四臺電腦集群
192.168.1.111 master
192.168.1.112 slave1
192.168.1.113 slave2
192.168.1.114 slave3
修改hosts
vim /etc/hosts
配置master到其它三臺slave的免密碼登陸
各服務(wù)器上使用 ssh-keygen -t rsa 一路按回車就行了。
剛才都作甚了呢叮喳?主要是設(shè)置ssh的密鑰和密鑰的存放路徑挠将。 路徑為~/.ssh下采盒。
打開~/.ssh 下面有三個文件
authorized_keys殿遂,已認證的keys
id_rsa袁稽,私鑰
id_rsa.pub腾夯,公鑰 三個文件堤撵。
下面就是關(guān)鍵的地方了纯续,(我們要做ssh認證随珠。進行下面操作前灭袁,可以先搜關(guān)于認證和加密區(qū)別以及各自的過程。)
①在master上將公鑰放到authorized_keys里窗看。命令:
sudo cat id_rsa.pub >> authorized_keys
②將master上的authorized_keys放到其他linux的~/.ssh目錄下简卧。命令:
sudo scp authorized_keys ubuntu@192.168.1.112:~/.ssh
sudo scp authorized_keys 遠程主機用戶名@遠程主機名或ip:存放路徑。
③修改authorized_keys權(quán)限烤芦,命令:chmod 644 authorized_keys
④測試是否成功
ssh slave1 輸入用戶名密碼举娩,然后退出,再次ssh slave1不用密碼构罗,直接進入系統(tǒng)铜涉。這就表示成功了。
安裝jdk1.7
mkdir /usr/java
sudo tar -zxvf jdk-7u79-linux-x64.tar.gz -C /usr/java
vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_79
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
- 刷新配置
source /etc/profile
- 測試
java -version
關(guān)閉每臺機器的防火墻
sudo ufw disable
(重啟生效)
創(chuàng)建/home/cloud目錄
mkdir ~/cloud
解壓hadoop
tar -zxvf hadoop-2.7.2.tar.gz -C ./cloud
配置hadoop-env.sh yarn-env.sh
修改JAVA_HOME值export JAVA_HOME=/usr/java/jdk1.7.0_79
創(chuàng)建文件夾
mkdir /home/ubuntu/cloud/hadoop-2.7.2/tmp
mkdir /home/ubuntu/cloud/hadoop-2.7.2/dfs/data
mkdir /home/ubuntu/cloud/hadoop-2.7.2/dfs/name
配置slaves
slave1
slave2
slave3
配置core-site.xml
<configuration>
<property>
<name>fs.defaultFS</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>file:/home/ubuntu/cloud/hadoop-2.7.2/tmp</value>
<description>Abase for other temporary directories.</description>
</property>
<property>
<name>hadoop.proxyuser.ubuntu.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.ubuntu.groups</name>
<value>*</value>
</property>
</configuration>
配置hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>master:9001</value>
</property>
<property>
<name>dfs.replication</name>
<value>4</value>
</property>
<property>
<name>dfs.permissions.enabled</name>
<value>false</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/home/ubuntu/cloud/hadoop-2.7.2/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/home/ubuntu/cloud/hadoop-2.7.2/dfs/data</value>
</property>
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
</configuration>
配置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>
配置yarn-site.xml
<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.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>
復(fù)制到其它節(jié)點
sudo scp -r /home/ubuntu/cloud ubuntu@slave1:~/
sudo scp -r /home/ubuntu/cloud ubuntu@slave2:~/
sudo scp -r /home/ubuntu/cloud ubuntu@slave3:~/
配置環(huán)境變量
vim /etc/profile
export HADOOP_HOME=/home/ubuntu/cloud/hadoop-2.7.2
export PATH=$PATH:${JAVA_HOME}/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:
啟動hadoop
- 格式化namenode
hadoop namenode –format
- 啟動hdfs
start-dfs.sh
- 啟動yarn
start-yarn.sh
- web端查看
http://master:8088 http://master:50070