kafka集群搭建
一、zookeeper集群搭建
略,請參考其他文檔,這里不再贅述。
二、下載kafka
從kafka官網(wǎng)下載kafka_2.11-0.11.0.0.tgz,并解壓。
tar -zxvf kafka_2.11-0.11.0.0
三、kafka配置修改
這里我們僅以兩臺kafka實例做集群。
打開kafka屬性文件
vim ${kafka_home}/config/server.properties
修改其中的關(guān)鍵屬性
# The id of the broker. This must be set to a unique integer for each broker.
broker.id=0
# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=192.168.2.233:2181,192.168.2.234:2181,192.168.2.235:2181
# The default number of log partitions per topic. More partitions allow greater
# parallelism for consumption, but this will also result in more files across
# the brokers.
num.partitions=1
broker.id 第一臺機器寫0,第二臺機器寫1,以此類推。
zookeeper.connect :將zookeeper集群的地址和端口寫上。
num.partitions=1 :每個topic的partition默認數(shù)量。可根據(jù)自己項目的情況進行配置。
其他屬性請參照官網(wǎng)。
四、kafka集群啟動
nohup ${kafka_home}/bin/kafka-server-start.sh ${kafka_home}/config/server.properties &
將兩臺機器的kafka啟動,集群搭建完畢。
集群搭建就是這么簡單。