openresty + lua 4、openresty kafka,


  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

  wtf,怎么可能不存在呢,各种百度、google,也是简直了,就是不行。最后,皇天不负有心人呢,终于找到了一个文章,说是 kafka 的 server.properties 里必须要配置 host.name,说必须,

我想,我是没有配置这个,当时还在怀疑,这行吗,反正这样了,试试吧,怀着忐忑的心情,修改重启,结果还真可以了。我的苍天呢。

  host.name=127.0.0.1

  

 2、kafka、zookeeper 进程杀不掉(其实不能说是杀不掉,是杀掉,自己又重启了一个进程)

  这个也是个很淡疼的问题,kill -9后没了,2-3 s后又有新的进程启动了,进程号变了。

  这个问题现在还没有好,不知道 kafka 是几个意思。

      不过,看到了一个设置 

# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown. # This value is recommended to be increased for installations with data dirs located in RAID array. num.recovery.threads.per.data.dir=1 View Code

  不知道,跟这个设置有没有关系。如果有懂的大神,敬请指导一、二。谢谢先。

 

  好了,今天就到这里了。

 

相关内容

    暂无相关文章