У меня есть простой код для подключения Kafka
с помощью Kerberos
,
index.php
:
<?php
require 'vendor/autoload.php';
use Enqueue\RdKafka\RdKafkaConnectionFactory;
$i = 0;
while (true) {
// connect to Kafka broker at example.com:1000 plus custom options
$connectionFactory = new RdKafkaConnectionFactory([
'global' => [
'bootstrap.servers' =>'kafka1.dataak.dev:9096,kafka2.dataak.dev:9096,
kafka3.dataak.dev:9096',
'sasl.kerberos.keytab' => 'twitter_crawler.user.keytab',
'sasl.kerberos.service.name'=> 'kafka',
'security.protocol' => 'SASL_PLAINTEXT',
'sasl.kerberos.principal'=> '[email protected]',
'sasl.mechanisms'=> 'GSSAPI',
],
'topic' => [
'auto.offset.reset' => 'beginning',
],
]);
$psrContext = $connectionFactory->createContext();
$message = $psrContext->createMessage($i);
$fooTopic = $psrContext->createTopic('test');
$psrContext->createProducer()->send($fooTopic, $message);
echo $i . " success push \n";
$i++;
}
Код работает хорошо, но иногда, в середине выполнения, я сталкиваюсь с этим сообщением:
0%2|1536492505.195|LIBSASL|rdkafka#producer-11|
[thrd:sasl_plaintext://kafka2.dataak.dev:9096/bootstrap]:
sasl_plaintext://kafka2.dataak.dev:9096/bootstrap: GSSAPI Error:
Unspecified GSS failure. Minor code may provide more information
(Matching credential not found)
%3|1536492505.195|FAIL|rdkafka#producer-11|
[thrd:sasl_plaintext://kafka2.dataak.dev:9096/bootstrap]:
sasl_plaintext://kafka2.dataak.dev:9096/bootstrap: Failed to
initialize SASL authentication: SASL handshake failed (start (-1)):
SASL(-1): generic failure: GSSAPI Error: Unspecified GSS failure.
Minor code may provide more information (Matching credential not found)
%3|1536492505.195|ERROR|rdkafka#producer-11| [thrd:sasl_plaintext://kafka2.dataak.dev:9096/bootstrap]: sasl_plaintext://kafka2.dataak.dev:9096/bootstrap: Failed to initialize SASL authentication: SASL handshake failed (start (-1)): SASL(-1): generic failure: GSSAPI Error: Unspecified GSS failure. Minor code may provide more information (Matching credential not found)
11%2|1536492506.480|LIBSASL|rdkafka#producer-12| [thrd:sasl_plaintext://kafka3.dataak.dev:9096/bootstrap]: sasl_plaintext://kafka3.dataak.dev:9096/bootstrap: GSSAPI Error: Unspecified GSS failure. Minor code may provide more information (Matching credential not found)
%3|1536492506.480|FAIL|rdkafka#producer-12| [thrd:sasl_plaintext://kafka3.dataak.dev:9096/bootstrap]: sasl_plaintext://kafka3.dataak.dev:9096/bootstrap: Failed to initialize SASL authentication: SASL handshake failed (start (-1)): SASL(-1): generic failure: GSSAPI Error: Unspecified GSS failure. Minor code may provide more information (Matching credential not found)
%3|1536492506.480|ERROR|rdkafka#producer-12| [thrd:sasl_plaintext://kafka3.dataak.dev:9096/bootstrap]: sasl_plaintext://kafka3.dataak.dev:9096/bootstrap: Failed to initialize SASL authentication: SASL handshake failed (start (-1)): SASL(-1): generic failure: GSSAPI Error: Unspecified GSS failure. Minor code may provide more information (Matching credential not found)
Эта проблема будет больше, когда я запустите это php index.php
несколько раз одновременно.
Это естественная проблема?
Есть ли способ решить это?
Задача ещё не решена.
Других решений пока нет …