• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
邹天得
博客园    首页    新随笔    联系   管理    订阅  订阅
hdfs常用命令

1.在spark-shell中查询的结果保存成文件

  /home/mr/spark/bin/spark-shell (--master spark://$(echo `hostname`):7077  --executor-memory 5G --total-executor-cores 3,四川现场不加默认5G、5核)

  sqlContext.sql("use zxvmax")

  sqlContext.sql("select count(1) from t252_table_nsn where  p_provincecode=510000 and p_date='2017-03-06' and p_hour=12").show(10000).rdd.saveAsTextFile("/user/hadoop/output")

  hadoop fs -getmerge /user/hadoop/output local_file

 

2.hdfs ls按时间排序

hadoop fs -ls /zxvmax/telecom/lte/nds_l_textfile/textfile_t166/p_provincecode=510000/p_date=2017-03-21/p_hour=7 | sort -r -k6,7
-rwxr-xr-x 3 mr users 158 2017-03-21 07:46 /zxvmax/telecom/lte/nds_l_textfile/textfile_t166/p_provincecode=510000/p_date=2017-03-21/p_hour=7/part-00007
-rwxr-xr-x 3 mr users 189 2017-03-21 07:17 /zxvmax/telecom/lte/nds_l_textfile/textfile_t166/p_provincecode=510000/p_date=2017-03-21/p_hour=7/part-00000
-rwxr-xr-x 3 mr users 186 2017-03-21 07:17 /zxvmax/telecom/lte/nds_l_textfile/textfile_t166/p_provincecode=510000/p_date=2017-03-21/p_hour=7/part-00012
-rwxr-xr-x 3 mr users 172 2017-03-21 07:17 /zxvmax/telecom/lte/nds_l_textfile/textfile_t166/p_provincecode=510000/p_date=2017-03-21/p_hour=7/part-00004
-rwxr-xr-x 3 mr users 157 2017-03-21 07:17 /zxvmax/telecom/lte/nds_l_textfile/textfile_t166/p_provincecode=510000/p_date=2017-03-21/p_hour=7/part-00003

 

3.进入hdfs,su hdfs

4.hdfs dfs -ls /zxvmax/telecom/lte/netmaxl/nbi

 或hadoop fs -ls /zxvmax/telecom/lte/nds_l/t121/p_provincecode=510000/p_date=2017-03-16/p_hour=18

5.在hdfs上推数据:

建表时,为了测试,建议用textfile格式:

STORED AS textfile LOCATION '/zxvmax/telecom/lte/subject/lte_function_ems_pm_cellthrput/';

①在spark SQL上建分区:

alter table lte_function_ems_pm_cellthrput add partition (p_provincecode=510000,p_date='2016-08-16',p_hour=11);

//show partitions;//查看分区

②在hdfs上推数据:

1.txt的内容(unix utf-08):

2016-03-05,634887,1,31.11,32.11

hdfs dfs -put /home/10192057/1.txt /zxvmax/telecom/lte/subject/lte_function_ems_pm_cellthrput/p_provincecode=510000/p_date=2016-03-05/p_hour=1

③也可以删除数据:

hdfs dfs -rm /zxvmax/telecom/lte/subject/lte_function_ems_pm_cellthrput/p_provincecode=510000/p_date=2016-03-05/p_hour=1/1.txt

hdfs dfs -rm -r 目录

hadoop fs -rm

④查看建表时的存储路径:

desc formatted lte_qcell_prru_location;

 

   

posted on 2017-03-21 10:33  邹天得  阅读(945)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3