1.创建测试文件

echo "Hello from slave1 and slave2!" > /tmp/hello.txt

2.查看创建是否成功

cat /tmp/hello.txt

创建成功

3.上传到hdfs

/opt/hadoop-3.4.1/bin/hdfs dfs -put /tmp/hello.txt /

4.读hdfs

/opt/hadoop-3.4.1/bin/hdfs dfs -cat /hello.txt

5.查看blocks分布

/opt/hadoop-3.4.1/bin/hdfs fsck /hello.txt -files -blocks -locations

分布正常

6.模拟故障(拔掉一个 DN)

pkill -f "slave2"

查看hdfs状态(10分钟后再看,jps看slave2已经杀掉了,但是还有心跳)

/opt/hadoop-3.4.1/bin/hdfs dfsadmin -report

通过检验端口号是否释放进一步确认

ss -tuln | grep 9872

确认已经kill slave2

7.在slave2离线时再次读文件

/opt/hadoop-3.4.1/bin/hdfs dfs -cat /hello.txt

发现即使有报错,也输出了文件内容“Hello from slave1 and slave2!”

通过这个简单的验证,熟悉了创建文件,上传文件(put),读取文件(cat),block分布,以及hdfs的高可用。

更多推荐