Mac部署hadoop3(僞分佈式)

環境信息

  1. 操做系統:macOS Mojave 10.14.6
  2. JDK:1.8.0211 (安裝位置:/Library/Java/JavaVirtualMachines/jdk1.8.0211.jdk/Contents/Home)
  3. hadoop:3.2.1

開通ssh

在"系統偏好設置"->"共享",設置以下:在這裏插入圖片描述html

免密碼登陸

  1. 執行如下命令建立祕鑰:
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa複製代碼

一路next,最終會在~/.ssh目錄生成idrsa和idrsa.pub文件java

  1. 執行如下命令,將本身的祕鑰放在ssh受權目錄,這樣ssh登陸自身就不須要輸入密碼了:
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys複製代碼
  1. ssh登陸試試,此次不須要密碼了:
Last login: Sun Oct 13 21:44:17 on ttys000
(base) zhaoqindeMBP:~ zhaoqin$ ssh localhost
Last login: Sun Oct 13 21:48:57 2019
(base) zhaoqindeMBP:~ zhaoqin$複製代碼

下載hadoop

  1. 下載hadoop,地址是:http://hadoop.apache.org/releases.html
  2. 將下載文件hadoop-3.2.1.tar.gz解壓,我這裏解壓後的地址是:~/software/hadoop-3.2.1/

若是隻須要hadoop單機模式,如今就能夠了,可是單機模式沒有hdfs,所以接下來要作僞分佈模式的設置;node

僞分佈模式設置

進入目錄hadoop-3.2.1/etc/hadoop,作如下設置:程序員

  1. 打開hadoop-env.sh文件,增長JAVA的路徑設置:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home複製代碼
  1. 打開core-site.xml文件,將configuration節點改成以下內容:
<configuration>
  <property>
    <name>fs.defaultFS</name>
    <value>hdfs://localhost:9000</value>
  </property>
</configuration>複製代碼
  1. 打開hdfs-site.xml文件,將configuration節點改成以下內容:
<configuration>
  <property>
    <name>dfs.replication</name>
    <value>1</value>
  </property>
</configuration>複製代碼
  1. 打開mapred-site.xml文件,將configuration節點改成以下內容:
<configuration>
    <property>
         <name>mapreduce.framework.name</name>
         <value>yarn</value>
     </property>
</configuration>複製代碼
  1. 打開yarn-site.xml文件,將configuration節點改成以下內容:
<configuration>
    <property> 
        <name>yarn.nodemanager.aux-services</name> 
        <value>mapreduce_shuffle</value> 
    </property>
    <property> 
        <name>yarn.nodemanager.env-whitelist</name>
                  <value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAPRED_HOME</value>
    </property>
</configuration>複製代碼
  1. 在目錄hadoop-3.2.1/bin執行如下命令,初始化hdfs:
./hdfs namenode -format複製代碼

初始化成功後,可見以下信息:web

2019-10-13 22:13:32,468 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
2019-10-13 22:13:32,473 INFO namenode.FSImage: FSImageSaver clean checkpoint: txid=0 when meet shutdown.
2019-10-13 22:13:32,474 INFO namenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at zhaoqindeMBP/192.168.50.12
************************************************************/複製代碼

啓動

  1. 進入目錄hadoop-3.2.1/sbin,執行./start-dfs.sh啓動hdfs:
(base) zhaoqindeMBP:sbin zhaoqin$ ./start-dfs.sh
Starting namenodes on [localhost]
Starting datanodes
Starting secondary namenodes [zhaoqindeMBP]
zhaoqindeMBP: Warning: Permanently added 'zhaoqindembp,192.168.50.12' (ECDSA) to the list of known hosts.
2019-10-13 22:28:30,597 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable複製代碼

上面的警告不會影響使用;apache

  1. 瀏覽器訪問地址:localhost:9870 ,可見hadoop的web頁面以下圖:
    在這裏插入圖片描述
  2. 進入目錄hadoop-3.2.1/sbin,執行./start-yarn.sh啓動yarn:
base) zhaoqindeMBP:sbin zhaoqin$ ./start-yarn.sh
Starting resourcemanager
Starting nodemanagers複製代碼
  1. 瀏覽器訪問地址:localhost:8088 ,可見yarn的web頁面以下圖:
    在這裏插入圖片描述
  2. 執行jps命令查看全部java進程,正常狀況下能夠見到如下進程:
(base) zhaoqindeMBP:sbin zhaoqin$ jps
2161 NodeManager
1825 SecondaryNameNode
2065 ResourceManager
1591 NameNode
2234 Jps
1691 DataNode複製代碼

至此,hadoop3僞分佈式環境的部署、設置、啓動都已經完成。瀏覽器

中止hadoop服務

進入目錄hadoop-3.2.1/sbin,執行./stop-all.sh便可關閉hadoop的全部服務:markdown

(base) zhaoqindeMBP:sbin zhaoqin$ ./stop-all.sh
WARNING: Stopping all Apache Hadoop daemons as zhaoqin in 10 seconds.
WARNING: Use CTRL-C to abort.
Stopping namenodes on [localhost]
Stopping datanodes
Stopping secondary namenodes [zhaoqindeMBP]
2019-10-13 22:49:00,941 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Stopping nodemanagers
Stopping resourcemanager複製代碼

以上就是Mac環境部署hadoop3的所有過程,但願能給您一些參考。app

歡迎關注公衆號:程序員欣宸

相關文章
相關標籤/搜索