Ubuntu 中 HDFS 数据存储机制与配置
一、整体架构与数据流转
二、存储单元与副本机制
hdfs fsck 检查文件与块健康。三、本地磁盘目录与配置
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:///data/hadoop/namenode</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:///data/hadoop/datanode</value>
</property>
</configuration>
$HADOOP_HOME/bin/hdfs namenode -format
$HADOOP_HOME/sbin/start-dfs.sh
四、常用操作与验证
hdfs dfs -mkdir -p /user/input
hdfs dfs -put localfile.txt /user/input/
hdfs dfs -ls /user/input
hdfs dfs -cat /user/input/localfile.txt
hdfs dfs -get /user/input/localfile.txt ./
hdfs dfs -rm -r /user/output
hdfs dfs -setrep 3 /user/input/*
hdfs fsck /user/input/localfile.txt -files -blocks
hdfs dfsadmin -report
jps # 应见 NameNode、DataNode、SecondaryNameNode
# Web UI:NameNode http://<namenode-host>:9870
# Web UI:DataNode http://<datanode-host>:9864
五、性能与容量优化建议