Updated on 2024-12-11 GMT+08:00

Modifying Kafka Topic Configurations

Scenario

You can use a cluster client to create Kafka topics based on service requirements. Management permission is required for clusters with Kerberos authentication enabled. You can also modify topic configurations on Kafka UI.

  • In security mode, when modifying topic configurations on the Kafka UI, ensure that the Kafka UI login user belongs to the kafkaadmin user group or the corresponding operation permission is granted to the user. Otherwise, the authentication fails.
  • In non-security mode, Kafka UI does not authenticate any operation.
  • This topic is available for MRS 3.x or later.

Modifying Kafka Topics Using the Kafka Client

  1. Access the ZooKeeper instance page.

    Log in to FusionInsight Manager. For details, see Accessing FusionInsight Manager (MRS 3.x or Later). Choose Cluster > Services > ZooKeeper > Instances.

  2. View the IP addresses of the ZooKeeper role instance.

    Record the IP address of any ZooKeeper instance.

  3. Prepare the client based on service requirements. Log in to the node where the client is installed.

    Log in to the node where the client is installed. For details, see Using an MRS Client.

  4. Switch to the client installation directory, for example, /opt/client/Kafka/kafka/bin.

    cd /opt/client/Kafka/kafka/bin

  5. Configure environment variables.

    source /opt/client/bigdata_env

  6. Perform user authentication. (Skip this step for normal clusters.)

    kinit Component service user

  7. Use kafka-topics.sh to modify the topic.

    ./kafka-topics.sh --alter --topic Topic name --config Configuration item=Value--zookeeper Service IP address of any ZooKeeper node:clientPort/kafka

  8. Use kafka-topics.sh to view the modified topic.

    • ./kafka-topics.sh --describe --zookeeper Service IP address of any ZooKeeper node:clientPort/kafka --topic Topic name
    • ./kafka-topics.sh --describe --bootstrap-server IP address of the Kafka cluster:21007 --command-config ../config/client.properties --topic Topic name

Using Kafka UI to Modify Kafka Topics (MRS 3.1.2 and Later Versions)

  1. Access the Kafka UI.

    1. Log in to FusionInsight Manager as a user who has the permission to access the Kafka UI and choose Cluster > Services > Kafka.

      If you need to perform operations on the page, for example, creating a topic, you need to grant related permissions to users. For details, see Kafka User Permissions.

    2. On the right of KafkaManager WebUI, click the URL to access the Kafka UI.

  2. Choose Topics.
  1. In the Operation column of the item to be modified, choose Action > Config. On the displayed page, change the values of Key and Value of the topic. To add multiple items, click .
  2. Click OK.