Advertisement

hadoop学习与海量日志分析(二)HBase

阅读量:

先前的一篇文献阐述了借助MapReduce技术对Web日志进行解析的流程。本文在此前研究的基础上,进一步引入HBase技术以实现对Web日志的处理。

1、Web日志分析

在Web日志中,每一条记录均反映了用户的访问操作,以下为某条日志的具体示例:

复制代码

每条日志记录均包含用户的IP地址、访问时间以及所访问页面的相关信息等。

2、导入日志文件,并将其存储至HBase数据库中

代码实现:

复制代码
  public static void main(String args[]) throws IOException, ClassNotFoundException, InterruptedException

    
 	{
    
 		
    
 		/*	read data from file ,write in HBase */
    
 	    String strRowKey = "";
    
 	    String strIP = "";
    
 	    String strURL = "";
    
 	    String fileName = args[0];
    
 	    Configuration conf = HBaseConfiguration.create();
    
 	    HTable tab

全部评论 (0)

还没有任何评论哟~