hadoop笔记



ubuntu下安装

http://www.powerxing.com/install-hadoop/


centos下安装



hadoop入门进阶课程


spark入门实战系列


hadoop数据分析平台




hadoop命令


和linux基本命令很像


cd到hadoop安装目录


对dfs的操作

执行 NameNode 的格式化

./bin/hdfs namenode -format


启动hadoop

./sbin/start-dfs.sh


在HDFS中创建用户目录

./bin/hdfs dfs -mkdir -p /user/hadoop


在HDFS中创建目录

./bin/hdfs dfs -mkdir /user/hadoop/input


从linux上传文件到hdfs

./bin/hdfs dfs -put ./etc/hadoop/*.xml /user/hadoop/input


查看HDFS文件列表

./bin/hdfs dfs -ls /user/hadoop/input


查看HDFS文件的命令

./bin/hdfs dfs -cat output/*


将 HDFS 上的 output 文件夹拷贝到本机

./bin/hdfs dfs -get /user/hadoop/output ./output


在HDFS上将文件从源路径复制到目标路径

./bin/hdfs dfs -cp /user/hadoop/input/22.txt /user/hadoop/input/11.txt


文件连接getmerge

使用方法:hadoop fs -getmerge <src> <localdst> [addnl]

接受一个源目录和一个目标文件作为输入,并且将源目录中所有的文件连接成本地目标文件。addnl是可选的,用于指定在每个文件结尾添加一个换行符。

假设在你的hdfs集群上有一个/user/hadoop/output目录
里面有作业执行的结果(多个文件组成)part-000000,part-000001,part-000002
然后你想把所有的文件合拢来一起看 可以使用命令:

./bin/hdfs dfs -getmerge /user/hadoop/output/ ~/re.txt



在hdfs指定目录下新建一个空文件

./bin/hdfs dfs -touchz /user/hadoop/input/11.txt


将HDFS上某个文件重命名

./bin/hdfs dfs -mv /user/hadoop/input/11.txt /user/hadoop/input/22.txt


删除HDFS下output 文件夹

./bin/hdfs dfs -rm -r /user/hadoop/output


关闭 Hadoop

./sbin/stop-dfs.sh




hadoop初级到资深


常见错误


错误:java.lang.IllegalArgumentException: Wrong FS: hdfs:/, expected: file:///


解决方法:
   把hadoop集群上的core-site.xml和hdfs-site.xml放到工程的src目录下

或者

conf.addResource(newPath("/home/hadoop/conf/core-site.xml"));


错误:Input path does not exist

修改代码:
FileInputFormat.addInputPath(job,new Path("hdfs://localhost:9000/anders/passwd"));
 FileOutputFormat.setOutputPath(job, new Path("hdfs://localhost:9000/anders/out1"));
这样才能正确,这个路径是根据core-site.xml里面的fs.default.name 





hadoop笔记

http://www.cnblogs.com/wuyudong/category/592600.html

http://blog.csdn.net/GarfieldEr007/article/category/2472155



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值