kafka叢集搭建
一、zookeeper叢集搭建
略,請參考其他文檔,這裡不再贅述。
二、下載下傳kafka
從kafka官網下載下傳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
修改其中的關鍵屬性
# 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預設數量。可根據自己項目的情況進行配置。
其他屬性請參照官網。
四、kafka叢集啟動
nohup ${kafka_home}/bin/kafka-server-start.sh ${kafka_home}/config/server.properties &
将兩台機器的kafka啟動,叢集搭建完畢。
叢集搭建就是這麼簡單。