LogStash启动报错:<Redis::CommandError: ERR unknown command 'script'>

来源:互联网 发布:淘宝真丝针织背心 编辑:程序博客网 时间:2024/05/22 12:38

今天学习LogStash,想使用redis作为中间缓冲,client读取日志发给redis,然后server从redis中获取日志保存到一起。
测试data_type为‘channel’的时候很正常,但是消息发布之后,如果订阅方没有启动,这条消息就丢失了。
于是测试data_type为‘list’,也就是redis的BLPOP指令,相当于一个队列。
结果client启动正常,server启动却报了如下错误:

[2017-03-17T19:24:36,346][WARN ][logstash.inputs.redis    ] Redis connection problem {:exception=>#<Redis::CommandError: ERR unknown command 'script'>}

下面是logstash的conf设置:

input{     redis {        data_type => "list"        key => "logstash-zorro-redis-test"        host => "192.168.0.8"        port => 6379    }}output{    stdout{        codec=>rubydebug    }}

然后查看官方文档,首先看到了这么几句话:

The list command (BLPOP) used by Logstash is supported in Redis v1.3.1+, and the channel commands used by Logstash are found in Redis v1.3.8+.
#list(BLPOP)指令需要redis版本为1.3.1以上,channel(发布订阅模式)需要redis版本1.3.8以上。

batch_count note: If you use the batch_count setting, you must use a Redis version 2.6.0 or newer.
#batch_count指令,如果你使用这个设置,你必须使用redis的版本为2.6.0以上。

我一看没错啊,我的redis是2.4的,并没有使用batch_count设置啊。
然后在网上也查不到相关信息。
正准备屈服去升级redis的时候,看见了官网文档的一个表格:
这里写图片描述
原来这玩意儿有默认值,被上面给误导了。
这个值是指从队列中读取数据时,一次性取出多少条。
所以,解决办法就是,不使用这个功能,将batch_size设置为1.

input{     redis {        data_type => "list"        key => "logstash-zorro-redis-test"        host => "192.168.0.8"        port => 6379        batch_count => 1    }}output{    stdout{        codec=>rubydebug    }}

然后启动测试,一切正常。

(感觉就一句话的事,被我说了这么久。。。)

0 0