# nginx-kafka-log **Repository Path**: wanghehan/nginx-kafka-log ## Basic Information - **Project Name**: nginx-kafka-log - **Description**: 使用Nginx Kafka Module 收集页面用户行为数据 发送到kafka - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-06 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # nginx-kafka-log #### 介绍 使用Nginx Kafka Module 收集页面用户行为数据 发送到kafka #### 软件架构 * 系统版本: macOS Big Sur 11.0 Beta版 * Zookeeper: 3.6.1 * Kafka: * Nginx: #### 搭建流程 1. 安装zk * `brew install zookeeper` * `zkServer start` 2. 安装kafka * `brew install kafka` * 修改server.properties ```zookeeper.connect=localhost:2181/kafka``` * `kafka-server-start server.properties` 3. 安装nginx `wget http://nginx.org/download/nginx-1.19.2.tar.gz` 下载并解压 4. 安装[ngx_kafka_module](https://github.com/brg-liuwei/ngx_kafka_module) ```shell # 1.安装module以及nginx git clone https://github.com/brg-liuwei/ngx_kafka_module # cd /path/to/nginx ./configure --add-module=/Users/happyelements/lagou/ngx_kafka_module make sudo make install ``` ```shell # 2 修改配置文件 cd /usr/local/nginx vim nginx.conf # http { # some other configs kafka; kafka_broker_list 127.0.0.1:9092; server { # some other configs location = /t1 { # optional directive: kafka_partition [ | auto] # # kafka_partition auto; # default value # kafka_partition 0; # kafka_partition 1; kafka_topic topic_1; } } } ``` ```shell #启动nginx /usr/local/nginx/sbin/nginx ``` 5. 测试 ```shell $ curl localhost/t1 -d "hello ngx_kafka_module" ``` ```shell $ kafka-console-consumer --bootstrap-server localhost:9092 -topic topic_1 hello ngx_kafka_module hello ngx_kafka_module ``` #### 演示 1. 演示视频见doc目录