Hadoop1.2.1僞分佈模式安裝指南



1、前置條件java

一、操做系統準備
(1)Linux能夠用做開發平臺及產品平臺。
(2)win32只可用做開發平臺,且須要cygwin的支持。
二、安裝jdk 1.6或以上
三、安裝ssh,並配置免密碼登陸。
$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa  
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
注意
(1)若.ssh目錄不存在,則先創建目錄。
(2).ssh/的權限爲700, authorized_keys的權限爲700,權限大了小了都不行。

四、若爲初次安裝,爲避免權限問題,建議使用root用戶。

2、基本準備
一、下載hadoop1.2.1並解壓
  [root@jediael jediael]$wget http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-1.2.1/hadoop-1.2.1.tar.gz
 [root@jediael jediael]$ tar -zxvf hadoop-1.2.1-bin.tar.gz
選擇國內鏡像,速度較快。

二、修改conf/hadoop-env.sh,添加JAVA_HOME變量
(1) 增長JAVA_HOME
[root@jediael hadoop-1.2.1]$ vi conf/hadoop-env.sh
 export JAVA_HOME=/usr/java/jdk1.7.0_51
(2)執行hadoop命令
[root@jediael hadoop-1.2.1]$ bin/hadoop 
Usage: hadoop [--config confdir] COMMAND 
where COMMAND is one of: 
namenode -format format the DFS filesystem 
secondarynamenode run the DFS secondary namenode 
namenode run the DFS namenode 
datanode run a DFS datanode 
dfsadmin run a DFS admin client 
mradmin run a Map-Reduce admin client 
fsck run a DFS filesystem checking utility 
fs run a generic filesystem user client
以上輸出代表安裝正常。

3、配置僞分佈模式
一、配置core-site.xml,增長如下屬性
<configuration>
     <property>
         <name>fs.default.name</name>
         <value>hdfs://localhost:9000</value>
     </property>
</configuration>
二、配置hdfs-site.xml,增長如下屬性
<configuration>
     <property>
         <name>dfs.replication</name>
         <value>1</value>
     </property>
</configuration>

三、配置mapred-site.xml,增長如下屬性
<configuration>
     <property>
         <name>mapred.job.tracker</name>
         <value>localhost:9001</value>
     </property>
</configuration>
 
4、啓動hadoop
一、格式化hdfs
[root@jediael hadoop-1.2.1]$ bin/hadoop namenode -format 
14/08/16 23:50:02 INFO namenode.NameNode: STARTUP_MSG: 
/************************************************************ 
STARTUP_MSG: Starting NameNode 
STARTUP_MSG: host = jediael/10.171.29.191 
STARTUP_MSG: args = [-format] 
STARTUP_MSG: version = 1.2.1 
STARTUP_MSG: build = https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.2 -r 1503152; compiled by 'mattf' on Mon Jul 22 15:23:09 PDT 2013 
STARTUP_MSG: java = 1.7.0_51 
************************************************************/ 
14/08/16 23:50:02 INFO util.GSet: Computing capacity for map BlocksMap 
14/08/16 23:50:02 INFO util.GSet: VM type = 64-bit 
14/08/16 23:50:02 INFO util.GSet: 2.0% max memory = 1013645312 
14/08/16 23:50:02 INFO util.GSet: capacity = 2^21 = 2097152 entries 
14/08/16 23:50:02 INFO util.GSet: recommended=2097152, actual=2097152 
14/08/16 23:50:02 INFO namenode.FSNamesystem: fsOwner=jediael 
14/08/16 23:50:02 INFO namenode.FSNamesystem: supergroup=supergroup 
14/08/16 23:50:02 INFO namenode.FSNamesystem: isPermissionEnabled=true 
14/08/16 23:50:02 INFO namenode.FSNamesystem: dfs.block.invalidate.limit=100 
14/08/16 23:50:02 INFO namenode.FSNamesystem: isAccessTokenEnabled=false accessKeyUpdateInterval=0 min(s), accessTokenLifetime=0 min(s) 
14/08/16 23:50:02 INFO namenode.FSEditLog: dfs.namenode.edits.toleration.length = 0 
14/08/16 23:50:02 INFO namenode.NameNode: Caching file names occuring more than 10 times 
14/08/16 23:50:03 INFO common.Storage: Image file /tmp/hadoop-jediael/dfs/name/current/fsimage of size 113 bytes saved in 0 seconds. 
14/08/16 23:50:03 INFO namenode.FSEditLog: closing edit log: position=4, editlog=/tmp/hadoop-jediael/dfs/name/current/edits 
14/08/16 23:50:03 INFO namenode.FSEditLog: close success: truncate to 4, editlog=/tmp/hadoop-jediael/dfs/name/current/edits 
14/08/16 23:50:03 INFO common.Storage: Storage directory /tmp/hadoop-jediael/dfs/name has been successfully formatted. 
14/08/16 23:50:03 INFO namenode.NameNode: SHUTDOWN_MSG: 
/************************************************************ 
SHUTDOWN_MSG: Shutting down NameNode at jediael/10.171.29.191 
************************************************************/

二、啓動hadoop
[root@jediael hadoop-1.2.1]# bin/start-all.sh 
starting namenode, logging to /opt/jediael/hadoop-1.2.1/libexec/../logs/hadoop-root-namenode-jediael.out 
localhost: starting datanode, logging to /opt/jediael/hadoop-1.2.1/libexec/../logs/hadoop-root-datanode-jediael.out 
localhost: starting secondarynamenode, logging to /opt/jediael/hadoop-1.2.1/libexec/../logs/hadoop-root-secondarynamenode-jediael.out 
starting jobtracker, logging to /opt/jediael/hadoop-1.2.1/libexec/../logs/hadoop-root-jobtracker-jediael.out 
localhost: starting tasktracker, logging to /opt/jediael/hadoop-1.2.1/libexec/../logs/hadoop-root-tasktracker-jediael.out


默認狀況下,日誌將被輸出至 {HADOOP_HOME}/logs,除非修改了 ${HADOOP_LOG_DIR}。

三、訪問如下2個頁面,驗證是否已經安裝成功

四、使用jps查看各個進程的運行狀況
[root@jediael hadoop-1.2.0]# jps 
3148 JobTracker 
3280 TaskTracker 
3052 SecondaryNameNode 
2920 DataNode 
2801 NameNode 
3442 Jps

5、使用一個簡單的hadoop程序驗證環境
相關文章
相關標籤/搜索