<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] # 1. 配置HDFS **一:配置集群** 1. 在 {hadoop_home}/etc/hadoop/hadoop-env.sh 配置文件中指定jdk路徑。 ```sql # 指定你安裝的jdk路徑 export JAVA_HOME=/usr/local/software/jdk1.8.0_171 ``` 2. 在 {hadoop_home}/etc/hadoop/core-site.xml 配置文件中指定NameNode地址。 ```shell <configuration> <!-- 指定HDFS中NameNode的地址--> <property> <name>fs.defaultFS</name> <value>hdfs://hadoop101:9000</value> </property> <!-- 指定hadoop運行時產生文件的存儲目錄 --> <property> <name>hadoop.tmp.dir</name> <value>/opt/install/hadoop/data/tmp</value> </property> </configuration> ``` 3. 在 {hadoop_home}/etc/hadoop/hdfs-site.xml 配置文件中指定HDFS副本數量。 ```shell <configuration> <!-- 指定HDFS副本的數量為1,默認為3 --> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration> ``` 4. 配置ssh無密碼登錄,往后啟動hdfs的時候就不需要輸入本機密碼了 ```shell [root@hadoop101 /]# yum install -y openssh openssh-server openssh-clients openssl openssl-devel [root@hadoop101 /]# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' [root@hadoop101 /]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys [root@hadoop101 /]# systemctl start sshd ``` **二:啟動hdfs集群** 啟動hdfs集群需要在root用戶下啟動,執行`su`進入root用戶。 1. 啟動hdfs集群 ```shell -- 回到hadoop安裝目錄進行格式化和啟動hdfs集群 -- 注意:首次啟動時才需要格式化,以后都不能格式化,否則hadoop可能無法啟動 # bin/hdfs namenode -format -- 到hadoop安裝目錄下啟動hdfs # sbin/start-dfs.sh -- 查看是否啟動成功 # jps 4784 Jps 4497 DataNode 4664 SecondaryNameNode 4365 NameNode ``` 如果只需要單獨啟動NameNode執行`sbin/hadoop-daemon.sh start namenode` ; 如果只需要單獨啟動DataNode執行`sbin/hadoop-daemon.sh start datanode` ; 2. 訪問HDFS文件系統 瀏覽器訪問:http://hadoop101:50070/ , 顯示頁面如下 ![](https://img.kancloud.cn/95/dc/95dc383e74bf2e3f7c514d1fca260603_1081x561.png)<br/> **三:操作集群** 操作要在hadoop的安裝目錄下執行。 ```shell -- 在hdfs文件系統上創建一個input目錄 # bin/hdfs dfs -mkdir -p /user/hadoop/input -- 將測試文件內容上傳到文件系統上 # bin/hdfs dfs -put wcinput/wc.input /user/hadoop/input/ -- 查看上傳的文件是否正確 # bin/hdfs dfs -ls /user/hadoop/input/ Found 1 items -rw-r--r-- 1 root supergroup 61 2020-11-30 17:21 /user/hadoop/input/wc.input # bin/hdfs dfs -cat /user/hadoop/input/wc.input hadoop yarn spark hadoop mapreduce hadoop spark hadoop spark -- 運行mapreduce程序 -- /user/hadoop/output為運行時生成的文件的目錄 # bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.14.2.jar wordcount /user/hadoop/input/ /user/hadoop/output -- 查看輸出結果 # bin/hdfs dfs -cat /user/hadoop/output/* hadoop 4 mapreduce 1 spark 3 yarn 1 ``` 或者在瀏覽器中查看 ![](https://img.kancloud.cn/a0/f4/a0f48ace25e25bd1c0cf6410e7afccb6_1729x551.png) ```shell -- 將測試文件內容下載到本地,即下載到 ./wcoutput/目錄下 # bin/hdfs dfs -get /user/hadoop/output/part-r-00000 ./wcoutput/ -- 刪除輸出結果 # bin/hdfs dfs -rm -r /user/hadoop/output ``` <br/> # 2. 配置Yarn **一:配置集群** 1. 在 {hadoop_home}/etc/hadoop/yarn-env.sh 配置文件中指定jdk目錄。 ```shell # 找到jdk的安裝位置 # some Java parameters export JAVA_HOME=/usr/local/software/jdk1.8.0_171/ ``` 2. 在 {hadoop_home}/etc/hadoop/yarn-site.xml 配置文件中指定ResourceMnanager地址。 ```xml <configuration> <!-- reducer獲取數據的方式 --> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <!-- 指定YARN的ResourceManager的地址 --> <property> <name>yarn.resourcemanager.hostname</name> <value>hadoop101</value> </property> </configuration> ``` 3. 在 {hadoop_home}/etc/hadoop/mapred-env.sh 配置文件指定jdk位置。 ```xml # 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. # 找到jdk位置 export JAVA_HOME=/usr/local/software/jdk1.8.0_171/ ``` 4. 在 {hadoop_home}/etc/hadoop/mapred-site.xml 配置文件指定MapReduce運行在yarn上 ```xml -- 將mapred-site.xml.template重命名為mapred-site.xml # mv mapred-site.xml.template mapred-site.xml -- 在mapred-site.xml做如下配置 <configuration> <!-- 指定MapReduce運行在yarn上 --> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration> ``` **二:啟動yarn集群** 1. 啟動yarn集群 ```xml -- 啟動前先確保namenode和datanode已經啟動 -- 查看是否已經啟動namenode和datanode # jps 4194 DataNode 4855 Jps 4061 NameNode 4365 SecondaryNameNode -- 出現上面信息則啟動,如果沒有啟動到hadoop安裝目錄下執行啟動 # sbin/start-dfs.sh -- 到hadoop的安裝目錄下啟動yarn # sbin/start-yarn.sh [root@hadoop101 hadoop]# jps 3505 NodeManager 3223 ResourceManager 3631 Jps ``` 如果只需要單獨啟動resourcemanager請執行 `sbin/yarn-daemon.sh start resourcemanager` ; 如果只需要單獨啟動nodemanager請執行`sbin/yarn-daemon.sh start nodemanager` ; 2. 瀏覽器訪問 瀏覽器訪問 http://hadoop101:8088/cluster 出現如下頁面啟動成功 ![](https://img.kancloud.cn/b1/2f/b12f2b3996693deb8557db46fafebe59_1336x565.png)<br/> **三:集群操作** 下面的操作均在hadoop的安裝目錄下執行。 ```xml -- 在hdfs文件系統上創建一個input目錄 # bin/hdfs dfs -mkdir -p /lean/hadoop/input -- 將測試文件內容上傳到文件系統上 # bin/hdfs dfs -put wcinput/wc.input /lean/hadoop/input/ -- 運行mapreduce程序 -- /lean/hadoop/output為運行時生成的文件的目錄 # bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.14.2.jar wordcount /lean/hadoop/input/ /lean/hadoop/output -- 查看運行結果 # bin/hdfs dfs -cat /lean/hadoop/output/* hadoop 4 mapreduce 1 spark 3 yarn 1 ``` 或者在HDFS頁面查看 ![](https://img.kancloud.cn/b7/8d/b78d80a6b281582e7946441d0d3522da_1723x559.png) 可在yarn頁面上查看提交次數和完成次數等信息 ![](https://img.kancloud.cn/59/4d/594d6cdbf9318301438a823879a22eeb_1463x459.png) <br/> # 3. 配置歷史服務器 配置歷史服務器可以查看MapReduce任務的詳情信息,查看日志,定位錯誤等信息。 1. 在 {hadoop_home}/etc/hadoop/mapred-site.xml 配置文件中配置歷史服務器訪問地址。 ```xml <property> <name>mapreduce.jobhistory.address</name> <value>hadoop101:10020</value> </property> <property> <name>mapreduce.jobhistory.webapp.address</name> <value>hadoop101:19888</value> </property> ``` 2. 啟動歷史服務器 ```xml -- 回到hadoop目下啟動歷史服務器 # sbin/mr-jobhistory-daemon.sh start historyserver -- 查看歷史服務器是否已經啟動,輸出JobHistoryServer表示啟動 # jps 6329 JobHistoryServer 6398 Jps ``` 3. 瀏覽器訪問 訪問 http://hadoop101:19888/jobhistory ,歷史頁面顯示如下 ![](https://img.kancloud.cn/33/4c/334c8228188d2167f553b9acf1e1f119_1354x484.png) <br/> # 4. 配置日志聚集 日志聚集概念:應用運行完成以后,將日志信息上傳到HDFS系統上,方便查看。 1. 在{hadoop_home}/etc/hadoop/yarn-site.xml配置進行相關配置。 ```xml <!-- 日志聚集功能開啟 --> <property> <name>yarn.log-aggregation-enable</name> <value>true</value> </property> <!-- 日志保留時間設置7天 --> <property> <name>yarn.log-aggregation.retain-seconds</name> <value>604800</value> </property> ``` 2. 關閉nodemanager 、resourcemanager(yarn)、historymanager(歷史服務器) ```xml -- 回到hadoop的安裝目錄下執行 # sbin/yarn-daemon.sh stop resourcemanage # sbin/yarn-daemon.sh stop nodemanage # sbin/mr-jobhistory-daemon.sh stop historyserver ``` 3. 啟動nodemanager 、resourcemanager(yarn)、historymanager(歷史服務器) ```xml # sbin/yarn-daemon.sh start resourcemanager # sbin/yarn-daemon.sh start nodemanager # sbin/mr-jobhistory-daemon.sh start historyserver ``` 4. 測試:刪除hdfs上已經存在的hdfs文件,然后重新生成 ```xml # bin/hdfs dfs -rm -R /lean/hadoop/output # hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.14.2.jar wordcount /lean/hadoop/input /lean/hadoop/outpu ``` 5. 瀏覽器訪問歷史 訪問 http://hadoop101:19888/jobhistory ,日志相關信息如下 ![](https://img.kancloud.cn/14/a8/14a89381e937828ad77d0c37230f7157_1899x541.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看