如題
目錄
1、硬體配置
2、軟體版本
3、準備工作
3.1、建立虛拟機,網絡設定為橋接模式
3.2、更改主機名
3.3、綁定主機名和IP,建立各主機間的聯系
3.4、關閉防火牆
3.5、配置主控端hosts檔案
3.6、配置SSH,實作節點間的無密碼登入
4、安裝JDK
5、安裝Hadoop
6、格式化
7、啟動
8、測試wordcount
9、注意點
10、配置檔案10.1、一些配置項解釋
采用3台虛拟機
節點名稱
IP位址
記憶體
硬碟
節點角色
node1
192.168.1.6
2GB
10GB
NameNode、ResoucerManager
node2
192.168.1.7
DataNode、NodeManager、SecondaryNameNode
node3
192.168.1.8
DataNode、NodeManager
軟體
版本
JDK
jdk-8u271
HADOOP
hadoop-3.2.1
在 node1 上執行如下步驟:
使主控端和虛拟機系統可以互相ping通
<code>C:\Windows\System32\drivers\etc\hosts</code> 目錄下,添加如下内容:
無密碼登陸:在 node1 上,通過 <code>ssh node2</code> 或 <code>ssh node3</code> 就可以登陸到對方計算機上,而不用輸入密碼。
分别在三台虛拟機的 <code>/root</code> 目錄下執行:
設定 ssh 的密鑰和密鑰的存放路徑。 路徑為<code>~/.ssh</code>
進入到 <code>.ssh</code> 目錄,執行如下指令,将公鑰放到 authorized_keys 裡:
将 node1 上的 authorized_keys 放入其他虛拟機的 <code>~/.ssh</code> 目錄下:
在 node1 上,下載下傳,解壓,并配置環境變量:
将 jdk1.8.0_271 複制到 node2 和 node3
将 /etc/profile 複制到 node2 和 node3
配置配置檔案後,将 hadoop-3.2.1 複制到 node2 和 node3
對 node1 :
如果再次格式化,需要先删除 namenode 和 datanode 上的 <code>dfs/namenode</code> 和 <code>dfs/datanode</code>目錄。
可以全部啟動,也可以分别啟動。

出現了如下問題:
(1)通過 yarn 送出任務出現 <code>Failed while trying to construct the redirect url to the log server. Log Server url may not be configured</code>
原因是未配置 historyserver 服務。配置如下屬性:
(2)執行作業時,出現了 <code>錯誤: 找不到或無法加載主類 org.apache.hadoop.mapreduce.v2.app.MRAppMaster</code>
将上述值添加到 <code>yarn-site.xml</code> 檔案如下屬性中:
(3)執行作業時,出現了 <code>The auxService:mapreduce_shuffle does not exist</code> 錯誤。
因為在複制 yarn-site.xml 時漏掉了 <code>yarn.nodemanager.aux-services</code> 屬性。
(4)第一次執行作業的時候,輸出日志一直卡在 <code>INFO mapreduce.Job: Running job: job_1605371813670_0001</code> 。這個問題首先要考慮配置檔案是否正确,其次考慮yarn的資源配置設定。
(1)如果某個程序啟動失敗了,考慮配置檔案是不是配置錯誤了,或者格式化的時候未清理上次叢集的id。
(2)如果啟動,出現了 <code>ERROR: but there is no HDFS_NAMENODE_USER defined. Aborting operation.</code> 錯誤,說明在 <code>hadoop-env.sh</code> 中未配置此項。具體配置内容見下面的配置檔案。
(3)在 Hadoop3.x 中,NameNode 的 web 端口改成了 9870
(4)配置檔案的配置可以同時參考 官網叢集搭建、官網core-site.xml、官網hdfs-site.xml、官網yarn-site.xml、官網mapred-site.xml
(5)在跑任務時,注意資源的配置設定。
管理者應該通過設定 <code>etc/hadoop/hadoop-env.sh</code>,和可選的 <code>etc/hadoop/mapred-env.sh</code>、<code>etc/hadoop/yarn-env.sh</code> 腳本來對 Hadoop 守護程序環境進行個性化設定,比如,設定 namenode 使用多少堆記憶體。
至少,你需要在每個遠端結點上指定 JAVA_HOME 。
預設是 <code>file://${hadoop.tmp.dir}/dfs/data</code>
Determines where on the local filesystem an DFS data node should store its blocks. If this is a comma-delimited list of directories, then data will be stored in all named directories, typically on different devices. The directories should be tagged with corresponding storage types ([SSD]/[DISK]/[ARCHIVE]/[RAM_DISK]) for HDFS storage policies. The default storage type will be DISK if the directory does not have a storage type tagged explicitly. Directories that do not exist will be created if local filesystem permission allows.