Kafka Console consumer with kerberos authentication

后端 未结 1 1544
情话喂你
情话喂你 2021-02-09 05:00

How to consume published messages from the kafka (version 0.10) server which was kerberos authorized, for the authentication keytab file is being used.

I tried with the

1条回答
  •  醉话见心
    2021-02-09 05:37

    Kerberos-enabled clusters can pose some tricky challenges at times. I've had to deal with some of these myself.

    If the Kafka Cluster is Kerberos-enabled then you'll need to supply a jaas.conf file with the Kerberos details. Try following these steps(they worked for me):

    1. Create a jaas.conf file with the following contents:
    KafkaClient {
    com.sun.security.auth.module.Krb5LoginModule required
    useKeyTab=true
    keyTab=""
    principal="";
    };
    

    Note: I've assumed that the Kafka principal and the associated keytab is already created. If not, you'll need to create these first.

    1. Create a properties file (say "consumer.properties") with the following contents:
    security.protocol=SASL_PLAINTEXT
    sasl.kerberos.service.name=kafka
    
    1. Then at the terminal run the following command:
    $export KAFKA_OPTS="-Djava.security.auth.login.config="
    
    1. Execute the Kafka-console-consumer script:
    $ kafka-console-consumer --topic  --from-beginning 
    --bootstrap-server :9092 --consumer.config 
    

    I hope this helps.

    0 讨论(0)
提交回复
热议问题