作用
官方文档中没有说明
发现生产环境中使用到该服务
后续需要源代码分析再更新其他信息
创建目录
mkdir /apps/svr/falcon-plus/kafka_consumer/{bin,config,logs} -p
配置文件
/apps/svr/falcon-plus/kafka_consumer/config/cfg.json
{
"log_level": "info",
"http": {
"enabled": true,
"listen": "0.0.0.0:6850"
},
"consumer": {
"kafkaVersion": "low",
"topics": ["vipfalcon"],
"group": "vipfalcon_trend_20190517",
"offset": "newest",
"offsetTimeout": 10,
"concurrent": 32,
"zookeeper": "ns-yun-020022.133.com:2181,ns-yun-020023.133.com:2181,ns-yun-020024.133.com:2181",
"kafka": ["ns-yun-020022.133.com:9092","ns-yun-020023.133.com:9092","ns-yun-020024.133.com:9092"]
},
"trend": {
"enabled": true,
"batch": 200,
"connTimeout": 1000,
"callTimeout": 5000,
"maxConns": 32,
"maxIdle": 32,
"replicas": 500,
"cluster": {
"trend-00" : "xx.xxx.xx.21:6990",
"trend-01" : "xx.xxx.xx.22:6990",
"trend-02" : "xx.xxx.xx.23:6990",
"trend-03" : "xx.xxx.xx.24:6990"
}
},
"transfer": {
"enabled": true,
"batch": 200,
"retry": 1,
"connTimeout": 1000,
"callTimeout": 5000,
"maxConns": 32,
"maxIdle": 32,
"cluster": {
"transfer-00": "xx.xxx.xx.29:8443"
}
},
"percent_check": {
"cpu.idle": true,
"cpu.user": true,
"cpu.nice": true,
"cpu.system": true,
"cpu.iowait": true,
"cpu.irq": true,
"cpu.softirq": true,
"cpu.steal": true,
"cpu.guest": true
},
"ignore_host": {
"localhost": true,
"localhost.example": true,
"localhost.localdomain": true,
"local_host": true
}
}
启动测试
[root@ns-yun-020026 kafka_consumer]# bin/falcon-kafka_consumer -c config/cfg.json
2020/08/24 09:00:00 cfg.go:102: g.ParseConfig ok, file config/cfg.json
2020/08/24 09:00:00 proc.go:29: proc.Start, ok
INFO[0000] send.Start, ok
INFO[0000] start to init consumer group of low version kafka
2020/08/24 09:00:00 http.go:39: http.startHttpServer ok, listening 0.0.0.0:6850
2020/08/24 09:00:00 structs.go:21: Connected to xx.xxx.xx.22:2181
2020/08/24 09:00:00 structs.go:21: Authenticated: id=72057612521898042, timeout=4000
2020/08/24 09:00:00 structs.go:21: Re-submitting `0` credentials after reconnect
2020/08/24 09:00:01 main.go:20: 186155 register signal notify
启动文件
/usr/lib/systemd/system/falcon-kafka_consumer.service
[Unit]
Description=falcon kafka_consumer
After=network-online.target
Before=shutdown.target
[Service]
Type=simple
User=apps
Group=apps
LimitNOFILE=65535
ExecStart=/apps/svr/falcon-plus/kafka_consumer/bin/falcon-kafka_consumer -c /apps/svr/falcon-plus/kafka_consumer/config/cfg.json
Restart=always
StandardOutput=journal
启动
[root@ns-yun-020026 system]# systemctl status falcon-kafka_consumer.service
● falcon-kafka_consumer.service - falcon kafka_consumer
Loaded: loaded (/usr/lib/systemd/system/falcon-kafka_consumer.service; static; vendor preset: disabled)
Active: active (running) since Mon 2020-08-24 09:02:23 CST; 3s ago
Main PID: 186269 (falcon-kafka_co)
Memory: 3.6M
CGroup: /system.slice/falcon-kafka_consumer.service
└─186269 /apps/svr/falcon-plus/kafka_consumer/bin/falcon-kafka_consumer -c /apps/svr/falcon-plus/kafka_consumer/...
Aug 24 09:02:23 ns-yun-020026.133.com falcon-kafka_consumer[186269]: 2020/08/24 09:02:23 cfg.go:102: g.ParseConfig o...son
Aug 24 09:02:23 ns-yun-020026.133.com falcon-kafka_consumer[186269]: 2020/08/24 09:02:23 proc.go:29: proc.Start, ok
Aug 24 09:02:23 ns-yun-020026.133.com falcon-kafka_consumer[186269]: time="2020-08-24T09:02:23+08:00" level=info msg...ok"
Aug 24 09:02:23 ns-yun-020026.133.com falcon-kafka_consumer[186269]: time="2020-08-24T09:02:23+08:00" level=info msg...ka"
Aug 24 09:02:23 ns-yun-020026.133.com falcon-kafka_consumer[186269]: 2020/08/24 09:02:23 http.go:39: http.startHttpS...850
Aug 24 09:02:23 ns-yun-020026.133.com falcon-kafka_consumer[186269]: 2020/08/24 09:02:23 structs.go:21: Connected to...181
Aug 24 09:02:23 ns-yun-020026.133.com falcon-kafka_consumer[186269]: 2020/08/24 09:02:23 structs.go:21: Authenticate...000
Aug 24 09:02:23 ns-yun-020026.133.com falcon-kafka_consumer[186269]: 2020/08/24 09:02:23 structs.go:21: Re-submittin...ect
Aug 24 09:02:23 ns-yun-020026.133.com falcon-kafka_consumer[186269]: 2020/08/24 09:02:23 main.go:20: 186269 register...ify
Aug 24 09:02:25 ns-yun-020026.133.com falcon-kafka_consumer[186269]: time="2020-08-24T09:02:25+08:00" level=error ms...76"
Hint: Some lines were ellipsized, use -l to show in full.