Hadoop安装以及配置

Hadoop:
单机模式
伪分布模式
集群模式


==========================================================================
单机模式(开发测试模式,hadoop将以Java进程形式运行)
==========================================================================
1、去官网下载最新的hadoop:



2、安装JDK,配置好JDK环境变量
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_17
export CLASSPATH=.:$JAVA_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH

source /etc/profile

3、解压hadoop:
---------------------------------------
hadoop0.23.6版本配置

sudo tar -xzf hadoop0.23.6.tar.gz
cd /opt/apps/
ln -s /opt/app_install/hadoop0.23.6 hadoop
---------------------------------------
hadoop1.0.4版本配置

tar -zxvf hadoop-1.0.4.tar.gz
cd /opt/apps/
ln -s /opt/apps_install/hadoop-1.0.4 hadoop
---------------------------------------

4、创建hadoop的用户和用户组
(1)创建一个名为hadoop的用户组:
sudo addgroup hadoop
RedHat下面 groupadd hadoop
(2)创建一个名为hadoop的用户,归到hadoop用户组下
sudo adduser --ingroup hadoop hadoop
或redhat下面 useradd -ghadoop hadoop
(3)用gedit打开etc下的sudoers文件
sudo gedit /etc/sudoers
在 root ALL=(ALL) ALL 下面添加如下一行
hadoop ALL=(ALL) ALL

切换用户
su hadoop


5、创建ssh-key
(1)装载ssh服务
sudo apt-get install openssh-server
(2)创建ssh-key,为rsa
ssh-keygen -t rsa -P ""
(3)将此ssh-key添加到信任列表中,并启用此ssh-key
cat /home/hadoop/.ssh/id_rsa.pub >> /home/hadoop/.ssh/authorized_keys
sudo /etc/init.d/ssh reload


6、配置系统环境变量
---------------------------------------
hadoop0.23.6版本配置

export HADOOP_HOME=/opt/apps/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export YARN_CONF_DIR=$HADOOP_HOME/etc/hadoop
生效source /etc/profile
---------------------------------------
hadoop1.0.4版本配置

export HADOOP_INSTALL=/opt/apps/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
生效source /etc/profile
---------------------------------------

(已经可以运行开发测试模式,hadoop将以java进程形式运行)
测试:
hadoop jar hadoop-mapreduce-examples-0.23.6.jar wordcount firstTest result

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/9a9f781006d112624193565acef32aae.html