hadoop 常用命令,2024年最新终于搞明白了

slave 节点重启(停止、启动) datanode 服务:
$ ./sbin/hadoop-daemon.sh stop datanode
$ ./sbin/hadoop-daemon.sh start datanode

查看 HDFS 文件中系统的DFS使用情况:
$ hadoop fs -du -s -h /

垃圾清理(多次执行):
$ hadoop fs -expunge

datanode 使用率占满&配置容量显示为0的问题【DFS Used%: 100.00% & Configured Capacity: 0 (0 B)】
$ hadoop dfsadmin -report
查看到使用率占满,显示:
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

Configured Capacity: 0 (0 B)
Present Capacity: 0 (0 B)
DFS Remaining: 0 (0 B)
DFS Used: 0 (0 B)
DFS Used%: NaN%
Under replicated blocks: 76125
Blocks with corrupt replicas: 0
Missing blocks: 76125
Missing blocks (with replication factor 1): 21993


Live datanodes (1):

Name: 192.168.1.188:50010 (hadoop01)
Hostname: hadoop01
Decommission Status : Normal
Configured Capacity: 0 (0 B)
DFS Used: 0 (0 B)
Non DFS Used: 0 (0 B)
DFS Remaining: 0 (0 B)
DFS Used%: 100.00%
DFS Remaining%: 0.00%
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 Mar 25 17:02:43 CST 2024

配置容量显示为0了:
Configured Capacity: 0 (0 B)

尝试多种方法、最终原因是 slave 中配置的 datanode 节点 hostname 配置成了  localhost 而导致的问题。
vi salve 把配置的 datanode 主机名配置为  hadoop01 后,重启 datanode 服务,问题就解决了。

$ ./sbin/hadoop-daemon.sh stop datanode
$ ./sbin/hadoop-daemon.sh start datanode
$ hadoop dfsadmin -report
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

Configured Capacity: 98337751040 (91.58 GB)
Present Capacity: 65340043264 (60.85 GB)
DFS Remaining: 61911707648 (57.66 GB)
DFS Used: 3428335616 (3.19 GB)
DFS Used%: 5.25%
Under replicated blocks: 73720
Blocks with corrupt replicas: 0
Missing blocks: 82
Missing blocks (with replication factor 1): 21993


Live datanodes (1):

Name: 192.168.1.188:50010 (hadoop01)
Hostname: hadoop01
Decommission Status : Normal
Configured Capacity: 98337751040 (91.58 GB)
DFS Used: 3428335616 (3.19 GB)
Non DFS Used: 32997707776 (30.73 GB)
DFS Remaining: 61911707648 (57.66 GB)
DFS Used%: 3.49%
DFS Remaining%: 62.96%
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: 1
Last contact: Mon Mar 25 17:27:05 CST 2024

Hive建表和LOAD数据:

– 普通表(TextFile存储格式)
drop table if exists testdb.tb_test03;
create table testdb.tb_test03 (
id int, 
info string,
cnt bigint)
– partitioned by (pt_sheng string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,’ LINES TERMINATED BY ‘\n’
STORED AS TextFile
– STORED AS INPUTFORMAT 
–    ‘org.apache.hadoop.mapred.TextInputFormat’ 
–  OUTPUTFORMAT 
–    ‘org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat’
LOCATION ‘hdfs://192.168.1.188:9000/user/hive/warehouse/testdb.db/tb_test03’
;

–  hadoop fs -ls /user/hive/warehouse/testdb.db/tb_test03.txt

show tables;
show create table testdb.tb_test03;
select * from testdb.tb_test03;

– 方法1:
$ echo ‘1,jack,95
2,frank,96
3,lucy,97
4,hack,99’ > /opt/frank/tb_test03.txt

– hiveSQL: load from Local OS dir
LOAD DATA LOCAL INPATH ‘/opt/frank/tb_test03.txt’ OVERWRITE INTO TABLE tb_test03;

– 方法2:
– shell_cmd: 先拷贝到 hdfs, 再从 hdfs 路径 load
– $  hadoop fs -rm /frank/tb_test03.txt
– $  hadoop fs -put /opt/frank/tb_test03.txt /frank/
– $  hadoop fs -cat /frank/tb_test03.txt
– – hiveSQL: load from HDFS FileSystem dir
– LOAD DATA INPATH ‘/frank/tb_test03.txt’ OVERWRITE INTO TABLE tb_test03;
select * from tb_test03;

– load后会在配置文件决定的固定目录下产生一个表名对应的目录,目录下为对应的数据文件
$  hadoop fs -ls /user/hive/warehouse/testdb.db/tb_test03/

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数大数据工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年大数据全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上大数据开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加VX:vip204888 (备注大数据获取)
img

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

助,可以添加VX:vip204888 (备注大数据获取)**
[外链图片转存中…(img-y4OluHuA-1712966198404)]

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 24
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值