在CentOS上部署和使用Hadoop分布式文件系统(HDFS)是一个常见的任务,尤其是在大数据处理和分析的场景中。以下是一个详细的使用案例分享,涵盖了从环境搭建到基本操作的各个方面。
/usr/local/hadoop
。/etc/profile
文件,添加Hadoop的路径和库路径。source /etc/profile
命令使配置生效。hdfs namenode -format
命令,初始化文件系统。/opt/hadoop/sbin/start-dfs.sh
jps
命令检查进程,确保NameNode和DataNode正在运行。http://namenode-host:50070
)访问HDFS。hdfs dfs -put /usr/local/hadoop-2.8.5/NOTICE.txt /input/
hdfs dfs -get /input/README.txt ./hdfs_backup.txt
hdfs dfs -rm /input/README.txt
hdfs dfs -rm -r /output
hdfs dfs -mkdir /output
hdfs dfs -mkdir -p /output/abc/123
hdfs dfs -cp /input/NOTICE.txt /input/NOTICE2.txt
hdfs dfs -mv /input/NOTICE.txt /input/NOTICE3.txt
hdfs dfs -cat /input/NOTICE3.txt
hdfs-site.xml
文件,添加相关配置。通过以上步骤,您可以在CentOS上成功搭建和配置HDFS,并进行基本操作和高级配置与优化。根据具体需求和环境,选择最适合的配置策略。