标签:
最近闲来无事搭建了一个hadoop环境,将搭建步骤记录一下。
一.环境准备
环境:VMware,xshell
OS: Ubuntu server(选择最简安装,只安装OpenSSH-Server)
版本:hadoop-2.6.0
三个节点:
192.168.16.131 master
192.168.16.132 node1
192.168.16.133 node2
将节点信息添加进去(如上)
groupadd hadoop //设置hadoop用户组
useradd –s /bin/bash –d /home/wh –m wh –g hadoop –G admin //添加一个wh用户,此用户属于hadoop用户组,且具有admin权限。
passwd wh //设置用户zhm登录密码
su wh //切换到wh用户中
chmod u+w /etc/sudoers
vim /etc/sudoers (添加如下东西)
wh ALL=(ALL:ALL) ALL
chmod u-w /etc/sudoers
`二.安装jdk(选择7)
1.安装
apt-get install openjdk-7-jdk
2.环境配置
vim .bashrc
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64(默认安装位置)
chmod u+w /etc/profile(给予修改权限)
vim /etc/profile
#末尾添加以下配置:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
chmod u-w /etc/profile(权限回收)
java -version
三.SSH无密码登录
1.生成master公匙
ssh-keygen -t dsa -P ‘‘ -f ~/.ssh/id_dsa
cd .ssh
2.让 节点需能无密码 SSH 本机,在 节点上执行:
cat id_rsa.pub >> authorized_keys
3.使用ssh localhost检查是否能登录自身(三个都用)
4.使用master节点ssh另外两个节点
在node1,node2节点执行:
scp wh@master:~/.ssh/id_dsa.pub ./master_dsa.pub
cat master_dsa.pub >> authorized_keys
5.测试是否成功
ssh node1(node2)
注意:第一次需要输入node1(node2)节点密码,第二次不用。
四.配置hadoop-2.6.0
下载hadoop-2.6.0:http://pan.baidu.com/s/1c24XcEs
通过Xftp将文件从windows传入Ubuntu 解压到/home/wh下
修改core-site.xml(都在/home/wh/hadoop/etc/hadoop/下):
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://master:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/home/wh/hadoop/tmp</value>
<description>Abase for other temporary directories.</description>
</property>
</configuration>
<configuration>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>master:50090</value>
</property>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/home/wh/hadoop/tmp/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/home/wh/hadoop/tmp/dfs/data</value>
</property>
</configuration>
<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>
<configuration>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>master</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
node1
node2
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
tar -zcf ~/hadoop.master.tar.gz ./hadoop
scp ./hadoop.master.tar.gz node1:/home/wh
sudo tar -zxf ~/hadoop.master.tar.gz -C /home/wh
bin/hdfs namenode -format
sbin/start-dfs.sh
sbin/start-yarn.sh
sbin/mr-jobhistory-daemon.sh start historyserver
五.运行hadoop实例
bin/hdfs dfs -mkdir -p /user/wh
bin/hdfs dfs -mkdir input
bin/hdfs dfs -put /home/wh/hadoop/etc/hadoop/*.xml input
hadoop jar /home/wh/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar grep \ input output ‘dfs[a-z.]+‘
六.关闭hadoop
sbin/stop-yarn.sh
sbin/stop-hdfs.sh
sbin/mr-jobhistory-daemon.sh stop historyserver
标签:
原文地址:http://blog.csdn.net/svmachine/article/details/51334188