How to add a new Kafka brokers machines dynamically to a cluster

jes*_*ica 1 apache-kafka

We have Kafka confluent cluster , cluster include 3 Kafka brokers ,

Version details:

Kafka machines are installed on rhel version 7.2 
Kafka confluent version is 0.1x
Zookeeper version: 3.4.10
schema-registry version: 4.0.0
Run Code Online (Sandbox Code Playgroud)

Each Kafka broker machine include the following services

Kafka broker
Zookeeper server
Schema registry
Run Code Online (Sandbox Code Playgroud)

Now we want to add a additionally new 3 Kafka brokers machines to the current Kafka cluster ( the Additional Kafka machines are – kafka04/05/06 with the same Kafka version – 0.1X , )

So cluster should be finally with:

6 Kafka brokers machines - kafka01, kafka02 , kafka03 , kafka04 , kakfa05 , kafka05

3 zookeeper servers - kafka01, kafka02 , kafka03

3 schema registry services - kafka01, kafka02 , kafka03

In order to connect the new 3 Kafka brokers to the existing Kafka cluster we need to change the Configuration on all Kafka Machines ( the old Kafka machines and the new Kafka machines )

We are not sure what are exactly the configuration files in Kafka brokers that should be changed, But From my understanding We should change the Kafka and zookeeper settings as the following

I will happy to get remarks/notes about the following procedure

  1. Edit the server.properties file on the new Kafka brokers - kafka04/05/06 , and change the broker.id parameter as the following

    On kafka04 - broker.id=4 On kafka05 - broker.id=5 On kafka06 - broker.id=6

  2. Edit the server.properties on all Kafka machines - kafka01/02/03/04/05/06 And change the following parameters to the number of total nodes in the cluster

     offsets.topic.replication.factor=6
     transaction.state.log.replication.factor=6
    
    Run Code Online (Sandbox Code Playgroud)
  3. On the new Kafka machines - Kafka 04/05/06 edit the server.properties and update the parameter -- zookeeper.connect with the zookeeper server ip’s that located on kafka01 , kafka02 , kafka03

    Example

     zookeeper.connect=10.10.10.1:2181,10.10.10.2:2181,10.10.10.3:2181
    
    Run Code Online (Sandbox Code Playgroud)
  4. On Kafka machines – kafka 04/05/06 , edit the file - zookeeper.properties as the
    Following

    server.1=10.10.10.1:2888:3888
    server.2=10.10.10.2:2888:3888
    server.3=10.10.10.3:2888:3888
    
    Run Code Online (Sandbox Code Playgroud)
  5. Edit the file - myid file on Kafka 04/05/06 , and change the parameter broker.id as the Following

    on kafka04 set:

     broker.id=4
    
    Run Code Online (Sandbox Code Playgroud)

    on kafka05 set:

     broker.id=5
    
    Run Code Online (Sandbox Code Playgroud)

    on kafka06 set:

     broker.id=6
    
    Run Code Online (Sandbox Code Playgroud)
  6. After settings as above , restart all Kafka brokers services on kafka01/02/03/04/05/06 and Restart the zookeeper servers on kafka01/02/03

    And verify all Kafka services and zookeeper service started successfully

Reference info - https://www2.microstrategy.com/producthelp/current/PlatformAnalytics/en-us/Content/Add_kafka_node_to_kafka_cluster.htm

Mic*_*son 6

添加代理时,您不需要更改现有代理的配置,也不需要重新启动它们。如果您不添加新的 ZooKeeper 服务器,这同样适用于 ZooKeeper。

在新代理上,您只需要设置一个不同的broker.id值。

我不建议将主题(包括内部)的复制因子增加到 3 以上。

新代理启动后,您可能需要重新平衡现有数据。有很多工具可以做到这一点,包括kafka-reassign-partitions.sh工具。Kafka 文档中有一个部分详细介绍了该过程:https : //kafka.apache.org/documentation/#basic_ops_cluster_expansion

  • 如果您不在这些新机器上运行 ZooKeeper,您甚至不需要“zookeeper.properties”文件!仅当在机器上运行 ZooKeeper 时才需要此文件。 (2认同)