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;