排查logstash2.4升级到5.0版本后kafka不兼容问题

参考文档:

/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-kafka-5.0.5/CHANGELOG.md
/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-kafka-5.0.5/DEVELOPER.md
/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-kafka-5.0.5/README.md.md
/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-kafka-5.0.5/lib/logstash/inputs/kafka.rb
/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-kafka-5.0.4/lib/logstash/outputs/kafka.rb

缘由:

之前对ELKB环境从2.4版本升级到最新的5.0稳定版本,主要升级步骤可以参考http://jerrymin.blog.51cto.com/3002256/1870205,后来发现kafka集群运行报错,现在把排查过程记录如下,仅供参考

之前环境:

logstash2.4

logstash-input-kafka-2.0.9

logstash-output-kafka-2.0.5

kafka_2.10-0.8.2.2.tgz

升级后环境:

logstash5.0

logstash-input-kafka-2.0.9

logstash-output-kafka-2.0.5

报错信息:

[2016-11-16T14:35:44,739][ERROR][logstash.inputs.kafka    ] Unknown setting ‘zk_connect‘ for kafka
[2016-11-16T14:35:44,741][ERROR][logstash.inputs.kafka    ] Unknown setting ‘topic_id‘ for kafka
[2016-11-16T14:35:44,741][ERROR][logstash.inputs.kafka    ] Unknown setting ‘reset_beginning‘ for kafka

实施步骤:

1,根据错误查看程序哪里报错

grep  "Unknown setting" /usr/share/logstash/ -R
/usr/share/logstash/logstash-core/lib/logstash/config/mixin.rb:          self.logger.error("Unknown setting ‘#{name}‘ for #{@plugin_name}")

2,查看程序相关代码,发现需要查看plugins的config定义文件等

    def validate_check_invalid_parameter_names(params)
      invalid_params = params.keys
      # Filter out parameters that match regexp keys.
      # These are defined in plugins like this:
      #   config /foo.*/ => ...
      @config.each_key do |config_key|
        if config_key.is_a?(Regexp)
          invalid_params.reject! { |k| k =~ config_key }
        elsif config_key.is_a?(String)
          invalid_params.reject! { |k| k == config_key }
        end
      end
      if invalid_params.size > 0
        invalid_params.each do |name|
          self.logger.error("Unknown setting ‘#{name}‘ for #{@plugin_name}")
        end
        return false
      end # if invalid_params.size > 0
      return true
    end # def validate_check_invalid_parameter_names

3,进入插件总目录查看具体信息

cd  /usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-kafka-5.0.5

发现重点查看如下文件

