BigData-1 HDFS Command

BigData-1 HDFS Command
风铃夜行Part1
步骤3
ssh连接hadoop服务器
1 | ssh master |
建议开启五个tab,最后一个是主机,不执行任何ssh命令
terminal开启更多tab
左上角file->open tab
步骤4
在master的tab中执行:
1 | bash /scripts/hadoop/start-hadoop.sh |
在主机tab中执行:
1 | mkdir -p ~/Desktop/workspace/hdfs_op |
步骤5
如果需要创建多层目录,可以使用参数“-p”
主机tab:
查看目录列表
1 | hadoop fs -ls / |
创建目录
1 | hadoop fs -mkdir /newDir |
删除目录
1 | hadoop fs -rm -r /newDir |
步骤6
查看当前目录位置
1 | pwd |
创建hello.txt
1 | echo "hello" > hello.txt |
将文件放入数据库
1 | hadoop fs -put hello.txt /newDir |
查看数据库文件
1 | hadoop fs -cat /newDir/hello.txt |
从数据库下载文件hello_get.txt
1 | hadoop fs -get /newDir/hello.txt hello_get.txt |
本地查看文件
1 | cat hello_get.txt |
查看文件大小
上面这个是本地
下面这个是数据库
1 | ls -l hello.txt |
复制文件
1 | hadoop fs -cp /newDir/hello.txt /newDir/hello_cp.txt |
移动文件
也可以用来重命名
1 | hadoop fs -mv /newDir/hello.txt /newDir/hello_mv.txt |
权限管理
1 | hadoop fs -chmod 777 /newDir/hello_mv.txt |
删除文件
1 | hadoop fs -rm /newDir/hello_mv.txt |
步骤7
查看文件系统信息
1 | hadoop fs -df -h |
步骤8 习题
均在master tab完成
1 | hadoop fs -mkdir /mydir |
作业
Recommend References:
HDFS 07 - HDFS 性能调优之 合并小文件
Hadoop - getmerge Command
Merging small files into single file in hdfs
Part2
已实测希冀平台上所有程序均可运行。直接参考即可。
之后可能会更新HShell和作业提示。





