hdfs常用命令

URI
统一资源定位符
jdbc:mysql://localhost:3306
hdfs://mini2:9000
schema 协议ip端口
指定客户端在访问时访问那个ip的那个端口
hadoop.tmp.dir 每个进程工作时的数据目录
mapred-site.xml 中hdfs.framework的默认值是local,表示单机环境下,改为yarn表示集群环境下

hadoop fs -ls / 查看根目录
hadoop fs -put aaa / 上传当前目录的aaa 到dfs的根目录
hadoop fs -cat /aaa 查看
hadoop fs -get /README.txt ./soft 下载文件,第二个参数缺省时为当前目录
hadoop fs -mkdir -p /wordCount/input 创建文件夹
运行自己的wordCount程序
hadoop jar hadoop-mapreduce-examples-2.6.5.jar wordcount /wordCount/input/README.txt /wordCount/output
hdfs命令
hadoop fs -chown user1:usergroup1 /ttt 修改文件的用户和组,因为hdfs系统的文件可以任意指定,弱
hadoop fs -setrep 3 /yyy 如果副本数超过了节点数,那么只会存节点数相等的副本数,但是浏览器中查看的还是10个副本,只会记录的namenode的元数据中,真实的副本数还得看datanode的数量

hadoop fs - moveToLocal /aaa/bbb/cc/dd /home/hadoop/a.txt 从hdfs剪切粘贴到本地

hadoop fs -appendToFile ./hello.txt hdfs://hadoop-server01:9000/hello.txt
可以简写为:
Hadoop fs -appendToFile ./hello.txt /hello.txt 追加一个文件到已经存在的文件末尾
hadoop fs -cat /hello.txt 显示文件内容

hadoop fs -tail /weblog/access_log.1 显示一个文件的末尾
hadoop fs -text /weblog/access_log.1 以字符形式打印一个文件的内容
hadoop fs -count /aaa/ 统计一个指定目录下的文件节点数量

 安全模式

hadoop dfsadmin -safemode enter
hadoop dfsadmin -safemode leave

在命令行里查看报告(可以不用访问页面)

hdfs dfsadmin -report

(查看文件用了那些块)hdfs  fsck /test128  -blocks -locations

hdfs 判断文件是否存在

hadoop fs -test -e /hadoop fs -test -e /movie/top_n_city/output
if [ $? -ne 0 ]; then
echo "Directory not exists!"
fi

原文地址:https://www.cnblogs.com/rocky-AGE-24/p/6872373.html