文档首页> MapReduce服务 MRS> 组件操作指南(普通版)> 使用Kafka> Kafka Token认证机制工具使用说明
更新时间:2023-06-21 GMT+08:00
分享

Kafka Token认证机制工具使用说明

操作场景

使用Token认证机制时对Token的操作。

本章节内容适用于MRS 3.x及后续版本的启用Kerberos认证的集群。

前提条件

  • MRS集群管理员已明确业务需求,并准备一个系统用户。
  • 已开启Token认证机制,详细操作请参考Kafka服务端配置
  • 已安装Kafka客户端。

操作步骤

  1. 以客户端安装用户,登录安装Kafka客户端的节点。
  2. 切换到Kafka客户端安装目录,例如“/opt/client”。

    cd /opt/client

  3. 执行以下命令,配置环境变量。

    source bigdata_env

  4. 执行以下命令,进行用户认证。

    kinit 组件业务用户

  5. 执行以下命令,切换到Kafka客户端安装目录。

    cd Kafka/kafka/bin

  6. 使用kafka-delegation-tokens.sh对Token进行操作

    • 为用户生成Token

      ./kafka-delegation-tokens.sh --create --bootstrap-server <IP1:PORT, IP2:PORT,...> --max-life-time-period <Long: max life period in milliseconds> --command-config <config file> --renewer-principal User:<user name>

      例如: ./kafka-delegation-tokens.sh --create --bootstrap-server 192.168.1.1:21007,192.168.1.2:21007,192.168.1.3:21007 --command-config ../config/producer.properties --max-life-time-period -1 --renewer-principal User:username

    • 列出归属在特定用户下的所有Token信息

      ./kafka-delegation-tokens.sh --describe --bootstrap-server <IP1:PORT, IP2:PORT,...> --command-config <config file> --owner-principal User:<user name>

      例如: ./kafka-delegation-tokens.sh --describe --bootstrap-server 192.168.1.1:21007,192.168.1.2:21007,192.168.1.3:21007 --command-config ../config/producer.properties --owner-principal User:username

    • Token有效期刷新

      ./kafka-delegation-tokens.sh --renew --bootstrap-server <IP1:PORT, IP2:PORT,...> --renew-time-period <Long: renew time period in milliseconds> --command-config <config file> --hmac <String: HMAC of the delegation token>

      例如: ./kafka-delegation-tokens.sh --renew --bootstrap-server 192.168.1.1:21007,192.168.1.2:21007,192.168.1.3:21007 --renew-time-period -1 --command-config ../config/producer.properties --hmac ABCDEFG

    • 销毁Token

      ./kafka-delegation-tokens.sh --expire --bootstrap-server <IP1:PORT, IP2:PORT,...> --expiry-time-period <Long: expiry time period in milliseconds> --command-config <config file> --hmac <String: HMAC of the delegation token>

      例如: ./kafka-delegation-tokens.sh --expire --bootstrap-server 192.168.1.1:21007,192.168.1.2:21007,192.168.1.3:21007 --expiry-time-period -1 --command-config ../config/producer.properties --hmac ABCDEFG

分享:

    相关文档

    相关产品