hive导入nginx日志
2014-03-28 18:04
232 查看
将nginx日志导入到hive中的方法
1 在hive中建表
导入后日志格式为
第二种方法导入
注意:这个方法在建表后,使用查询语句等前要先执行
hive> add jar /home/hjl/hive/lib/hive_contrib.jar;
导入后的格式
如果文件数据是纯文本,可以使用 STORED AS TEXTFILE。如果数据需要压缩,使用 STORED AS SEQUENCE 。
导入日志命令
hive>load data local inpath '/home/log/map.gz' overwrite into table log;
导入日志支持.gz等格式
参考http://www.johnandcailin.com/blog/cailin/exploring-apache-log-files-using-hive-and-hadoop
1 在hive中建表
CREATE TABLE apachelog (ipaddress STRING, identd STRING, user STRING,finishtime STRING,requestline string, returncode INT, size INT,referer string,agent string) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.dynamic_type.DynamicSerDe'WITH SERDEPROPERTIES ('serialization.format'='org.apache.hadoop.hive.serde2.thrift.TCTLSeparatedProtocol','quote.delim'='("|\\[|\\])','field.delim'=' ','serialization.null.format'='-')STORED AS TEXTFILE;
导入后日志格式为
203.208.60.91 - - 05/May/2011:01:18:47 +0800 GET /robots.txt HTTP/1.1 404 1238 Mozilla/5.0
第二种方法导入
注意:这个方法在建表后,使用查询语句等前要先执行
hive> add jar /home/hjl/hive/lib/hive_contrib.jar;
CREATE TABLE log (host STRING,identity STRING,user STRING,time STRING,request STRING,status STRING,size STRING,referer STRING,agent STRING) ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe' WITH SERDEPROPERTIES ("input.regex" = "([^ ]*) ([^ ]*) ([^ ]*) (-|\\[[^\\]]*\\]) ([^ \"]*|\"[^\"]*\") (-|[0-9]*) (-|[0-9]*)(?: ([^ \"]*|\".*\") ([^ \"]*|\".*\"))?","output.format.string" = "%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s %9$s")STORED AS TEXTFILE;
导入后的格式
203.208.60.91 - - [05/May/2011:01:18:47 +0800] "GET /robots.txt HTTP/1.1" 404 1238 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
如果文件数据是纯文本,可以使用 STORED AS TEXTFILE。如果数据需要压缩,使用 STORED AS SEQUENCE 。
导入日志命令
hive>load data local inpath '/home/log/map.gz' overwrite into table log;
导入日志支持.gz等格式
参考http://www.johnandcailin.com/blog/cailin/exploring-apache-log-files-using-hive-and-hadoop
相关文章推荐
- hive导入 nginx 或 apache 日志
- Hive导入Apache Nginx等日志与分析
- hive导入apache nginx等日志与分析
- 自动将每日的日志增量导入到hive中
- hive日志文件的批量导入
- hive1.2.2+hadoop2.7.3导入米骑测试日志以及数据优化(五)
- 使用Hive的正则解析器RegexSerDe分析nginx日志
- shell脚本 日志文件批量导入hive
- hive 分析nginx的access.log日志
- 通过Hive及其Udf函数进行Nginx日志分析
- 业务系统JSON日志通过python处理并导入Hive方案
- 使用 Heka 导入自定义的nginx日志到Elasticsearch
- 用Hive分析nginx日志——1
- 用Hive分析nginx日志
- 使用hive分析nginx访问日志方法
- 使用hive分析nginx访问日志方法
- hive分析nginx日志之UDF清洗数据
- hive分析nginx日志之UDF清洗数据
- 2000-使用Hive的正则解析器RegexSerDe分析Nginx日志
- 实战6 Nginx的web日志导入到MongoDB数据库