kafka topic和topic权限操作

topic

  • 创建
    /opt/kafka/bin/kafka-topics.sh --create \
      --zookeeper zookeeper.example.com \
      --replication-factor 1 \
      --partitions 1 \
      --topic KafkaTopicName
    
  • 查询
    /opt/kafka/bin/kafka-topics.sh --list \
        --zookeeper zookeeper.example.com:2181
    
  • 删除
    /opt/kafka/bin/kafka-topics.sh \
        --delete \
        --zookeeper zookeeper.example.com:2181 \
        --topic KafkaTopicName
    

topic权限:

  • 增加
    /opt/kafka/bin/kafka-acls.sh \
      --authorizer-properties zookeeper.connect=zookeeper.example.com:2181 \
      --add \
      --allow-principal User:"kafkaclient" \
      --operation Read \
      --topic KafkaTopicName
    
  • 移除
    /opt/kafka/bin/kafka-acls.sh \
      --authorizer-properties zookeeper.connect=zookeeper.example.com:2181 \
      --remove \
      --allow-principal User:"kafkaclient" \
      --operation Describe \
      --topic KafkaTopicName \
      --force
    
  • 查询
    /opt/kafka/bin/kafka-acls.sh \
      --authorizer-properties zookeeper.connect=zookeeper.example.com:2181 \
      --list \
      --topic KafkaTopicName