kafka-python通过Snappy压缩访问时,报Snappy codec is not available错误

maoch 发布于 2015/11/15 17:59
阅读 891
收藏 0

1、测试环境:

    CentOS6.5_64位、JDK1.7、kafka版本为:kafka_2.9.2-0.8.2.2,zookeeper版本为:zookeeper-3.4.6,

kafka-python-0.9.4 。

2、测试步骤:

    已经安装好zookeeper和kafaka环境,设置codec=CODEC_SNAPPY则报错,codec=CODEC_NONE或者是codec=CODEC_GZIP则正常,此时怀疑是未安装SNAPPY

    安装SNAPPY,进行测试,发现还是报错:

错误如下:

Traceback (most recent call last):
  File "/usr/local/kafkaTest/producer.py", line 67, in <module>
    main()
  File "/usr/local/kafkaTest/producer.py", line 63, in main
    load(hostname, max_size, loaded)
  File "/usr/local/kafkaTest/producer.py", line 22, in load
    producer.send_messages('topic1', big_msg)
  File "build/bdist.linux-x86_64/egg/kafka/producer/simple.py", line 54, in send_messages
  File "build/bdist.linux-x86_64/egg/kafka/producer/base.py", line 349, in send_messages
  File "build/bdist.linux-x86_64/egg/kafka/producer/base.py", line 385, in _send_messages
  File "build/bdist.linux-x86_64/egg/kafka/protocol.py", line 603, in create_message_set
  File "build/bdist.linux-x86_64/egg/kafka/protocol.py", line 586, in create_snappy_message
  File "build/bdist.linux-x86_64/egg/kafka/codec.py", line 76, in snappy_encode
NotImplementedError: Snappy codec is not available

测试代码如下:

producer = SimpleProducer(client,async=False,codec=CODEC_SNAPPY,req_acks=0,ack_timeout=2000,sync_fail_on_error=False)





加载中
0
maoch
maoch
解决了,参考kafka-python中的install.rst可以解决
返回顶部
顶部