hive要打开,另一边root@hadoop-virtual-machine:/# hdfs dfs -ls /user/hive查看hdfs上都有些什么,
然后把数据文件导入到hdfs上 ,root@hadoop-virtual-machine:/# hdfs dfs -put /opt/os.txt /user/hive/
hive那边用show databases;查看当前都有什么数据库
然后创建表(此表是用来装导入进来的数据的)
hive> create table os
> (pathid string,nodeweight int,pathweight string,nodeid int,shutdown string)
> ROW FORMAT DELIMITED FIELDS TERMINATED BY ' ' LINES TERMINATED BY '\n'
> STORED AS TEXTFILE;
要保证创建的表的格式要和数据文件中的格式一样,例如字段间的间隔符是什么行与行间的间隔符都要进行限定,
导入数据 hive> load data inpath '/user/hive/os.txt' into table os;
hive> select * from os;
OK
["12->22"] 9638 [52] 12 false
["19->78"]