There are 3 servers, the IP is 192.168.174.10,192.168.174.11,192.168.174.12, respectively.
- Download the website and unzip the installation on each machine separately.
# 创建kafka的安装目录mkdir -p /usr/local/software/kafka# 解压tar -xvf kafka_2.12-1.1.0.tgz -C /usr/local/software/kafka/
- Modify each server's/etc/profile file, set the Kafka environment variable, add the following content
export KAFKA_HOME=/usr/local/software/kafka/kafka_2.12-1.1.0export PATH=$PATH:$KAFKA_HOME/bin
After adding the configuration, reboot the command as follows:
source /etc/profile
- Modify the Server.properties file under $kafka_home/config for each server, modify the agent ID and log storage directory
#指定代理id,borker.id可以任意指定,前提是保证集群内每台机器的broker.id唯一,第二台机器设置为2...以此类推broker.id=1#设置日志目录log.dirs=/opt/data/kafka/kafka-logs#设置zookeeper集群地址zookeeper.connect=192.168.174.7:2181,192.168.174.8:2181,192.168.174.9:2181#设置本机地址,设置为本服务器的ip地址。如果不设置会在创建主题和发送消息时,发生NOT LEADER FOR PARTITION异常。host.name=192.168.174.10
- After the configuration is complete, start the Kafka of the 3 servers separately, and make sure the Zookeeper cluster has started successfully before starting Kafka.
kafka-server-start.sh -daemon server.properties
- Verify that startup is successful
jps
If you see the Kafka process, the boot succeeds.
The Zookeeper directory structure can also be viewed through the Zookeeper client, as follows:
#登录zookeeperzkCli . sh -server 192.168.174.7:2181#查看目录结构ls /#查看已启动的kafka代理ls /brokers/ids
4. Deploying Kafka clusters under Linux contos6.8