日期:2014-05-16  浏览次数:20722 次

Linux下安装hadoop的步骤
一、前期准备:
下载hadoop: http://hadoop.apache.org/core/releases.html
http://hadoop.apache.org/common/releases.html
http://www.apache.org/dyn/closer.cgi/hadoop/core/
http://labs.xiaonei.com/apache-mirror/hadoop/core/hadoop-0.20.1/hadoop-0.20.1.tar.gz
http://labs.xiaonei.com/apache-mirror/hadoop/
二、硬件环境
共有3台机器,均使用的CentOS,Java使用的是jdk1.6.0。

三、安装JAVA6
sudo apt-get install sun-java6-jdk

/etc/environment
打开之后加入:#中间是以英文的冒号隔开,记得windows中是以英文的分号做为分隔的
CLASSPATH=.:/usr/local/java/lib
JAVA_HOME=/usr/local/java


三、配置host表
[root@hadoop ~]# vi /etc/hosts
127.0.0.1 ? ? ? localhost
192.168.13.100 ? ? namenode
192.168.13.108 ? ? datanode1
192.168.13.110 ? ? datanode2

[root@test ~]# vi /etc/hosts
127.0.0.1 ? ? ? localhost
192.168.13.100 ? ? namenode
192.168.13.108 ? ? datanode1

[root@test2 ~]# vi /etc/host
127.0.0.1 ? ? ? localhost
192.168.13.100 ? ? namenode
192.168.13.110 ? ? datanode2
添加用户和用户组
addgroup hadoop
adduser ?hadoop
usermod -a -G hadoop hadoop
passwd hadoop

配置ssh:

服务端:
su hadoop
ssh-keygen ?-t ?rsa
cp id_rsa.pub authorized_keys

客户端
chmod 700 /home/hadoop
chmod 755 /home/hadoop/.ssh
su hadoop
cd /home
mkdir .ssh

服务端:
chmod 644 /home/hadoop/.ssh/authorized_keys
scp authorized_keys datanode1:/home/hadoop/.ssh/
scp authorized_keys datanode2:/home/hadoop/.ssh/

ssh datanode1
ssh datanode2

 如果ssh配置好了就会出现以下提示信息
The authenticity of host [dbrg-2] can't be established.
Key fingerpr is 1024 5f:a0:0b:65:d3:82:df:ab:44:62:6d:98:9c:fe:e9:52.
Are you sure you want to continue connecting (yes/no)?
  OpenSSH告诉你它不知道这台主机但是你不用担心这个问题你是第次登录这台主机键入“yes”这将把
这台主机“识别标记”加到“~/.ssh/know_hosts”文件中第 2次访问这台主机时候就不会再显示这条提示信


不过别忘了测试本机ssh dbrg-1
 


mkdir /home/hadoop/HadoopInstall
tar -zxvf hadoop-0.20.1.tar.gz -C /home/hadoop/HadoopInstall/
cd /home/hadoop/HadoopInstall/
ln ?-s ?hadoop-0.20.1 ?hadoop

export JAVA_HOME=/usr/local/java
export CLASSPATH=.:/usr/local/java/lib
export HADOOP_HOME=/home/hadoop/HadoopInstall/hadoop
export HADOOP_CONF_DIR=/home/hadoop/hadoop-conf
export PATH=$HADOOP_HOME/bin:$PATH

cd $HADOOP_HOME/conf/
mkdir /home/hadoop/hadoop-conf
cp hadoop-env.sh core-site.xml hdfs-site.xml mapred-site.xml masters slaves /home/hadoop/hadoop-conf

vi $HADOOP_HOME/hadoop-conf/hadoop-env.sh


# The java implementation to use. ?Required. --修改成你自己jdk安装的目录
export JAVA_HOME=/usr/local/java?
?
export ?HADOOP_CLASSPATH=.:/usr/local/java/lib
# The maximum amount of heap to use, in MB. Default is 1000.--根据你的内存大小调整
export HADOOP_HEAPSIZE=200 ? ? ? ? ?

vi /home/hadoop/.bashrc
export JAVA_HOME=/usr/local/java
export CLASSPATH=.:/usr/local/java/lib
export HADOOP_HOME=/home/hadoop/HadoopInstall/hadoop
export HADOOP_CONF_DIR=/home/hadoop/hadoop-conf
export PATH=$HADOOP_HOME/bin:$PATH