ubuntu安装hadoop(单机)

参考 kinglau  —   一、Ubuntu14.04下安装Hadoop2.4.0 (单机模式

1.创建hadoop用户

1.1创建hadoop用户组

$ sudo addgroup hadoop

1.2 创建hadoop用户

$ sudo adduser -ingroup hadoop hadoop

1.3 为hadoop用户添加管理员权限

$ sudo gedit /etc/sudoers
# 添加root相同权限
# #User priveilege specification
# hadoop ALL=(ALL:ALL) ALL

2. hadoop用户登录系统

3. 安装ssh

3.1 安装ssh

$ sudo apt-get install openssh-server
$ sudo /etc/init.d/ssh start
$ ps -e | grep ssh
# 2153 ?  00:00:00 ssh-agent
# 4046 ?  00:00:00 ssh-agent
# 6216 ?  00:00:00 sshd

3.2 免密码登录

$ ssh-keygen -t rsa -P ""
# ssh-keygen
$ cd /home/hadoop/.ssh
$ ls
# id_rsa 私钥 id_rsa.pub 公钥
$ cat id_rsa.pub >> ~ authorized_keys
$ ssh localhost
$ exit

4. 安装JDK

$ sudo apt-get install openjdk-7-jdk
$ java -version

5. 安装hadoop

5.1 下载

# http://www.apache.org/dyn/closer.cgi/hadoop/common/

5.2 安装

$ sudo tar xzf hadoop-x.x.x.tar.gz
$ sudo mv hadoop-x.x.x /usr/local/hadoop
$ sudo chmod 774 /usr/local/hadoop

5.3 配置

$ update-alternatives --config java
# There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java
# Nothing to configure.
# we get JAVA_HOME as /usr/lib/jvm/java-7-openjdk-i386
$ sudo gedit ~/.bashrc
# 文件末尾追加
#HADOOP VARIABLES START
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
#HADOOP VARIABLES END
$ source ~/.bashrc
# hadoop-2.x.x
$ sudo gedit /usr/local/hadoop/etc/hadoop/hadoop-env.sh
# hadoop-1.x.x
$ sudo gedit /usr/local/hadoop/conf/hadoop-env.sh
# 修改 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386

6. WordCount 测试

$ cd /usr/local/hadoop
$ mkdir input
$ cp README.txt input
# hadoop-2.x.x $ bin
/hadoop jar share/hadoop/mapreduce/sources/hadoop-mapreduce-examples-2.x.x-sources.jar org.apache.hadoop.examples.WordCount input output
# hadoop-1.x.x
$ bin/hadoop jar  hadoop-examples-1.x.x.jar wordcount input output $ cat output
/*

 

posted on 2015-04-21 15:34  Erbin  阅读(267)  评论(0编辑  收藏  举报

导航