如果是把数据放在了hdfs系统,那么我们如何访问他们呢?
1.hdfs查看文件夹
./hdfs dfs -ls hdfs://mycluster/output/online/
2.hdfs创建目录dfs创建文件夹
./hdfs dfs -mkdir hdfs://mycluster/output/online/
./hdfs dfs -mkdir hdfs://mycluster/output/online/pv
这里有个坑,如果你直接创建多级目录,会得到错误提示,所以要一级一级的去建立目录才行!
16/12/22 18:32:54 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
mkdir: `hdfs://mycluster/output/online/pv': No such file or directory
3.创建hive表
CREATE EXTERNAL TABLE `pv_table`(
`city_name` string,
`pv` string,
`product_line` string)
PARTITIONED BY (
`day` string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ' '
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'hdfs://mycluster/output/online/pv')