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)
<p>
<br>
</p>
<p>
<br>
</p>
解决了,参考kafka-python中的install.rst可以解决
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。