【项目三】大数据离线分析平台

1.使用eclipse导入javaweb项目 test-aura

具体导入方法使用下面的连接

https://blog.csdn.net/jenrey/article/details/80457591

2.修改数据埋点收集的数据发送Nginx的位置


注意修改后需要重新部署到Tomcat中

3.点击页面在Nginx端产生数据

http://localhost:8080/test-aura/

随意点点

[hadoop@hadoop04 ~]$ su

[root@hadoop04 ~]# cd /var/log/nginx

[root@hadoop04 nginx]# tail -F access.log 


4.编写JavaSDK代码

用来写后台的两种数据埋点

5.编写连接Nginx的代码

然后测试代码hbase-test


上述做完就是:数据通过编写数据埋点 -》Nginx服务器上面了 

6.使用flume把Nginx的数据存入HDFS

现在我们要做的就是通过Flume读取Nginx上面的数据存到HDFS

source:exec

channel:memory

sink:hdfssink

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /var/log/nginx/access.log



# Use a channel which buffers events in memory
a1.channels.c1.type = memory


# Describe the sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://hadoop1:9000/flume/%Y%m%d
a1.sinks.k1.hdfs.useLocalTimeStamp = true    #设置上面的年月日,一定要设置这个参数
a1.sinks.k1.hdfs.fileType = DataStream
a1.sinks.k1.hdfs.rollInterval = 0
a1.sinks.k1.hdfs.rollSize = 10240
a1.sinks.k1.hdfs.rollCount = 0



# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

[hadoop@hadoop04 ~]$ flume-ng agent --conf conf --conf-file file2hdfs.properties --name a1 -Dflume.hadoop.logger=INFO,console    

注意权限需要在root用户下才能访问Nginx的目录


随意点几下这样在HDFS中就有数据了


7.MR解析数据


直接从网上下载解析纯真IP地址的java代码就是别人封装好的就行。然后直接创建对象调用方法就可以了。

解析浏览器信息就用别人写好的代码直接解析就行了。

本文已经下载好了。就是在hbase-test下面org.gh.ip这个包下面






猜你喜欢

转载自blog.csdn.net/jenrey/article/details/80462497