Hadoop 的使用

hadoop:
hadoop启动:./sbin/start-dfs.sh
hadoop关闭:./sbin/stop-dfs.sh
bin文件用于在HDFS创建数据
HDFS 中创建用户目录:
./bin/hdfs dfs -mkdir -p /user/hadoop

往input中放数据:
./bin/hdfs dfs -mkdir input
./bin/hdfs dfs -put ./etc/hadoop/*.xml input

查看input文件夹内容:
./bin/hdfs dfs -ls input

运行类子:
./bin/hadoop jar ./share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar grep input output 'dfs[a-z.]+'

查看的是位于 HDFS 中的输出结果 :  
./bin/hdfs dfs -cat output/*

从HDFS中把数据取回本地:
rm -r ./output    # 先删除本地的 output 文件夹(如果存在)
./bin/hdfs dfs -get output ./output     # 将 HDFS 上的 output 文件夹拷贝到本机
 cat ./output/*

./bin/hdfs dfs -rm -r output    # 删除 HDFS 中的output 文件夹

posted @ 2017-10-10 20:07  soyosuyang  阅读(253)  评论(0)    收藏  举报