一、在Ubuntu下創建hadoop用戶組合hadoop用戶
1、創建hadoop用戶組
addgroup hadoop
2、創建hadoop用戶
adduser -ingroup hadoop hadoop
3、為hadoop用戶添加權限
vim /etc/sudoers
4、切換到hadoop用戶
su - hadoop
二、ssh安裝與設置
1、安裝ssh
sudo apt-get install openssh-server
2、啟動服務
sudo /etc/init.d/ssh start
3、查看啟動
ps -e | grep ssh
4、設置免密碼登錄,生成私鑰與公鑰
ssh-keygen -t rsa -P ""
此時會在/home/hadoop/.ssh下生成兩個文件:id_rsa和id_rsa.pub,前者為私鑰,后者為公鑰。
將公鑰追加到authorized_keys中,它用戶保存所有允許以當前用戶身份登錄到ssh客戶端用戶的公鑰內容。
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
5、ssh登錄
ssh localhost
6、退出登錄
exit
三、安裝java環境
1、安裝java
sudo apt-get install openjdk-7-jdk
2、查看java版本
java -version
3、查看java安裝路徑
update-alternative --config java
四、安裝hadoop2.7.1
1、下載hadoop2.7.1.tar.gz
2、解壓:sudo tar xzf hadoop-2.7.1.tar.gz
3、復制到:sudo mv hadoop-2.7.1 /usr/local/hadoop
4、權限設置:sudo chmod 774 /usr/local/hadoop
5、配置.bashrc文件
#HADOOP VARIABLES START export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 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
6、環境變量生效
source ~/.bashrc
7、編輯/usr/local/hadoop/etc/hadoop/hadoop-env.sh
五、驗證測試
1、/usr/local/hadoop路徑下創建input文件夾
2、拷貝README.txt到input
3、執行WordCount
bin/hadoop jar share/hadoop/mapreduce/sources/hadoop-mapreduce-examples-2.4.0-sources.jar org.apache.hadoop.examples.WordCount input output
六、結果演示
