kafka 官网: https://kafka.apache.org/quickstart

  zookeeper 官网:https://zookeeper.apache.org/

  kafka 运行需要 zookeeper 支持,所以安装 kafka 的时候需要先安装 zookeeper. 

  kafka、zookeeper 的安装按照官网说的即可,我安装的时候没遇到什么问题,centos、mac都尝试安装了(mac 还是推荐使用 brew,很强大) 

  项目已经在使用 kafka 了,所以自己研究了下 openresty 和 kafka 的使用,遇到了如下的问题:

  1、topic 不存在

699
2017/11/22 09:15:33 [error] 10904#2551098: *932 [lua] client.lua:150: _fetch_metadata(): all brokers failed in fetch topic metadata, context: ngx.timer, client: 127.0.0.1, server: 0.0.0.0:6699
2017/11/22 09:15:33 [error] 10904#2551098: *929 [lua] client.lua:150: _fetch_metadata(): all brokers failed in fetch topic metadata, client: 127.0.0.1, server: localhost, request: "GET /test_kafka HTTP/1.1", host: "localhost:6699"
2017/11/22 09:15:33 [error] 10904#2551098: *932 [lua] client.lua:150: _fetch_metadata(): all brokers failed in fetch topic metadata, context: ngx.timer, client: 127.0.0.1, server: 0.0.0.0:6699
2017/11/22 09:15:33 [error] 10904#2551098: *932 [lua] producer.lua:258: buffered messages send to kafka err: not found topic, retryable: true, topic: test, partition_id: -1, length: 1, context: ngx.timer, client: 127.0.0.1, server: 0.0.0.0:6699
2017/11/22 09:23:24 [error] 11155#2563328: *1850 lua entry thread aborted: runtime error: .../Cellar/openresty/1.11.2.5/lualib/resty/kafka/client.lua:117: attempt to index local 'self' (a nil value)
stack traceback:
coroutine 0:
    .../Cellar/openresty/1.11.2.5/lualib/resty/kafka/client.lua: in function 'refresh'
    ...zi_relation/exercise/lua_pro/mobile_login/kafka_demo.lua:42: in function <...zi_relation/exercise/lua_pro/mobile_login/kafka_demo.lua:1>, client: 127.0.0.1, server: localhost, request: "GET /test_kafka HTTP/1.1", host: "localhost:6699"
2017/11/22 09:23:24 [error] 11155#2563328: *1851 lua entry thread aborted: runtime error: .../Cellar/openresty/1.11.2.5/lualib/resty/kafka/client.lua:117: attempt to index local 'self' (a nil value)
View Code

相关文章: