【Hadoop 分布式部署 五:分布式部署之分發、基本測試及監控】

來源:互聯網
上載者:User

標籤:開啟   檔案   重啟   mat   日誌資訊   應該   col      程式   

1.對  hadoop 進行格式化

    到  /opt/app/hadoop-2.5.0  目錄下  執行命令:    bin/hdfs namenode -format

      執行的如下  (  成功   格式化     不要沒事格式化  )

              

 

2.啟動dfs   

   執行命令(在  /opt/app/hadoop-2.5.0/目錄下):    sbin/start-dfs.sh      

      執行之後的效果就如 (可以看到  3個DataNode已經啟動起來了,NameNode  和 secondarynamenode 也已經啟動起來了)

      

      然後在分別上這三台機器上查看一下啟動情況

      節點一(hadoop-senior.zuoayn.com)

      

       節點二 (hadoop-senior02.zuoyan.com)

      

      節點三(Hadoop-senior03.zuoyan.com)

      

 

      可以看到 每個節點上執行的任務  都是我們當時設計的,我的這種情況是比較幸運的沒有出現什麼錯誤,都啟動起來了,但是有的時候會出現  

      :Temporary  failure in name resolutionop-senior02.zuoyan.com

      :Temporary  failure in name resolutionop-senior.zuoyan.com 

      出現這個原因是因為 拷貝虛擬機器出現的問題  出現這種情況的原因 就是網域名稱解析問題   機器重啟  ,還有另一種方式解決

      就是到每個機器上單獨去啟動   使用命令 :sbin/hadoop-daemon.sh start datanode 

         

通過瀏覽器開啟查看一下啟動情況:

      輸入網址:http://hadoop-senior.zuoyan.com:50070(這裡也就是第一個主機的ip地址,因為我映射到了windows的hosts中,所以也能通過這個主機名稱訪問)

       點擊首頁的  LiveNodes  就可以看見如下的介面

       這個介面上顯示的就是我們的節點

            

使用一些命令進行測試一下

        建立目錄命令:    bin/hdfs  dfs -mkdir -p /user/beifeng/tmp/conf

        

        上傳檔案命令:   bin/hdfs dfs -put /etc/hadoop/*.-site.xml  /user/beifeng/tmp/conf

        

                            讀取檔案命令:   bin/hdfs dfs -text /user/beifeng/tmp/conf/core-site.xml   (就是成功的讀取出來了)

        

        

        

3.啟動yarn  

    (在/opt/app/hadoop-2.5.0 的目錄下  )   使用命令:  sbin/start-yarn.sh

    

 

    在啟動yarn的時候我的出先了一個問題  就是resourcemanager  啟動不起來  不論是在  第一個節點上看,還是在第二個節點上看  都沒有resourcemanager 

      

      日誌資訊如下

      

 

        最終在開源中國上尋找到瞭解決方案  

        Namenode和ResourceManger如果不是同一台機器,不能在NameNode上啟動 yarn,應該在ResouceManager所在的機器上啟動yarn。

 

4.測試Mapreduce程式

        首先建立一個目錄用來存放輸入資料  命令:    bin/hdfs dfs -mkdir -p /user/beifeng/mapreduce/wordcount/input

        

        上傳檔案到檔案系統上去  命令:bin/hdfs dfs -put /opt/modules/hadoop-2.5.0/wc.input /user/beifeng/mapreduce/wordcount/input

         

        使用命令查看一下檔案是否上傳成功 命令:bin/hdfs dfs -ls /user/beifeng/mapreduce/wordcount/input   (可以看到wc.input 已經在這個目錄下)

          

        

        完成準備工作之後  就開始使用 yarn 來運行wordcount 程式 

        命令: bin/yarn jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.0.jar wordcount /user/beifeng/mapreduce/wordcount/input    /user/beifeng/mapreduce/wordcount/output

        程式已經開始在機器上運行了

        

        

        從WEB頁面上看到的效果

        

        

        最後在使用hdfs 的命令來查看一下   wordcount 統計的結果  命令 :bin/hdfs -dfs -text /user/beifeng/mapreduce/wordcount/output/part*

        

        

 

到此  配置結束,但是剩下的還有 環境問題解決  和  叢集基礎測試

 

    

 

 

        

 

 

        

        

 

 

         

 

 

 

 

  

      

 

【Hadoop 分布式部署 五:分布式部署之分發、基本測試及監控】

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.