hadoop安装与配置

一、安装准备

1、下载hadoop 0.21.0,地址:http://mirror.bjtu.edu.cn/apache/hadoop/core/hadoop-0.21.0/hadoop-0.21.0.tar.gz

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

3、操作系统:ubuntu10.10

4、三台机器,192.168.2.27master+ slave),192.168.3.28slave),192.168.3.29slave

二、安装操作

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

2、安装JDK:

执行代码:
jdk-6u22-linux-i586.bin

会出现字幕,持续按回车键,直到屏幕出现需要输入yes/no,此时输入yes/y 回车,将会把JDK解压到文件夹,得到jdk1.6.0_22.此时JDK安装完毕。下面进行配置。
执行代码:
sudo gedit /etc/environment

environment中修改如下信息:
PATH="........:/home/yuxl/jdk1.6.0_22/bin"
CLASSPATH=".:/home/yuxl/jdk1.6.0_22/lib"
JAVA_HOME="/home/yuxl/jdk1.6.0_22"

ubuntu中有默认jdk还需要执行如下工作
执行代码:
sudo update-alternatives --install /usr/bin/java java /home/yuxl/jdk1.6.0_22/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /home/yuxl/jdk1.6.0_22/bin/javac 300

通过 这一步将我们安装的JDK加入java选单
然后执行代码:
sudo update-alternatives --config java

过这一步设置系统默认的JDK
然后在shell中执行代码:
java -version
此时显示的系统中的java就是刚刚安装的 java

3、解压hdaoop/yuxl目录下。tar –zxvf  hadoop-0.21.0.tar.gz  -C /yuxl

4、配置27机器可以通过SSH无密码访问2829:

27上执行以下操作:
$ 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
27上的id_dsa.pub 文件追加到2829authorized_keys ( 192.168.2.28节点为例)
a. 拷贝27id_dsa.pub文件:
$ scp id_dsa.pub 192.168.2.28:/root/
b. 登录192.168.2.28,进入/root目录执行:
$ cat id_dsa.pub >> .ssh/authorized_keys
之后可以在27上不输入密码直接访问28

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

192.168.2.27
 
6、修改/yuxl/hadoop-0.21.0/conf/目录下的slaves文件,内容如下:
192.168.2.27(同时为namenodedatanode)
192.168.2.28
192.168.2.29
 
7、修改/yulx/hadoop-0.21.0/conf/hadoop-env.sh文件的环境变量:
# The java implementation to use.  Required.
export JAVA_HOME=/home/yuxl/jdk1.6.0_22
8、修改/yuxl/hadoop-0.21.0/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://192.168.2.27: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、修改/yuxl/hadoop-0.21.0/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>192.168.2.27: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.2.27 机器名
192.168.2.28 机器名
192.168.2.29机器名
12、修改/ect/profile配置文件,在末尾追加以下内容,并输入source/etc/profile使之生效:
export JAVA_HOME=/home/yuxl/jdk1.6.0_22
 
export JRE_HOME=/home/yuxl/jdk1.6.0_22/jre
 
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
 
export PATH=$JAVA_HOME/bin:$PATH
 
export HADOOP_HOME=/home/yuxl/hadoop-0.21.0
 
export PATH=$HADOOP_HOME/bin:$PATH
 
export PATH=$PATH:$HIVE_HOME/bin
 
13、将/jz/hadoop-0.20.2拷贝到192.168.3.132192.168.3.133对应的目录下。将/ect/profile/etc/hosts也拷贝到132133机器上。注意profile需要做生效操作。

三、启动/停止hadoop

1、通过shell脚本启动hadoop
sh /yuxl/hadoop-0.21.0/bin/start-all.sh
2、停止hadoop
sh /yuxl/hadoop-0.21.0/bin/stop-all.sh

四、初始配置

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

五、注意事项

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

2masterslaves2个配置文件可以不拷贝到s132s133机器上,只在master上保存即可。

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值