大數據集群環境搭建之一 hadoop-ha高可用安裝

来源:https://www.cnblogs.com/ideajiang/archive/2019/10/10/11645202.html
-Advertisement-
Play Games

1、如果你使用root用戶進行安裝。 vi /etc/profile 即可 系統變數 2、如果你使用普通用戶進行安裝。 vi ~/.bashrc 用戶變數 export HADOOP_HOME=/export/servers/hadoop-2.8.5 export PATH=$PATH:$HADOO ...


1、如果你使用root用戶進行安裝。 vi /etc/profile 即可 系統變數

2、如果你使用普通用戶進行安裝。 vi ~/.bashrc 用戶變數

export HADOOP_HOME=/export/servers/hadoop-2.8.5

export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:

同步配置文件

[root@jiang01 servers]# vi /etc/profile

[root@jiang01 servers]#

[root@jiang01 servers]# xrsync.sh /etc/profile

=========== jiang02 : /etc/profile ===========

命令執行成功

=========== jiang03 : /etc/profile ===========

命令執行成功

[root@jiang01 servers]#

刷新配置各個機器配置:

source /etc/profile

修改下麵各個配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
        <!-- 指定hdfs的nameservice為ns1 -->
    <property>
        <name>fs.defaultFS</name>
        <value>hdfs://myha01/</value>
    </property>
        <!-- 指定hadoop臨時目錄 -->
    <property>
        <name>hadoop.tmp.dir</name>
        <value>/export/servers/hadoop-2.8.5/hadoopDatas/tempDatas</value>
    </property>
        <!-- 指定zookeeper地址 -->
    <property>
        <name>ha.zookeeper.quorum</name>
        <value>jiang01:2181,jiang02:2181,jiang03:2181</value>
    </property>
</configuration>
core-site.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
    <!--指定hdfs的nameservice為ns1,需要和core-site.xml中的保持一致 -->
    <property>
        <name>dfs.nameservices</name>
        <value>myha01</value>
    </property>
    <!-- ns1下麵有兩個NameNode,分別是nn1,nn2 -->
    <property>
        <name>dfs.ha.namenodes.myha01</name>
        <value>nn1,nn2</value>
    </property>
    <!-- nn1的RPC通信地址 -->
    <property>
        <name>dfs.namenode.rpc-address.myha01.nn1</name>
        <value>jiang01:9000</value>
    </property>
    <!-- nn1的http通信地址 -->
    <property>
        <name>dfs.namenode.http-address.myha01.nn1</name>
        <value>jiang01:50070</value>
    </property>
    <!-- nn2的RPC通信地址 -->
    <property>
        <name>dfs.namenode.rpc-address.myha01.nn2</name>
        <value>jiang02:9000</value>
    </property>
    <!-- nn2的http通信地址 -->
    <property>
        <name>dfs.namenode.http-address.myha01.nn2</name>
        <value>jiang02:50070</value>
    </property>
    <!-- 指定NameNode的元數據在JournalNode上的存放位置 -->
    <property>
        <name>dfs.namenode.shared.edits.dir</name>
        <value>qjournal://jiang01:8485;jiang02:8485;jiang03:8485/myha01</value>
    </property>
    <!-- 指定JournalNode在本地磁碟存放數據的位置 -->
    <property>
        <name>dfs.journalnode.edits.dir</name>
        <value>/opt/hadoop-2.8.5/journal</value>
    </property>
    <!-- 開啟NameNode失敗自動切換 -->
    <property>
        <name>dfs.ha.automatic-failover.enabled</name>
        <value>true</value>
    </property>
    <!-- 配置失敗自動切換實現方式 -->
    <property>
        <name>dfs.client.failover.proxy.provider.myha01</name>
        <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
    </property>
    <!-- 配置隔離機制 -->
    <property>
        <name>dfs.ha.fencing.methods</name>
        <value>sshfence</value>
    </property>
    <!-- 使用隔離機制時需要ssh免登陸 -->
    <property>
        <name>dfs.ha.fencing.ssh.private-key-files</name>
        <value>/root/.ssh/id_dsa</value>
    </property>