grep config ./* -R |awk ‘{print $1}‘ |uniq 
./CHANGELOG.md:
./DEVELOPER.md:See
./lib/logstash/inputs/kafka.rb:#
./lib/logstash/inputs/kafka.rb:
./README.md:-
Binary

1)首先看CHANGELOG.md,就有发现logstash-input-3.0.0.beta1开始就不在向后兼容,且剔除了jruby-kafka,注意这里有个坑2)会讲到,4.0.0版本说开始支持kafka 0.9,5.0.0又说开始

支持0.10切不向后兼容,这破坏性更新也是够了。看来问题找到了我的kafka版本是kafka_2.10-0.8.2.2.tgz,kafka版本不兼容导致的。

CHANGELOG.md部分文档如下:

## 5.0.4
  - Update to Kafka version 0.10.0.1 for bug fixes
## 5.0.0
  - Support for Kafka 0.10 which is not backward compatible with 0.9 broker.
## 4.0.0
  - Republish all the gems under jruby.
  - Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
  - Support for Kafka 0.9 for LS 5.x
## 3.0.0.beta1
 - Refactor to use new Java based consumer, bypassing jruby-kafka
 - Breaking: Change configuration to match Kafka‘s configuration. This version is not backward compatible

2)之前我看DEVELOPER.md文档时,看配置语法都正确,还以为是却少依赖关系jruby-kafka library呢,这个再logstash2.x是在用的(另外对比logstash5.x发现5版本少了不少插件。另外

kafka版本写的是0.8.1.1,看来这个DEVELOPER.md没有及时更新(与后面kafka.rb文件不一致),谁要是看到了麻烦及时更新啊,虽是小问题但是也可能误导我等屁民。当然也有可能是我没

有全面看文档导致的。

DEVELOPER.md文档结尾如下:

Dependencies
====================
* Apache Kafka version 0.8.1.1
* jruby-kafka library

3)开始看README.md文档,特意看了下kafka的兼容性 看来logstas-input-kafka5.0.5和logstash-output-kafka5.0.4只能用kafka0.10了。如果你想用Kafka0.9还想用Logstash5.0,你的

logstash-input-kafka和logstash-output-kafka只能降级版本到4.0.0了,这里都说他是中间过渡版本了,所以还是随大流吧。

## Kafka Compatibility
Here‘s a table that describes the compatibility matrix for Kafka Broker support. Please remember that it is good advice to upgrade brokers before consumers/producers 
since brokers target backwards compatibility. The 0.9 broker will work with both the 0.8 consumer and 0.9 consumer APIs but not the other way around.
| Kafka Broker Version | Logstash Version | Input Plugin | Output Plugin | Why? |
|:---------------:|:------------------:|:--------------:|:---------------:|:------|
| 0.8           | 2.0 - 2.x   | < 3.0.0 | <3.0.0 | Legacy, 0.8 is still popular |
| 0.9           | 2.0 - 2.3.x   |   3.0.0 | 3.0.0  | Intermediate release before 0.10 that works with old Ruby Event API `[]`  |
| 0.9          | 2.4, 5.0           |   4.0.0 | 4.0.0  | Intermediate release before 0.10 with new get/set API |
| 0.10         | 2.4, 5.0           |   5.0.0 | 5.0.0  | Track latest Kafka release. Not compatible with 0.9 broker |

4)现在看来只能升级kafka版本了。最后我看了下jar-dependencies发现了kafka-clients-0.10.0.1.jar

ls /usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-kafka-5.0.5/vendor/jar-dependencies/runtime-jars/
kafka-clients-0.10.0.1.jar  log4j-1.2.17.jar  lz4-1.3.0.jar  slf4j-api-1.7.21.jar  slf4j-log4j12-1.7.21.jar  snappy-java-1.1.2.6.jar

5)还有一个文件没有看,怀着好奇心我看了一眼,发现之前都白费力气了,这里才是最有参考价值的的主参考文档啊,是捷径啊,隐藏的够深的,差点错过了,汗!

/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-kafka-5.0.5/lib/logstash/inputs/kafka.rb

kafka.rb部分文档如下:

# This input will read events from a Kafka topic. It uses the the newly designed
# 0.10 version of consumer API provided by Kafka to read messages from the broker.
#
# Here‘s a compatibility matrix that shows the Kafka client versions that are compatible with each combination
# of Logstash and the Kafka input plugin: 
# 
# [options="header"]
# |==========================================================
# |Kafka Client Version |Logstash Version |Plugin Version |Security Features |Why?
# |0.8       |2.0.0 - 2.x.x   |<3.0.0 | |Legacy, 0.8 is still popular 
# |0.9       |2.0.0 - 2.3.x   | 3.x.x |Basic Auth, SSL |Works with the old Ruby Event API (`event[‘product‘][‘price‘] = 10`)  
# |0.9       |2.4.0 - 5.0.x   | 4.x.x |Basic Auth, SSL |Works with the new getter/setter APIs (`event.set(‘[product][price]‘, 10)`)
# |0.10      |2.4.0 - 5.0.x   | 5.x.x |Basic Auth, SSL |Not compatible with the 0.9 broker 
# |==========================================================
# 
# NOTE: We recommended that you use matching Kafka client and broker versions. During upgrades, you should
# upgrade brokers before clients because brokers target backwards compatibility. For example, the 0.9 broker
# is compatible with both the 0.8 consumer and 0.9 consumer APIs, but not the other way around.

6)升级kafka_2.10-0.8.2.2.tgz为kafka_2.11-0.10.0.1.tgz (我看kafka-clients-0.10.0.1.jar,所以没有用最新的kafka_2.11-0.10.1.0.tgz)

大概步骤

关闭老kafka

/usr/local/kafka/bin/kafka-server-stop.sh /usr/local/kafka/config/server.properties

备份老配置文件

server.properties和zookeeper.properties

删除kafka

rm -rf /usr/local/kafka/

rm -rf /data/kafkalogs/*

安装配置新kafka

wget http://mirrors.hust.edu.cn/apache/kafka/0.10.0.1/kafka_2.11-0.10.0.1.tgz

tar zxvf kafka_2.11-0.10.0.1.tgz -C /usr/local/

ln -s /usr/local/kafka_2.11-0.10.0.1 /usr/local/kafka

diff了下server.properties和zookeeper.properties变动不大可以直接使用

启动新kafka

/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties &

7)注意几个关键配置需要修改

config :bootstrap_servers, :validate => :string, :default => "localhost:9092"

config :group_id, :validate => :string, :default => "logstash"

config :topics, :validate => :array, :default => ["logstash"]

config :consumer_threads, :validate => :number, :default => 1

除了上面的几个关键配置外,kafka的topic分片信息需要重新create一份,否则KafkaMonitor监控不出Active Topic Consumer图形,但实际是在工作中。

时间: 2024-08-11 09:53:36

排查logstash2.4升级到5.0版本后kafka不兼容问题的相关文章

CMS .NET 程序框架 从2.0/3.5升级到4.0 版本后 需要调整的地方

问题一: document.forms1.action 不可使用 需要修改程 document.forms[0] .NET 程序框架 从2.0/3.5升级到4.0 版本后,document.forms1  不可使用 也就是说所有浏览器都是支持document.forms["form1"]这样的写法的. 微软4.0之前是document.form1也能获取, 升级到4.0之后 取值方式为document.forms["form1"] 或者document.forms[

解决cocos2d-X 2.0版本后创建的Android项目提示org.cocos2dx.lib.Cocos2dxActivity找不到问题

原地址: http://blog.163.com/[email protected]/blog/static/6070970220132511558143/ 解决方法:    复制 ***\cocos2dx\platform\android\java\src\ (***为cocos2d-x更目录) 到你android项目中的src文件夹中这样就又有一个麻烦问题,是不是每次创建都要复制呢,答案当然是否定的,来看一劳永逸的方法,定位 (cocos2d-x根目录)\template\android\,

升级ox 10.10版本后 php项目无法显示验证码

升级ox 10.10版本后,php环境配置好,php项目能运行,但是验证码不能显示. 查看phpinfo(),有GD库技持. 有类似情况,而已解决的,请教一下解决方法

Ubuntu 16.04升级4.7.0内核后导致Compiz奔溃,问题:compiz[4852]: segfault at 48 ip 00007f88cae087f0 sp 00007ffce354c268 error 4 in libscale.so

由于硬件的驱动支持问题,升级4.7.0的内核主要是为了能使用Intel HD Graphics 630驱动,但是也出现了相关问题,比如Compiz的特效导致桌面上如果有多个相同程序启动,然后再次点击时就会出现闪烁和崩溃问题.查找日志如下: compiz[4852]: segfault at 48 ip 00007f88cae087f0 sp 00007ffce354c268 error 4 in libscale.so[7f5ce70cb000+24000] 解决方法: 这些方法只能尝试,不一定

pip升级到18.0版本过程中报错解决方法

我这台电脑是windows10系统,一般在cmd命令行界面下执行pip的升级命令:pip install –upgrade pip 安装的时候,会有拒绝访问报错:这个时候应该是权限的问题,于是在win10系统的搜索框输入cmd,然后在命令提示符上点右键,选择以管理员身份运行. 然后就执行pip的升级命令:pip install –upgrade pip就可以了. 原文地址:https://www.cnblogs.com/shanghongyun/p/9631764.html

mysql 官方源从8.0.3直接yum升级到8.0.4后无法启动

服务器环境:centos7.4.14 问题:mysql无法正常启动 查看日志 2018-02-23T02:10:08.371209Z 0 [System] [MY-010116] /usr/sbin/mysqld (mysqld 8.0.4-rc-log) starting as process 27702 ... 2018-02-23T02:10:08.737713Z 1 [ERROR] [MY-011096] No data dictionary version number found.

升级或者重装Discuz! 版本后 QQ互联英文乱码显示的正确解决方法

升级Discuz! X3版本QQ互联英文乱码!connect_viewthread_share_to_qq!  目前Discuz!论坛上 最简单的解决方法: 第一步:后台----->站长-----> 数据库----->升级 运行下面二行命令 delete from `pre_common_plugin` where `identifier`= 'qqconnect'; delete from `pre_common_setting` where `skey` = 'connect' 复制

fastDfs V5.02 升级到 V5.08版本后,启动报错:symbol lookup error: /usr/bin/fdfs_trackerd: undefined symbol: g_current_time

/libfastcommon-1.0.36 # ./make.sh cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o hash.o hash.c cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o chain.o chain.c cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o shared_fu

[原创]在使用SDK 23(6.0)版本后org.apache.http相关的类找不到的解决办法

参考: http://stackoverflow.com/questions/32153318/httpclient-wont-import-in-android-studio http://www.zhihu.com/question/35597452/answer/63619567 1. 在Android模块里面添加 android {    useLibrary 'org.apache.http.legacy'} 这个对我不起作用,依然提示 不识别 org.apache.http.lega