一.實驗環境準備
需要準備四臺Linux作業系統的服務器,配置引數最好一樣,由于我的虛擬機是之前偽分布式部署而來的,因此我的環境都一致,并且每天虛擬機默認都是Hadoop偽分布式喲!
1>.NameNode服務器(172.20.20.228)
2>.DataNode服務器(172.20.20.226-220)
二.修改Hadoop的組態檔
修改的組態檔路徑是我之前拷貝的full目錄,絕對路徑是:“/tosp/opt/hadoop”,修改這個目錄下的檔案之后,我們將hadoop目錄連接過來即可,當你需要偽分布式或者本地模式的時候只需要改變軟連接指向的目錄即可,這樣就輕松實作了三種模式組態檔和平相處的局面,
1>.core-site.xml 組態檔
[root@cdh14 ~]$ more /tosp/opt/hadoop/etc/hadoop/core-site.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://cdh14:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/tosp/opt/hadoop</value>
</property>
</configuration>
<!--
core-site.xml組態檔的作用:
用于定義系統級別的引數,如HDFS URL、Hadoop的臨時
目錄以及用于rack-aware集群中的組態檔的配置等,此中的參
數定義會覆寫core-default.xml檔案中的默認配置,
fs.defaultFS 引數的作用:
#宣告namenode的地址,相當于宣告hdfs檔案系統,
hadoop.tmp.dir 引數的作用:
#宣告hadoop作業目錄的地址,
-->
[root@cdh14 ~]$
2>.hdfs-site.xml 組態檔
[root@cdh14 ~]$ more /tosp/opt/hadoop/etc/hadoop/hdfs-site.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://www.cnblogs.com/yangtao481/p/configuration.xsl"?>
<configuration>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
</configuration>
<!--
hdfs-site.xml 組態檔的作用:
#HDFS的相關設定,如檔案副本的個數、塊大小及是否使用強制權限
等,此中的引數定義會覆寫hdfs-default.xml檔案中的默認配置.
dfs.replication 引數的作用:
#為了資料可用性及冗余的目的,HDFS會在多個節點上保存同一個資料
塊的多個副本,其默認為3個,而只有一個節點的偽分布式環境中其僅用
保存一個副本即可,這可以通過dfs.replication屬性進行定義,它是一個
軟體級備份,
-->
[root@cdh14 ~]$
3>.mapred-site.xml 組態檔
[root@cdh14 ~]$ more /tosp/opt/hadoop/etc/hadoop/mapred-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="https://www.cnblogs.com/yangtao481/p/configuration.xsl"?>
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
<!--
mapred-site.xml 組態檔的作用:
#HDFS的相關設定,如reduce任務的默認個數、任務所能夠使用記憶體
的默認上下限等,此中的引數定義會覆寫mapred-default.xml檔案中的
默認配置.
mapreduce.framework.name 引數的作用:
#指定MapReduce的計算框架,有三種可選,第一種:local(本地),第
二種是classic(hadoop一代執行框架),第三種是yarn(二代執行框架),我
們這里配置用目前版本最新的計算框架yarn即可,
-->
[root@cdh14 ~]$
4>.yarn-site.xml組態檔
[root@cdh14 ~]$ more /tosp/opt/hadoop/etc/hadoop/yarn-site.xml
<?xml version="1.0"?>
<configuration>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>cdh14</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
<!--
yarn-site.xml組態檔的作用:
#主要用于配置調度器級別的引數.
yarn.resourcemanager.hostname 引數的作用:
#指定資源管理器(resourcemanager)的主機名
yarn.nodemanager.aux-services 引數的作用:
#指定nodemanager使用shuffle
-->
[root@cdh14 ~]$
5>.slaves組態檔
[root@cdh14 ~]$ more /tosp/opt/hadoop/etc/hadoop/slaves #該組態檔的作用:是NameNode用與記錄需要連接哪些DataNode服務器節點,用與啟動或停止服務時發送遠程命令指令的目標主機, cdh14
cdh12
cdh11
cdh10
cdh9
cdh8
cdh7 [root@cdh14 ~]$
三.在NameNode節點上配置免密碼登錄各DataNode節點
1>.在本地上生成公私秘鑰對(生成之前,把上次部署偽分布式的秘鑰洗掉掉)
[root@cdh14 ~]$ rm -rf ~/.ssh/* [root@cdh14 ~]$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa Generating public/private rsa key pair. Your identification has been saved in /home/root/.ssh/id_rsa. Your public key has been saved in /home/root/.ssh/id_rsa.pub. The key fingerprint is: a3:a4:ae:d8:f7:7f:a2:b6:d6:15:74:29:de:fb:14:08 root@cdh14 The key's randomart image is: +--[ RSA 2048]----+ | . | | E o | | o = . | | o o . | | . S . . . | | o . .. . . | | . .. . o | | o .. o o . . | |. oo.+++.o | +-----------------+ [root@cdh14 ~]$
2>.使用ssh-copy-id命令分配公鑰到DataNode服務器(172.20.20.228)
[root@cdh14 ~]$ ssh-copy-id root@cdh14 The authenticity of host 'cdh14 (172.16.30.101)' can't be established. ECDSA key fingerprint is fa:25:bc:03:7e:99:eb:12:1e:bc:a8:c9:ce:39:ba:7b. Are you sure you want to continue connecting (yes/no)? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@cdh14's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@cdh14'" and check to make sure that only the key(s) you wanted were added. [root@cdh14 ~]$ ssh cdh14 Last login: Fri May 25 18:35:40 2018 from 172.16.30.1 [root@cdh14 ~]$ who root pts/0 2018-05-25 18:35 (172.16.30.1) root pts/1 2018-05-25 19:17 (cdh14) [root@cdh14 ~]$ exit logout Connection to cdh14 closed. [root@cdh14 ~]$ who root pts/0 2018-05-25 18:35 (172.16.30.1) [root@cdh14 ~]$
3>.使用ssh-copy-id命令分配公鑰到DataNode服務器(172.20.20.226-220)
[root@cdh14 ~]$ ssh-copy-id root@chd12-cdh7 /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@s102's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@s102'" and check to make sure that only the key(s) you wanted were added. [root@cdh14 ~]$ ssh s102 Last login: Fri May 25 18:35:42 2018 from 172.16.30.1 [root@s102 ~]$ who root pts/0 2018-05-25 18:35 (172.16.30.1) root pts/1 2018-05-25 19:19 (cdh14) [root@s102 ~]$ exit logout Connection to s102 closed. [root@cdh14 ~]$ who root pts/0 2018-05-25 18:35 (172.16.30.1) [root@cdh14 ~]$
注意:以上是普通使配置免密登錄,root用戶配置方法一致,最好也配置上root用戶的免密登錄,因為下文我會執行相應的shell腳本,
五.啟動服務并驗證是否成功
1>.格式化檔案系統
root@cdh14 ~]$ hdfs namenode -format2>.啟動hadoop
[root@cdh14 ~]$ start-all.sh3>.用自定義腳本驗證NameNode和DataNode是否已經正常啟動
[root@cdh14 ~]$ jps
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/144208.html
標籤:Linux
下一篇:LAMP環境搭建與配置(3)
