格式化命令:
```bash
hdfs namenode -format
```
日志输出片段:
```java
20/05/19 14:53:53 INFO util.GSet: 0.029999999329447746% max memory 966.7 MB = 297.0 KB
20/05/19 14:53:53 INFO util.GSet: capacity = 2^15 = 32768 entries
20/05/19 14:53:53 INFO namenode.FSImage: Allocated new BlockPoolId: BP-358508718-192.168.8.21-1589871233613
20/05/19 14:53:53 INFO common.Storage: Storage directory /opt/data/hadoop/tmp/dfs/name has been successfully formatted.
20/05/19 14:53:53 INFO namenode.FSImageFormatProtobuf: Saving image file /opt/data/hadoop/tmp/dfs/name/current/fsimage.ckpt_0000000000000000000 using no compression
20/05/19 14:53:53 INFO namenode.FSImageFormatProtobuf: Image file /opt/data/hadoop/tmp/dfs/name/current/fsimage.ckpt_0000000000000000000 of size 321 bytes saved in 0 seconds.
20/05/19 14:53:53 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
20/05/19 14:53:53 INFO util.ExitUtil: Exiting with status 0
20/05/19 14:53:53 INFO namenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at hadoop1/192.168.8.21
************************************************************/
```
### ①、脚本批量启动
```bash
/opt/hadoop/sbin/start-dfs.sh # 启动dfs
/opt/hadoop/sbin/stop-dfs.sh # 停止dfs
/opt/hadoop/sbin/start-yarn.sh # 启动yarn
/opt/hadoop/sbin/stop-yarn.sh # 停止yarn
```
```bash
jps # 查看进程
```
浏览器查看:[http://hadoop01:50070](http://hadoop01:50070)
### ②、单节点独立启动
```bash
/opt/hadoop/sbin/hadoop-daemon.sh start namenode # 在主角色上启动namenode
/opt/hadoop/sbin/hadoop-daemon.sh start datanode # 在从角色上启动datanode
/opt/hadoop/sbin/yarn-daemon.sh start resourcemanager # 在主角色上启动resourcemanager
/opt/hadoop/sbin/yarn-daemon.sh start nodemanager # 在从角色上启动nodemanager
```
停止,将`start`改成`stop`。