</configuration>
hdfs-site.xml
<?xml version="1.0"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->
<configuration>
   <!-- Site specific YARN configuration properties -->
<!-- 開啟RM高可靠 -->
        <property>
            <name>yarn.resourcemanager.ha.enabled</name>
            <value>true</value>
        </property>
        <!-- 指定RM的cluster id -->
        <property>
            <name>yarn.resourcemanager.cluster-id</name>
            <value>yrc</value>
        </property>
        <!-- 指定RM的名字 -->
        <property>
            <name>yarn.resourcemanager.ha.rm-ids</name>
            <value>rm1,rm2</value>
        </property>
        <!-- 分別指定RM的地址 -->
        <property>
            <name>yarn.resourcemanager.hostname.rm1</name>
            <value>jiang02</value>
        </property>
        <property>
            <name>yarn.resourcemanager.hostname.rm2</name>
            <value>jiang03</value>
        </property>
        <!-- 指定zk集群地址 -->
        <property>
            <name>yarn.resourcemanager.zk-address</name>
            <value>jiang01:2181,jiang02:2181,jiang03:2181</value>
        </property>
        <property>
            <name>yarn.nodemanager.aux-services</name>
            <value>mapreduce_shuffle</value>
        </property>
</configuration>
yarn-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
         <!-- 指定mr框架為yarn方式 -->
    <property>
        <name>mapreduce.framework.name</name>
        <value>yarn</value>
    </property>
</configuration>
mapred-site.xml
[root@jiang01 servers]#  hadoop version
Hadoop 2.8.5
Subversion https://git-wip-us.apache.org/repos/asf/hadoop.git -r 0b8464d75227fcee2c6e7f2410377b3d53d3d5f8
Compiled by jdu on 2018-09-10T03:32Z
Compiled with protoc 2.5.0
From source with checksum 9942ca5c745417c14e318835f420733
This command was run using /export/servers/hadoop-2.8.5/share/hadoop/common/hadoop-common-2.8.5.jar
[root@jiang01 servers]#
查看hadoop版本

啟動zk

[root@jiang01 servers]# 
[root@jiang01 servers]# xcall.sh jps -l
============= jiang01 : jps -l ============
10262 org.apache.zookeeper.server.quorum.QuorumPeerMain
10571 sun.tools.jps.Jps
命令執行成功
============= jiang02 : jps -l ============
10162 sun.tools.jps.Jps
9991 org.apache.zookeeper.server.quorum.QuorumPeerMain
命令執行成功
============= jiang03 : jps -l ============
2275 org.apache.zookeeper.server.quorum.QuorumPeerMain
2436 sun.tools.jps.Jps
命令執行成功
[root@jiang01 servers]# xcall.sh zkServer.sh status
============= jiang01 : zkServer.sh status ============
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper-3.4.14/bin/../conf/zoo.cfg
Mode: follower
命令執行成功
============= jiang02 : zkServer.sh status ============
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper-3.4.14/bin/../conf/zoo.cfg
Mode: leader
命令執行成功
============= jiang03 : zkServer.sh status ============
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper-3.4.14/bin/../conf/zoo.cfg
Mode: follower
命令執行成功
[root@jiang01 servers]#
啟動zk

在你配置的各個journalnode節點啟動該進程

[root@jiang01 servers]# 
[root@jiang01 servers]# xcall.sh hadoop-daemon.sh start journalnode
============= jiang01 : hadoop-daemon.sh start journalnode ============
starting journalnode, logging to /export/servers/hadoop-2.8.5/logs/hadoop-root-journalnode-jiang01.out
命令執行成功
============= jiang02 : hadoop-daemon.sh start journalnode ============
starting journalnode, logging to /export/servers/hadoop-2.8.5/logs/hadoop-root-journalnode-jiang02.out
命令執行成功
============= jiang03 : hadoop-daemon.sh start journalnode ============
starting journalnode, logging to /export/servers/hadoop-2.8.5/logs/hadoop-root-journalnode-jiang03.out
命令執行成功
[root@jiang01 servers]#
啟動journalnode

 

 

 先選取一個namenode(jiang01)節點進行格式化

