使用不一樣的namespace讓不一樣的kafka/Storm鏈接同一個zookeeper

背景介紹:java

 須要部署2個kafka獨立環境,可是隻有一個zookeeper集羣。app

須要部署2個獨立的storm環境,可是隻有一個zookeeper集羣。this

--------------------------spa

kafka配置rest

--------------------------orm

kafka的config/server.properties中經過zookeeper.connect配置zookeeper,一般狀況下,咱們配置server

zookeeper.connect=192.168.1.101:2181,192.168.1.102:2181,192.168.1.103:2181部署

 

這個時候,若是兩個kafka的broker.id都爲0的話,第二個kafka沒法啓動,啓動時會報異常:kafka

java.lang.RuntimeException: A broker is already registered on the path /brokers/ids/0. This probably indicates that you either have configured a brokerid that is already in use, or else you have shutdown this broker and restarted it faster than the zookeeper timeout so it appears to be re-registering.it

 

若是修改第二個kafka的broker.id,則kafka變成了一個集羣,而我想要的是兩套獨立的kafka使用同一個zk。

 

此時須要使用zk的命名空間進行配置,只須要在zookeeper.connect配置後,定義不一樣的命名空間便可,kafka啓動後,會在zk上自動建立命名空間。

kafka1:zookeeper.connect=192.168.1.101:2181,192.168.1.102:2181,192.168.1.103:2181/kafka_namespace1

kafka2:zookeeper.connect=192.168.1.101:2181,192.168.1.102:2181,192.168.1.103:2181/kafka_namespace2

-------------------------------------------------------------------------------------------------------

------------------

storm配置

------------------

在storm.yaml(${STORM_HOME}/conf目錄下)中,配置

 

 

Storm 1:

storm.zookeeper.servers:
- "192.168.1.101"
- "192.168.1.102"
- "192.168.1.103"

 

 storm.zookeeper.root: "/storm_xxxx"

 

Storm 2:

 

storm.zookeeper.servers:
- "192.168.1.101"
- "192.168.1.102"
- "192.168.1.103"

 

 storm.zookeeper.root: "/storm_ssss"

相關文章
相關標籤/搜索