初始化脚本位置:$HADOOP_HOME/bin/hdfs 相当于硬盘格式化

    1. 执行初始化脚本:hdfs namenode -format
      1. [root@hadoop101 hadoop-3.2.1]# hdfs namenode -format
      2. 2020-01-11 23:21:30,739 INFO namenode.NameNode: STARTUP_MSG:
      3. /************************************************************
      4. STARTUP_MSG: Starting NameNode
      5. STARTUP_MSG: host = hadoop101/10.150.8.101
      6. STARTUP_MSG: args = [-format]
      7. STARTUP_MSG: version = 3.2.1
      8. STARTUP_MSG: classpath = ...省略...
      9. STARTUP_MSG: build = https://gitbox.apache.org/repos/asf/hadoop.git -r b3cbbb467e22ea829b3808f4b7b01d07e0bf3842; compiled by 'rohithsharmaks' on 2019-09-10T15:56Z
      10. STARTUP_MSG: java = 1.8.0_144
      11. ************************************************************/
      12. 2020-01-11 23:21:30,774 INFO namenode.NameNode: registered UNIX signal handlers for [TERM, HUP, INT]
      13. ...省略...
      14. 2020-01-11 23:21:33,361 INFO namenode.FSImage: Allocated new BlockPoolId: BP-1570783588-10.150.8.101-1578756093340
      15. 2020-01-11 23:21:33,383 INFO common.Storage: Storage directory /home/data/hadoop/tmp/dfs/name has been successfully formatted.
      16. 2020-01-11 23:21:33,416 INFO namenode.FSImageFormatProtobuf: Saving image file /home/data/hadoop/tmp/dfs/name/current/fsimage.ckpt_0000000000000000000 using no compression
      17. 2020-01-11 23:21:33,531 INFO namenode.FSImageFormatProtobuf: Image file /home/data/hadoop/tmp/dfs/name/current/fsimage.ckpt_0000000000000000000 of size 399 bytes saved in 0 seconds .
      18. 2020-01-11 23:21:33,547 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
      19. 2020-01-11 23:21:33,554 INFO namenode.FSImage: FSImageSaver clean checkpoint: txid=0 when meet shutdown.
      20. 2020-01-11 23:21:33,555 INFO namenode.NameNode: SHUTDOWN_MSG:
      21. /************************************************************
      22. SHUTDOWN_MSG: Shutting down NameNode at hadoop101/10.150.8.101
      23. ************************************************************/
      24. [root@hadoop101 hadoop-3.2.1]#
      其中:
    • 出现“Storage directory /home/data/hadoop/tmp/dfs/name has been successfully formatted.”表示格式化成功
    1. 此时数据目录中已存在文件 ```shell [root@hadoop101 hadoop]# tree /home/data/hadoop/tmp/ /home/data/hadoop/tmp/ └── dfs └── name
       └── current
           ├── fsimage_0000000000000000000
           ├── fsimage_0000000000000000000.md5
           ├── seen_txid
           └── VERSION
      

    3 directories, 4 files ```