[root@jiang01 servers]# hadoop namenode -format
View Code

 

 

 

格式化zkfc,只能在nameonde節點進行

主節點上面啟動 dfs文件系統:

[root@jiang01 dfs]# start-dfs.sh

 

 

 jiang002啟動yarm

[root@jiang02 mapreduce]# start-yarn.sh
starting yarn daemons
starting resourcemanager, logging to /export/servers/hadoop-2.8.5/logs/yarn-root-resourcemanager-jiang02.out
jiang03: starting nodemanager, logging to /export/servers/hadoop-2.8.5/logs/yarn-root-nodemanager-jiang03.out
jiang01: starting nodemanager, logging to /export/servers/hadoop-2.8.5/logs/yarn-root-nodemanager-jiang01.out
jiang02: starting nodemanager, logging to /export/servers/hadoop-2.8.5/logs/yarn-root-nodemanager-jiang02.out
[root@jiang02 mapreduce]# 
View Code

jiang03啟動:resourcemanager

[root@jiang03 hadoopDatas]#  yarn-daemon.sh start resourcemanager
starting resourcemanager, logging to /export/servers/hadoop-2.8.5/logs/yarn-root-resourcemanager-jiang03.out
View Code

hadoop wordcount程式啟動:

1  cd /export/servers/hadoop-2.8.5/share/hadoop/mapreduce/

2 生成數據文件:

touch word.txt
echo "hello world" >> word.txt
echo "hello hadoop" >> word.txt
echo "hello hive" >> word.txt

3 創建hadoop 文件目錄

hdfs dfs -mkdir -p /work/data/input

4 向hadoop上傳數據文件

hdfs dfs -put ./word.txt /work/data/input

5 計算例子

hadoop jar hadoop-mapreduce-examples-2.8.5.jar wordcount /work/data/input /work/data/output

6 查看結果:

[root@jiang01 mapreduce]# hadoop jar hadoop-mapreduce-examples-2.8.5.jar wordcount /work/data/input /work/data/output
19/10/09 11:44:48 INFO input.FileInputFormat: Total input files to process : 1
19/10/09 11:44:48 INFO mapreduce.JobSubmitter: number of splits:1
19/10/09 11:44:48 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1570635804389_0001
19/10/09 11:44:48 INFO impl.YarnClientImpl: Submitted application application_1570635804389_0001
19/10/09 11:44:48 INFO mapreduce.Job: The url to track the job: http://jiang02:8088/proxy/application_1570635804389_0001/
19/10/09 11:44:48 INFO mapreduce.Job: Running job: job_1570635804389_0001
19/10/09 11:45:00 INFO mapreduce.Job: Job job_1570635804389_0001 running in uber mode : false
19/10/09 11:45:00 INFO mapreduce.Job:  map 0% reduce 0%
19/10/09 11:45:11 INFO mapreduce.Job:  map 100% reduce 0%
19/10/09 11:45:20 INFO mapreduce.Job:  map 100% reduce 100%
19/10/09 11:45:20 INFO mapreduce.Job: Job job_1570635804389_0001 completed successfully
19/10/09 11:45:21 INFO mapreduce.Job: Counters: 49
        File System Counters
                FILE: Number of bytes read=54
                FILE: Number of bytes written=321397
                FILE: Number of read operations=0
                FILE: Number of large read operations=0
                FILE: Number of write operations=0
                HDFS: Number of bytes read=139
                HDFS: Number of bytes written=32
                HDFS: Number of read operations=6
                HDFS: Number of large read operations=0
                HDFS: Number of write operations=2
        Job Counters 
                Launched map tasks=1
                Launched reduce tasks=1
                Data-local map tasks=1
                Total time spent by all maps in occupied slots (ms)=8790
                Total time spent by all reduces in occupied slots (ms)=6229
                Total time spent by all map tasks (ms)=8790
                Total time spent by all reduce tasks (ms)=6229
                Total vcore-milliseconds taken by all map tasks=8790
                Total vcore-milliseconds taken by all reduce tasks=6229
                Total megabyte-milliseconds taken by all map tasks=9000960
                Total megabyte-milliseconds taken by all reduce tasks=6378496
        Map-Reduce Framework
                Map input records=3
                Map output records=6
                Map output bytes=60
                Map output materialized bytes=54
                Input split bytes=103
                Combine input records=6
                Combine output records=4
                Reduce input groups=4
                Reduce shuffle bytes=54
                Reduce input records=4
                Reduce output records=4
                Spilled Records=8
                Shuffled Maps =1
                Failed Shuffles=0
                Merged Map outputs=1
                GC time elapsed (ms)=199
                CPU time spent (ms)=1320
                Physical memory (bytes) snapshot=325742592
                Virtual memory (bytes) snapshot=4161085440
                Total committed heap usage (bytes)=198316032
        Shuffle Errors
                BAD_ID=0
                CONNECTION=0
                IO_ERROR=0
                WRONG_LENGTH=0
                WRONG_MAP=0
                WRONG_REDUCE=0
        File Input Format Counters 
                Bytes Read=36
        File Output Format Counters 
                Bytes Written=32
