参考文献:
http://blog.csdn.net/inkfish/article/details/5168676
http://493663402-qq-com.iteye.com/blog/1515275
http://www.cnblogs.com/syveen/archive/2013/05/08/3068044.html
http://www.cnblogs.com/kinglau/p/3794433.html
环境 :Vmware11下Ubuntu14.04 LTS, Hadoop2.7.1
一 :创建账户
1.创建hadoop组 及组下hadoop用户
[email protected]:~$ sudo addgroup hadoop
[email protected]:~$ sudo adduser --ingroup hadoop hadoop
2.添加到sudoers里面
[email protected]:~$ sudo gedit /etc/sudoers
如图
3.切换至hadoop用户
[email protected]:~$ su hadoop
二:安装配置SSH
1.从应用商店选择合适的源,比如阿里源
2.安装 openssh-server
[email protected]:/home/dogless$ sudo apt-get install openssh-server
3.启动ssh服务器
sudo /etc/init.d/ssh start
ps -e | grep ssh
4.修改为免密码登录
[email protected]:/home/dogless$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
[email protected]:/home/dogless$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
5.尝试登录与登出,两遍
三:安装JAVA
sudo apt-get install openjdk-7-jdk
四:安装配置Hadoop(单机)
1.在桌面解压Hadoop 2.7.1安装包
2.移动到/hadoop目录并赋予权限
[email protected]:/home/dogless/Desktop$ sudo mv hadoop-2.7.1 /hadoop [email protected]:/home/dogless/Desktop$ sudo chmod 777 /hadoop
五:配置环境变量
[email protected]:/home/dogless/Desktop$ sudo gedit /etc/profile
末尾追加 (特别注意JAVA_HOME和HADOOP_INSTALL路径)
#HADOOP
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH:$JRE_HOME/lib
export HADOOP_INSTALL=/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
更新环境
[email protected]:/home/dogless/Desktop$ source /etc/profile
六:测试
1.定位到程序目录,创建测试目录input,使用Readme做数据
[email protected]:/home/dogless/Desktop$ cd /hadoop [email protected]:/hadoop$ cp README.txt input
2.测试wordcount这个example,输出到output文件夹
[email protected]:/hadoop$ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar wordcount input output
测试成功
版权声明:本文为博主原创文章,未经博主允许不得转载。