一台服务器上可以启动多个broker实例,或者将broker部署到多台服务器上,以下以172.16.50.21集群为例,多台服务器上部署broker。
Step 1. 下载 the 1.0.0 release包并解压到172.16.50.21、172.16.50.22 、172.16.50.23三台服务器上
tar -xzf kafka_2.11-1.0.0.tgz
cd kafka_2.11-1.0.0
Step 2. 启动zookeeper (可选)
kafka依赖zookeeper,如果环境中没有zookeeper,可以在kafka包中启动一个zookeeper实例
bin/zookeeper-server-start.sh config/zookeeper.properties &
Step 3. 配置broker
broker id在集群中不能重复,所以每个节点的broker id需要修改,在每个节点上修改 config/server.properties
server1 : config/server.properties:
broker.id=0
zookeeper.connect=172.16.50.21:2181,172.16.50.22:2181,172.16.50.23:2181
server2 : config/server.properties:
broker.id=1
zookeeper.connect=172.16.50.21:2181,172.16.50.22:2181,172.16.50.23:2181
server3 : config/server.properties:
broker.id=2
zookeeper.connect=172.16.50.21:2181,172.16.50.22:2181,172.16.50.23:2181
Step 4. 启动kafka服务
在每台机器上启动服务
nohup bin/kafka-server-start.sh config/server.properties kafka.log &