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

  不知道,跟這個設置有沒有關系。如果有懂的大神,敬請指導一、二。謝謝先。

 

  好了,今天就到這里了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM