housepower / clickhouse_sinker

Easily load data from kafka to ClickHouse
https://housepower.github.io/clickhouse_sinker
Apache License 2.0
515 stars 118 forks source link

编译后运行无法正常解析配置文件 #106

Closed WatchLucky closed 3 years ago

WatchLucky commented 3 years ago

不管是读取默认位置的配置文件还是通过参数指,都读取不出文件里配置的内容

./clickhouse_sinker

2021/01/14 14:30:01 Initial [clickhouse_sinker] 2021/01/14 14:30:01 Initial [clickhouse_sinker] complete INFO[2021-01-14T14:30:01+08:00] Run http server http://10.30.4.40:2112
INFO[2021-01-14T14:30:01+08:00] going to apply the first config: {"Kafka":{"Brokers":"","Version":"2.2.1","TLS":{"Enable":false,"CaCertFiles":"","ClientCertFile":"","ClientKeyFile":"","InsecureSkipVerify":false},"Sasl":{"Enable":false,"Mechanism":"","Username":"","Password":"","GSSAPI":{"AuthType":0,"KeyTabPath":"","KerberosConfigPath":"","ServiceName":"","Username":"","Password":"","Realm":"","DisablePAFXFAST":false}}},"Clickhouse":{"DB":"","Hosts":null,"Port":0,"Username":"","Password":"","DsnParams":"","RetryTimes":0},"Task":{"Name":"","KafkaClient":"kafka-go","Topic":"","ConsumerGroup":"","Earliest":false,"Parser":"fastjson","CsvFormat":null,"Delimiter":"","TableName":"","AutoSchema":false,"ExcludeColumns":null,"dims":null,"DynamicSchema":{"Enable":false,"Cluster":"","DistTableName":"","MaxDims":0},"flushInterval":3,"bufferSize":1048576,"minBufferSize":8192,"msgSizeHint":1000,"layoutDate":"2006-01-02","layoutDateTime":"2006-01-02T15:04:05Z07:00","layoutDateTime64":"2006-01-02T15:04:05Z07:00"},"LogLevel":"info"} INFO[2021-01-14T14:30:01+08:00] : Prepare sql=> INSERT INTO . () VALUES ()
panic: cannot create a new kafka reader with an empty topic

goroutine 90 [running]: github.com/segmentio/kafka-go.NewReader(0xc0000d8de0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...) /Users/60007943/Documents/go/pkg/mod/github.com/segmentio/kafka-go@v0.4.8/reader.go:536 +0x90b github.com/housepower/clickhouse_sinker/input.(KafkaGo).Init(0xc0000f3a00, 0xc00033c000, 0x0, 0x0, 0xc0000d8dd0, 0xc0000d6180, 0xc0000f3a00) /Users/60007943/Documents/go/src/clickhouse_sinker/input/kafka_go.go:111 +0x42d github.com/housepower/clickhouse_sinker/task.(Service).Init(0xc000386000, 0xc000386000, 0xeff224) /Users/60007943/Documents/go/src/clickhouse_sinker/task/task.go:104 +0x258 main.(Sinker).applyFirstConfig(0xc00030a340, 0xc00033c000, 0x4, 0x0) /Users/60007943/Documents/go/src/clickhouse_sinker/cmd/clickhouse_sinker/main.go:319 +0x124 main.(Sinker).applyConfig(0xc00030a340, 0xc00033c000, 0x0, 0x0) /Users/60007943/Documents/go/src/clickhouse_sinker/cmd/clickhouse_sinker/main.go:302 +0xfe main.(*Sinker).Run(0xc00030a340) /Users/60007943/Documents/go/src/clickhouse_sinker/cmd/clickhouse_sinker/main.go:251 +0x49b main.main.func2(0x0, 0x0) /Users/60007943/Documents/go/src/clickhouse_sinker/cmd/clickhouse_sinker/main.go:195 +0x45 github.com/housepower/clickhouse_sinker/util.Run.func1(0xf3acf0, 0xeed34d, 0x11) /Users/60007943/Documents/go/src/clickhouse_sinker/util/app.go:30 +0x2b created by github.com/housepower/clickhouse_sinker/util.Run /Users/60007943/Documents/go/src/clickhouse_sinker/util/app.go:29 +0x228

提示读取的配置都未空。

WatchLucky commented 3 years ago

下载最新版本的二进制文件 还是自己编译,都遇到这个问题 运行方式: ./dist/clickhouse_sinker --local-cfg-file clickhouse_sinker.json

文件内容: { "clickhouse": { "default": { "db": "default", "username": "admin", "password": "admin", "hosts": [ [ "10.30.4.40" ] ], "port": 9000 } }, "kafka": { "default": { "brokers": "10.31.4.44:9094", "version": "2.12.3" } }, "common": { "bufferSize": 90000, "minBufferSize": 1, "msgSizeHint": 1000, "flushInterval": 5, "logLevel": "debug" }, "tasks": { "logstash": { "name": "logstash", "kafkaClient": "kafka-go", "kafka": "default", "topic": "logstash", "consumerGroup": "logstash_sinker", "parser": "json", "clickhouse": "default", "tableName": "logstash", "autoSchema": true, "@desc_of_exclude_columns": "this columns will be excluded by insert SQL ", "excludeColumns": [ "day" ] } } }

我使用的姿势不对吗?

yuzhichang commented 3 years ago

sinker v1.8.0开始仅支持单task,相应地调整了配置文件格式。例子:https://github.com/housepower/clickhouse_sinker/blob/master/docker/test_auto_schema.json

WatchLucky commented 3 years ago

感谢。不过如果配置文件不对提示解析报错会不会更好一点。

yuzhichang commented 3 years ago

v1.8.1检测了几个常见的配置错误:clickhouse 集群拓扑为空,kafka brokers为空,task名为空。