Hadoop常用命令

1、基础命令

bash 复制代码
# 版本查看
hadoop version

# 启动
cd /opt/homebrew/sbin
start-all.sh

# 查看进程
jps

# 关闭
stop-all.sh

2、HDFS 命令

bash 复制代码
# 创建目录
hdfs dfs -mkdir -p /user/xiaokkk/documents

# 删除目录
hdfs dfs -rm -r /user/xiaokkk/documents

# 上传文件
hdfs dfs -put /Users/xiaokkk/Desktop/test1.txt /data

# 下载文件
hdfs dfs -get /data/test.txt test2.txt

# 显示文件内容
hdfs dfs -cat /data/test.txt
hdfs dfs -tail /data/test.txt

3、hdfs dfsadmin -report:

bash 复制代码
(base) xiaokkk@xiaokkkdeMacBook-Pro Desktop % hdfs dfsadmin -report
2024-09-02 14:49:46,687 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Configured Capacity: 245107195904 (228.27 GB)
Present Capacity: 15063244977 (14.03 GB)
DFS Remaining: 15063072768 (14.03 GB)
DFS Used: 172209 (168.17 KB)
DFS Used%: 0.00%
Replicated Blocks:
 Under replicated blocks: 3
 Blocks with corrupt replicas: 0
 Missing blocks: 0
 Missing blocks (with replication factor 1): 0
 Low redundancy blocks with highest priority to recover: 3
 Pending deletion blocks: 0
Erasure Coded Block Groups: 
 Low redundancy block groups: 0
 Block groups with corrupt internal blocks: 0
 Missing block groups: 0
 Low redundancy blocks with highest priority to recover: 0
 Pending deletion blocks: 0

-------------------------------------------------
Live datanodes (1):

Name: 127.0.0.1:9866 (localhost)
Hostname: 192.168.82.162
Decommission Status : Normal
Configured Capacity: 245107195904 (228.27 GB)
DFS Used: 172209 (168.17 KB)
Non DFS Used: 230043950927 (214.25 GB)
DFS Remaining: 15063072768 (14.03 GB)
DFS Used%: 0.00%
DFS Remaining%: 6.15%
Configured Cache Capacity: 0 (0 B)
Cache Used: 0 (0 B)
Cache Remaining: 0 (0 B)
Cache Used%: 100.00%
Cache Remaining%: 0.00%
Xceivers: 0
Last contact: Mon Sep 02 14:49:45 CST 2024
Last Block Report: Mon Sep 02 14:22:18 CST 2024
Num of Blocks: 3

从您提供的hdfs dfsadmin -report输出来看,您的Hadoop集群配置和运行状态如下:

  1. 总体容量

    • 配置容量:228.27 GB
    • 当前可用容量:14.03 GB
    • 已用容量:168.17 KB
    • 使用率:0.00%
  2. DataNode状态

    • 活动DataNode数量:1
    • 主机名:192.168.82.162
    • 配置容量:228.27 GB
    • 已用容量:168.17 KB
    • 剩余容量:14.03 GB
    • 使用率:0.00%
    • 剩余比例:6.15%
  3. NameNode状态

    • 存在3个未完全复制的块(Under replicated blocks)
    • 没有损坏的块(Blocks with corrupt replicas)
    • 没有丢失的块(Missing blocks)

4、附录

Hadoop 管理命令
  1. hdfs dfsadmin -report

    • 显示HDFS集群的状态报告。
    • 示例:hdfs dfsadmin -report
  2. hdfs dfsadmin -safemode [enter|leave|get]

    • 控制HDFS的安全模式。
    • 示例:hdfs dfsadmin -safemode leave
  3. hdfs fsck / [options]

    • 检查文件系统的完整性。
    • 示例:hdfs fsck / -delete
  4. hdfs balancer -threshold [percentage]

    • 平衡DataNode之间的数据分布。
    • 示例:hdfs balancer -threshold 10
  5. hdfs namenode -format

    • 格式化NameNode。
    • 示例:hdfs namenode -format
  6. hdfs secondarynamenode -start

    • 启动SecondaryNameNode。
    • 示例:hdfs secondarynamenode -start
YARN 管理命令
  1. yarn application -list

    • 列出所有活动的应用程序。
    • 示例:yarn application -list
  2. yarn application -kill [appId]

    • 终止一个应用程序。
    • 示例:yarn application -kill application_1234567890123456
  3. yarn node -list

    • 列出所有节点的状态。
    • 示例:yarn node -list
  4. yarn cluster -metrics

    • 显示集群的度量信息。
    • 示例:yarn cluster -metrics
  5. yarn jar [jarFile] [mainClass] [args]

    • 提交一个MapReduce作业。
    • 示例:yarn jar myjob.jar com.example.MyJob
其他命令
  1. hadoop version

    • 显示Hadoop的版本信息。
    • 示例:hadoop version
  2. hadoop classpath

    • 显示Hadoop的类路径。
    • 示例:hadoop classpath
相关推荐
元63317 小时前
spark和hadoop之间的对比和联系
大数据·hadoop·spark
哥不是小萝莉19 小时前
Hadoop和Spark大数据挖掘与实战
hadoop·ai·spark
lix的小鱼20 小时前
spark和Hadoop之间的对比和联系
大数据·hadoop·spark
TTBIGDATA1 天前
如何将 Apache Hudi 接入 Ambari?完整部署与验证指南
大数据·hadoop·ambari·hudi·bigtop·湖仓·自定义组件集成
IT成长日记1 天前
【Hive入门】Hive数据导出完全指南:从HDFS到本地文件系统的专业实践
hive·hadoop·hdfs·数据导出
大数据魔法师1 天前
Hadoop生态圈框架部署 - Windows上部署Hadoop
大数据·hadoop·windows
渣渣盟1 天前
大数据开发环境的安装,配置(Hadoop)
大数据·hadoop·分布式
IT成长日记2 天前
【Hive入门】Hive查询语言(DQL)完全指南:从基础查询到高级分析
数据仓库·hive·hadoop·dql操作
橘猫云计算机设计2 天前
springboot基于hadoop的酷狗音乐爬虫大数据分析可视化系统(源码+lw+部署文档+讲解),源码可白嫖!
数据库·hadoop·spring boot·爬虫·python·数据分析·毕业设计
宅小海2 天前
spark和Hadoop的区别和联系
大数据·hadoop·spark