现在的位置: 首页 > 云计算 > 正文

Hadoop分布式安装

2013年05月01日 云计算 ⁄ 共 3776字 ⁄ 字号 评论关闭

一、安装准备

1、下载hadoop 0.20.2,地址:http://www.apache.org/dist/hadoop/core/hadoop-0.20.2/

2、JDK版本:jdk-6u20-linux-i586.bin (必须是1.6)

3、操作系统:Linux s132 2.6.9-78.8AXS2smp #1 SMP Tue Dec 16 02:42:55 EST 2008 x86_64 x86_64 x86_64 GNU/Linux

4、三台机器,192.168.3.131(master),192.168.3.132(slave),192.168.3.133(slave)

二、安装操作

1、拷贝以上文件到Linux的“/root”目录下。同时新建目录“/jz”。

2、安装JDK,此步省略...

3、解压hdaoop到/jz目录下。tar -zxvf hbase-0.20.5.tar.gz -C /jz

4、配置131机器可以通过SSH直接访问132和133。

在131上执行以下操作:
$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa ,
直接回车,完成后会在~/.ssh/生成两个文件:id_dsa 和id_dsa.pub。这两个是成对出现,类似钥匙和锁。再把id_dsa.pub 追加到授权key 里面(当前并没有authorized_keys文件):
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys。
完成后可以实现无密码登录本机:
$ ssh localhost。
把131上的id_dsa.pub 文件追加到132和133的authorized_keys 内( 以192.168.3.132节点为例):
a. 拷贝131的id_dsa.pub文件:
$ scp id_dsa.pub s132@192.168.3.132:/root/
b. 登录192.168.3.132,进入/root目录执行:
$ cat id_dsa.pub >> .ssh/authorized_keys
之后可以在131上不输入密码直接访问132

5、修改/jz/hadoop-0.20.2/conf/目录下的master文件,内容如下:

192.168.3.131
6、修改/jz/hadoop-0.20.2/conf/目录下的slaves文件,内容如下:
192.168.3.132
192.168.3.133
7、修改/jz/hadoop-0.20.2/conf/hadoop-env.sh文件的环境变量:
# The java implementation to use.  Required.
export JAVA_HOME=/usr/java/jdk1.6.0_20
8、修改/jz/hadoop-0.20.2/conf/core-site.xml配置文件,内容如下:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
  <name>hadoop.tmp.dir</name>
  <value>/hadoopdata</value>
  <description>A base for other temporary directories.</description>
</property>

<property>
  <name>fs.default.name</name>
  <value>hdfs://m131:9000</value>
  <description>The name of the default file system.  A URI whose
  scheme and authority determine the FileSystem implementation.  The
  uri's scheme determines the config property (fs.SCHEME.impl) naming
  the FileSystem implementation class.  The uri's authority is used to
  determine the host, port, etc. for a filesystem.</description>
</property>

<property>
  <name>dfs.hosts.exclude</name>
  <value>excludes</value>
</property>
</configuration>
9、修改/jz/hadoop-0.20.2/conf/hdfs-site.xml配置文件,内容如下:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
10、修改/jz/hadoop-0.20.2/conf/mapred-site.xml配置文件,内容如下:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
  <name>mapred.job.tracker</name>
  <value>m131:9001</value>
  <description>The host and port that the MapReduce job tracker runs
  at.  If "local", then jobs are run in-process as a single map
  and reduce task.
  </description>
</property>
</configuration>
11、修改ect/hosts配置文件,内容如下:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost
192.168.3.131 m131
192.168.3.132 s132
192.168.3.133 s133
12、修改/ect/profile配置文件,在末尾追加以下内容,并输入source/etc/profile使之生效:
export JAVA_HOME=/usr/java/jdk1.6.0_20

export JRE_HOME=/usr/java/jdk1.6.0_20/jre

export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH

export PATH=$JAVA_HOME/bin:$PATH

export HADOOP_HOME=/jz/hadoop-0.20.2

export PATH=$HADOOP_HOME/bin:$PATH

export PATH=$PATH:$HIVE_HOME/bin
13、将/jz/hadoop-0.20.2拷贝到192.168.3.132和192.168.3.133对应的目录下。将/ect/profile和/etc/hosts也拷贝到132和133机器上。注意profile需要做生效操作。
三、启动/停止hadoop
1、通过shell脚本启动hadoop。
sh /jz/hadoop-0.20.2/bin/start-all.sh
2、停止hadoop
sh /jz/hadoop-0.20.2/bin/stop-all.sh

 

 

 

 

 

 

 

 

 

 

 

四、初始配置

1、格式化HDFS文件系统。进入/jz/hadoop-0.20.2/bin目录。执行:

hadoop namenode –format
2、在/jz/hadoop-0.20.2/bin目录下,执行:
hadoop fs -ls /
如果控制台返回结果,表示初始化成功。可以向里面录入数据。
3、通过WEB查看hadoop
查看集群状态 http://192.168.3.131:50070/dfshealth.jsp
查看JOB状态 http://192.168.3.131:50030/jobtracker.jsp

五、注意事项

1、hadoop的安装千万计的修改/etc/hosts文件。修改之后最好是重启机器。

2、master和slaves这2个配置文件可以不拷贝到s132和s133机器上,只在master上保存即可。

3、通过web查看hadoop的时候,如果使用IE一些图形工具显示不出来,建议使用opera或是chrome。

4、如果有些错的地方或是不清楚的地方可以发邮件交流:dajuezhao@gmail.com

【上篇】
【下篇】

抱歉!评论已关闭.