hadoop安裝全過程
1.下載hadoop-0.20.2,:http://www.apache.org/dist/hadoop/common/hadoop-0.20.2/2.下載jdk-6u20-linux-i586.bin,:http://autosetup1.googlecode.com/files/jdk-6u20-linux-i586.bin3.安裝jdk:./jdk-6u20-linux-i586.bin4.設定環境變數:在/etc/profile中加入如下語句:JAVA_HOME=java安裝路徑(如/usr/java)
CLASSPATH=.:$JAVA_HOME/lib
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH
然後重新載入環境變數 source /etc/profile5.解壓縮hadoop-0.20.2,修改hadoop配置,設定檔如下:1.core-site.xml:<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/hadoopdata</value>(這個是一個檔案夾,相當於Distributed File System的硬碟主目錄)
<description>A base for other temporary directories.</description>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://192.168.1.217:9000</value>(這是namenode的主機名稱和連接埠,串連hdfs時需要用到)
<description>The name of the default file system. A URI whose
scheme and authority determine the FileSystem implementation. The
uri's scheme determines the config property (fs.SCHEME.impl) naming
the FileSystem implementation class. The uri's authority is used to
determine the host, port, etc. for a filesystem.</description>
</property>
<property>
<name>dfs.hosts.exclude</name>
<value>/root/jz/hadoop-0.20.2/excludes</value>(這是一個檔案,現在還不知道是幹啥用的)
</property>
</configuration>2.hdfs-site.xml<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.name.dir</name>
<value>/root/jz/hadoop-0.20.2/hdfs/name</value>
</property>
<property>
<name>dfs.data.dir</name>
<value>/root/jz/hadoop-0.20.2/hdfs/data</value>
</property>
</configuration>3.mapred-site.xml:<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>m:9001</value>
<description>The host and port that the MapReduce job tracker runs
at. If "local", then jobs are run in-process as a single map
and reduce task.
</description>
</property>
</configuration>
master中填寫master主機IP地址 slave中填寫slave主機IP地址 遇到問題:hadoop環境變數配置,除了配置系統的環境變數/etc/profile外,還要配置hadoop/conf/hadoop-env.sh,因為hadoop啟動時會先通過這個指令碼重新載入環境變數,具體調用在hadoop-daemon.sh中hadoop啟動過程如下:先載入設定檔(hadoop-config.sh),啟動hdfs(start-dfs.sh),啟動mapreduce(start-mapred.sh)使用jps查看正在啟動並執行服務,namenode,jobtracker,SecondaryNameNode一定要起來如果出現哪一個沒起,就去日誌裡面查看原因,這次出現的兩個錯誤有:namenode沒有format,用命令hadoop namenode -format即可解決;excludes檔案不存在,建立一下就好注意:conf中的每一個配置對應的路徑和檔案都必須存在,否則就會出錯。第二個問題:如果沒把叢集配起,hdfs不能使用,配叢集要設定SSH,使master不輸入口令就可以串連到slave,配置方法如下:
第一步:產生密匙對,我用的是rsa的密鑰。使用命令 "ssh-keygen -t rsa"
[user1@rh user1]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/user1/.ssh/id_rsa): Created directory '/home/user1/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/user1/.ssh/id_rsa. Your public key has been saved in /home/user1/.ssh/id_rsa.pub. The key fingerprint is: e0:f0:3b:d3:0a:3d:da:42:01:6a:61:2f:6c:a0:c6:e7 user1@rh.test.com [user1@rh user1]$
產生的過程中提示輸入金鑰組儲存位置,直接斷行符號,接受預設值就行了。接著會提示輸入一
個不同於你的password的密碼,直接斷行符號,讓它空著。當然,也可以輸入一個。(我比較懶
,不想每次都要輸入密碼。) 這樣,金鑰組就產生完了。
其中公用密鑰儲存在 ~/.ssh/id_rsa.pub
私人密鑰儲存在 ~/.ssh/id_rsa
之後把這個金鑰組中的公用密鑰複製到你要訪問的機器上去,並儲存為
~/.ssh/authorized_keys. |
|
|