# go-kafka-consumer **Repository Path**: zhang-yu-1/go-kafka-consumer ## Basic Information - **Project Name**: go-kafka-consumer - **Description**: go语言读取kafka数据 - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2021-06-30 - **Last Updated**: 2021-06-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # go-kafka-consumer #### 介绍 go语言读取kafka数据 #### 软件架构 读取kafka数据,写入到mysql做数据统计,mysql数据库暂时设计为每天一张表 #### 安装教程 1. 扩展库 go get -u gopkg.in/confluentinc/confluent-kafka-go.v1/kafka go get github.com/astaxie/beego 2. kafka环境请自行安装 安装好后创建topics bin/kafka-topics.sh --create --zookeeper 127.0.0.1:2181 --replication-factor 1 --partitions 2 --topic game_server #### 使用说明 1. 配置文件 runmode = dev #kafka配置 broker = 127.0.0.1:9092 group = gameserver-consumer-group topics = game_server #数据库配置 dbuser = root dbpassword = root dbhost = 127.0.0.1 dbport = 3306 dbname = doubi #日志配置 logpath = ../logs/consumer.log #最多保留Statm个数 maxRawPre = 3 2. 构建 & 运行 ./build.sh ./run.sh 3. 对应结构体可参考action.go中 ActionLog type ActionLog struct { Uid uint32 `json:"user_id"` Zid uint32 `json:"zid"` BigPlat uint32 `json:"bigplat"` ChannelId uint32 `json:"channel_id"` ItemClass uint32 `json:"item_class"` ItemBeCnt uint32 `json:"item_before_op_cnt"` ItemOpCnt uint32 `json:"item_op_cnt"` Time uint32 `json:"time"` NickName string `json:"nickname"` Platid string `json:"platid"` SubPlat string `json:"subplat"` OpType string `json:"op_type"` SubType string `json:"sub_type"` ItemPos string `json:"item_pos"` ItemId string `json:"item_id"` Date string `json:"date"` Deviceid string `json:"deviceid"` } #### 参与贡献 1. kafka库 [https://github.com/confluentinc/confluent-kafka-go] 2. beego [https://github.com/astaxie/beego] 3. concat me for qq 670450173 #### 码云特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)