View Code

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 1 BEGIN 2 FOR c IN ( SELECT COLUMN_NAME cn FROM all_tab_columns WHERE table_name = '表名' ) 3 loop 4 BEGIN 5 execute IMMEDIATE 'alter table 表名 rename co ...
  • 此題的難度在於,選擇部門的前三位高工資人員(註意,允許併列人員的存在)。 分析題目: 存在兩張表,則肯定需要使用 ; 需要選取相同部門的前三名,原本想使用 以及 ; 然而 以及 無法滿足併列前三名的要求,因此,只能對同張表使用 ,如果某個薪水滿足 小於三個,則此人薪水在部門前三; 綜上所述,答案如下 ...
  • 用SQLyog連接MySQL8.0(社區版:mysql-installer-community-8.0.15.0.msi),出現錯誤2058(Plugin caching_sha2_password could not be loaded:xxxx),通過查詢資料瞭解了該錯誤的原因併在本文中提出了該... ...
  • 做了那麼多年的開發第一次寫博客,一開始是沒想過要寫博客的,後來想寫,卻一直不敢寫,一個是怕自己寫的不好,誤導人家,二來是不太自信。現在想起寫博客是因為,真正的勇士敢於面臨淋漓的鮮血,希望能提高自己,也是做個記錄自己不容易忘記,如果有哪裡寫的不好的,希望各位海涵,給出意見與批評,讓我更上一層樓。謝謝。 ...
  • 此題,竟然一時間沒想到如何合理的解決方案,主要是有較長的時間沒有使用 與`NOT IN`. 也是一個手熟的活,需要經常鍛煉,以下是解題答案: ...
  • 以前使用 ,都是局限於單個數值使用,從未嘗試過多個數據使用 . 此題涉及兩個表,肯定需要使用 操作. 此外,需要選取每個 的最大數值,那麼肯定涉及 以及 操作. 綜合以上因素,答案如下所示: ...
  • 1、增加列 2、刪除列 3、修改欄位類型 4、重命名列: 5、重命名錶: 當修改表結構時,sql server會彈出對話框,顯示以下內容: 不允許保存更改。您所做的更改要求刪除並重新創建以下表。您對無法重新創建的表進行了更改或者啟用了“阻止保存要求重新創建表的更改”選項。 解決方案:菜單欄->工具- ...
  • 1. SQL語言包括哪些類型? 數據定義:Create Table,Alter Table,Drop Table, Craete/Drop Index 數據操縱:Select ,insert,update,delete 數據控制:grant,revoke 2. 內聯接,外聯接區別? 內連接是保證兩個 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...