工欲善其事,必先利其器,啥都不说,Hadoop下载:http://archive.cloudera.com/cdh5/cdh/5/ 选择好相应版本搞起,在本文讲述的是 围绕hadoop-2.3.0-cdh5.1.2版本安装过程。(安装环境为自己在VMWare 10里面搭建的三台 Linux 虚拟机)。
1、hadoop 是大apache开源的分布式离线计算框架,语言:java,既然这样,要想搭建hadoop环境(不管伪分布式 还是多机集群),那必须在服务器上安装好jdk。
简单过程简单说,简要描述下jdk安装配置过程(据说,hadoop-2.3.0需要jdk1.7+版本支持,咱也不管了,那就装吧,版本:jdk-7u67-linux-i586.tar.gz,安装新jdk之前记得找到linux自带的jdk版本并删除,不明白处自百之)
Ubuntu 12.04下安装JDK1.7 http://www.linuxidc.com/Linux/2012-06/62239.htm
CentOS6.3安装JDK和环境配置 http://www.linuxidc.com/Linux/2012-09/70780.htm
Ubuntu14.04 64位 安装JDK1.7 http://www.linuxidc.com/Linux/2015-01/111102.htm
a、解压到/usr/java目录下
tar xvf jdk-7u67-linux-i586.tar.gz -C /usr/java
b、 vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_67
export CLASSPATH=/usr/java/jdk1.7.0_67/lib
export PATH=$JAVA_HOME/bin:$PATH
c、source /etc/profile //不重启服务器情况下,这句让配置文件生效
d、java -version //验证jdk是否正确安装
2、我们先规划好三台机,并制定好 三台机之后的角色:
主机名 ip 角色
master 192.168.140.128 NameNode ResourceManager
slave1 192.168.140.129 DateNode NodeManager
slave2 192.168.140.130 DateNode NodeManager
3、修改 主机名:
root 权限下:vi /etc/sysconfig/network
修改内容:HOSTNAME=master (同理 两台slave主机也要修改此配置,并分配相应的名字)
同时 vi /etc/hosts ( 同理 两台slave主机也要修改此配置,并分配相应的hosts对应关系)
127.0.0.1 master
192.168.140.129 slave1
192.168.140.130 slave2
修改完重启:reboot
4、建立hadoop用户(包括两台slave):
useradd hadoop
passwd hadoop
5、master上配置SSH免密码登录
su hadoop //切换到hadoop用户目录下
ssh-keygen-t rsa(一路回车 生成密钥)
cd/home/hadoop/.ssh/
ls //查看是否有生成两个文件 id_rsa.pub id_rsa
6、同步ssh信息到两台slave, 登录两台slave
mkdir /home/hadoop/.ssh
scp id_rsa.pub hadoop@slave1:/home/hadoop/.ssh/
mv id_rsa.pub authorized_keys
7、新建hadoop安装目录 (root权限下操作)
mkdir -p /data/hadoop
8、 解压下载下来的hadoop安装包到安装目录(root权限下操作)
tar xvf hadoop-2.3.0-cdh5.1.2.tar.gz -C/data/hadoop
9、将安装目录权限赋予给 hadoop用户:(root权限下操作)
chown -R hadoop.hadoop /data/hadoop/
10、配置hadoop安装信息和路径(root权限下操作)
vi /etc/profile (在最后加上下面内容)
export HADOOP_HOME=/data/hadoop
export PATH=$HADOOP_HOME/bin:$JAVA_HOME/bin:$PATH
source /etc/profile //让配置生效
11、master上/data/hadoop/etc/hadoop
vi slaves
slave1
slave2
vi masters
master
12、修改如下几个文件,并在中间添加以下相应内容:
a、vi 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:/data/hadoop/tmpvalue>
</property>
</configuration>
b、vi hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/data/hadoop/dfs/name</value>
</property>
<property>
<name>dfs.namenode.data.dir</name>
<value>file:/data/hadoop/dfs/data</value>
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
</configuration>
c、vi yarn-site.xml
<configuration>
<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>
<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>
</configuration>
d、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>
至此 配置文件基本配置完毕。
13、将master上的hadoop安装文件同步到slave1 slave2,(hadop用户权限下即可)
cd /data/hadoop
scp -r /data/hadoop/*hadoop@slave1:/data/hadoop/ //同步到slave1
scp -r /data/hadoop/*hadoop@slave2:/data/hadoop/ //同步到slave2
14、最后我们来到 /data/hadoop/bin目录下
./hadoop namenode -format //启动hadoop
15、如果没有报错信息,基本是可以说 hadoop起来了,随便截取了最后几段日志:
15/01/13 18:08:10 INFO util.GSet:VM type = 32-bit
15/01/13 18:08:10 INFO util.GSet:0.25% max memory 966.7 MB = 2.4 MB
15/01/13 18:08:10 INFO util.GSet:capacity = 2^19 = 524288 entries
15/01/13 18:08:10 INFOnamenode.FSNamesystem: dfs.namenode.safemode.threshold-pct = 0.9990000128746033
15/01/13 18:08:10 INFOnamenode.FSNamesystem: dfs.namenode.safemode.min.datanodes = 0
15/01/13 18:08:10 INFOnamenode.FSNamesystem: dfs.namenode.safemode.extension = 30000
15/01/13 18:08:10 INFOnamenode.FSNamesystem: Retry cache on namenode is enabled
15/01/13 18:08:10 INFOnamenode.FSNamesystem: Retry cache will use 0.03 of total heap and retry cacheentry expiry time is 600000 millis
15/01/13 18:08:10 INFO util.GSet:Computing capacity for map NameNodeRetryCache
15/01/13 18:08:10 INFO util.GSet:VM type = 32-bit
15/01/13 18:08:10 INFO util.GSet:0.029999999329447746% max memory 966.7 MB = 297.0 KB
15/01/13 18:08:10 INFO util.GSet:capacity = 2^16 = 65536 entries
15/01/13 18:08:10 INFOnamenode.AclConfigFlag: ACLs enabled? false
Re-format filesystem in StorageDirectory /data/hadoop/dfs/name ? (Y or N) Y
15/01/13 18:08:17 INFOnamenode.FSImage: Allocated new BlockPoolId:BP-729401054-127.0.0.1-1421143697660
15/01/13 18:08:17 INFOcommon.Storage: Storage directory /data/hadoop/dfs/name has been successfullyformatted.
15/01/13 18:08:18 INFOnamenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
15/01/13 18:08:18 INFOutil.ExitUtil: Exiting with status 0
15/01/13 18:08:18 INFOnamenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting downNameNode at master/127.0.0.1
************************************************************/
程序员干久了,性格沉闷,言辞干瘪,简单的描述只为做个记录,多多指教。
CentOS安装和配置Hadoop2.2.0 http://www.linuxidc.com/Linux/2014-01/94685.htm
Ubuntu 13.04上搭建Hadoop环境 http://www.linuxidc.com/Linux/2013-06/86106.htm
Ubuntu 12.10 +Hadoop 1.2.1版本集群配置 http://www.linuxidc.com/Linux/2013-09/90600.htm
Ubuntu上搭建Hadoop环境(单机模式+伪分布模式) http://www.linuxidc.com/Linux/2013-01/77681.htm
Ubuntu下Hadoop环境的配置 http://www.linuxidc.com/Linux/2012-11/74539.htm
单机版搭建Hadoop环境图文教程详解 http://www.linuxidc.com/Linux/2012-02/53927.htm
搭建Hadoop环境(在Winodws环境下用虚拟机虚拟两个Ubuntu系统进行搭建) http://www.linuxidc.com/Linux/2011-12/48894.htm
更多Hadoop相关信息见Hadoop 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=13
摘自永久更新链接地址:http://www.linuxidc.com/Linux/2015-01/111740.htm