【環境】:
html
常常遭遇由於依賴軟件版本不匹配致使的問題,此次大意了,覺得java問題不大,就用原本經過yast安裝的java1.6 openjdk去搞了,結果可想而知,問題不少,反覆定位,反覆谷歌百度,最後一朋友啓發下決定換換jdk版本。問題解決了,因此這裏貼下個人環境java
java環境: java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)node
系統: openSUSE 11.2 (x86_64)linux
hadoop版本:Hadoop-1.1.2.tar.gzshell
【Step1:】建立hadoop用戶及用戶組
ssh
組:hadoop oop
用戶:hadoop -> /home/hadoopui
加權限: vi /etc/sudoers 增長 hadoop ALL=(ALL:ALL) ALLspa
【Stpe2:】安裝hadoop.net
筆者tar xf 安裝完後是這樣的目錄結構(供參考):
/home/hadoop/hadoop-home/[bin|conf]
【Step3:】配SSH(避免啓動hadoop時須要密碼)
略安裝ssh
ssh-keygen -t rsa -P "" [一路回車及確認]
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
嘗試 ssh localhost [檢查下是否是不須要密碼啦]
【Step4:】安裝java
版本見【環境】部分
【Step5:】配conf/hadoop-env.sh
export JAVA_HOME=/usr/java/jdk1.7.0_17xxx #[jdk目錄]
export HADOOP_INSTALL=/home/hadoop/hadoop-home
export PATH=$PATH:$HADOOP_INSTALL/bin #[這裏是hadoop腳本所在目錄]
【Step6:】使用單機模式
hadoop version
mkdir input
man find > input/test.txt
hadoop jar hadoop-examples-1.1.2.jar wordcount input output
【Step7:】僞分佈模式(單機實現namenode,datanode,tackerd等模塊)
conf/[core-site.xml、hdfs-site.xml、mapred-site.xml]
core-site.xml
<configuration> <property> <name>fs.default.name</name> <value>hdfs://localhost:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/usr/local/hadoop/tmp</value> </property> </configuration>
hdfs-site.xml
<configuration> <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.name.dir</name> <value>/usr/local/hadoop/datalog1,/usr/local/hadoop/datalog2</value> </property> <prop<configuration> <property> <name>mapred.job.tracker</name> <value>localhost:9001</value> </property> </configuration>erty> <name>dfs.data.dir</name> <value>/usr/local/hadoop/data1,/usr/local/hadoop/data2</value> </property> </configuration>
mapred-site.xml
<configuration> <property> <name>mapred.job.tracker</name> <value>localhost:9001</value> </property> </configuration>
【Step8:】啓動
格式化:hadoop namenode -format
cd bin
sh start-all.sh
hadoop@linux-peterguo:~/hadoop-home/bin> sh start-all.sh starting namenode, logging to /home/hadoop/hadoop-home/libexec/../logs/hadoop-hadoop-namenode-linux-peterguo.out localhost: starting datanode, logging to /home/hadoop/hadoop-home/libexec/../logs/hadoop-hadoop-datanode-linux-peterguo.out localhost: starting secondarynamenode, logging to /home/hadoop/hadoop-home/libexec/../logs/hadoop-hadoop-secondarynamenode-linux-peterguo.out starting jobtracker, logging to /home/hadoop/hadoop-home/libexec/../logs/hadoop-hadoop-jobtracker-linux-peterguo.out localhost: starting tasktracker, logging to /home/hadoop/hadoop-home/libexec/../logs/hadoop-hadoop-tasktracker-linux-peterguo.out
jps查看進程是否全啓動 五個java進程 jobtracker/tasktracker/namenode/datanode/sencondarynamenode
能夠經過下面的操做來查看服務是否正常,在Hadoop中用於監控集羣健康狀態的Web界面:
http://localhost:50030/ - Hadoop 管理介面
http://localhost:50060/ - Hadoop Task Tracker 狀態
http://localhost:50070/ - Hadoop DFS 狀態
【Step9:】操做dfs數據文件
hadoop dfs -mkdir input
hadoop dfs -copyFromLocal input/test.txt input
hadoop dfs -ls input
【Step10:】運行dfs上的mr
hadoop jar hadoop-examples-1.1.2.jar wordcount input output
hadoop dfs -cat output/*
【Step11:】關閉
stop-all.sh
參考:http://blog.csdn.net/zhaoyl03/article/details/8657104