初始化脚本位置:$HADOOP_HOME/bin/hdfs 相当于硬盘格式化
- 执行初始化脚本:hdfs namenode -format
其中:[root@hadoop101 hadoop-3.2.1]# hdfs namenode -format
2020-01-11 23:21:30,739 INFO namenode.NameNode: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG: host = hadoop101/10.150.8.101
STARTUP_MSG: args = [-format]
STARTUP_MSG: version = 3.2.1
STARTUP_MSG: classpath = ...省略...
STARTUP_MSG: build = https://gitbox.apache.org/repos/asf/hadoop.git -r b3cbbb467e22ea829b3808f4b7b01d07e0bf3842; compiled by 'rohithsharmaks' on 2019-09-10T15:56Z
STARTUP_MSG: java = 1.8.0_144
************************************************************/
2020-01-11 23:21:30,774 INFO namenode.NameNode: registered UNIX signal handlers for [TERM, HUP, INT]
...省略...
2020-01-11 23:21:33,361 INFO namenode.FSImage: Allocated new BlockPoolId: BP-1570783588-10.150.8.101-1578756093340
2020-01-11 23:21:33,383 INFO common.Storage: Storage directory /home/data/hadoop/tmp/dfs/name has been successfully formatted.
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
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 .
2020-01-11 23:21:33,547 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
2020-01-11 23:21:33,554 INFO namenode.FSImage: FSImageSaver clean checkpoint: txid=0 when meet shutdown.
2020-01-11 23:21:33,555 INFO namenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at hadoop101/10.150.8.101
************************************************************/
[root@hadoop101 hadoop-3.2.1]#
- 出现“Storage directory /home/data/hadoop/tmp/dfs/name has been successfully formatted.”表示格式化成功
- 此时数据目录中已存在文件
```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 ```