kafka.admin.TopicCommand 失败
kafka.admin.TopicCommand Failing
我正在使用单节点 Kafka V 0.10.2(16 GB RAM,8 核)和单节点 zookeeper V 3.4.9(4 GB RAM,1 核)。我有 64 个消费者组和 500 个主题,每个主题有 250 个分区。我能够执行只需要 Kafka 代理及其 运行 的命令
前任。
./kafka-consumer-groups.sh --bootstrap-server localhost:9092
--describe --group
但是当我执行创建主题、更改主题等管理命令时,例如
./kafka-topics.sh --create --zookeeper :2181
--replication-factor 1 --partitions 1 --topic
正在显示以下异常:
Error while executing topic command : replication factor: 1 larger
than available brokers: 0 [2017-11-16 11:22:13,592] ERROR
org.apache.kafka.common.errors.InvalidReplicationFactorException:
replication factor: 1 larger than available brokers: 0
(kafka.admin.TopicCommand$)
我检查过我的经纪人已经上线了。 server.log 中有以下警告
[2017-11-16 11:14:26,959] WARN Client session timed out, have not heard from server in 15843ms for sessionid 0x15aa7f586e1c061 (org.apache.zookeeper.ClientCnxn)
[2017-11-16 11:14:28,795] WARN Unable to reconnect to ZooKeeper service, session 0x15aa7f586e1c061 has expired (org.apache.zookeeper.ClientCnxn)
[2017-11-16 11:21:46,055] WARN Unable to reconnect to ZooKeeper service, session 0x15aa7f586e1c067 has expired (org.apache.zookeeper.ClientCnxn)
下面提到的是我的 Kafka 服务器配置:
broker.id=1
delete.topic.enable=true
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/kafka/data/logs
num.partitions=1
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=<zookeeperIP>:2181
zookeeper.connection.timeout.ms=6000
Zookeeper 配置为:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/zookeeper/data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
autopurge.snapRetainCount=20
# Purge task interval in hours
# Set to "0" to disable auto purge feature
autopurge.purgeInterval=48
我不知道要调整哪个配置。我缺少什么。任何帮助将不胜感激。
当你是 运行 消费者时,zookeeper 参数如
./kafka-topics.sh --create --zookeeper :2181 --replication-factor 1
--partitions 1 --topic
这意味着消费者将去询问 zookeeper 有关经纪人的详细信息。如果 zookeeper 中提供了代理详细信息,它就可以连接到代理。
在您的场景中,我认为 zookeeper 丢失了代理详细信息。 zookeeper 通常将所有配置存储在树路径中。
要检查 zookeeper 是否有代理路径,您需要使用 /bin/zkCli.sh -server localhost:2181
登录到 zookeeper shell
连接成功后ls /
你会看到这样的输出
[controller, controller_epoch, brokers, zookeeper, admin, isr_change_notification, consumers, config]
然后执行 ls /brokers
输出将是 [ids, topics, seqid]
然后执行 ls /brokers/ids
输出将是 [0]
- 它是经纪人 ID 的数组。如果你的数组是空的 []
这意味着你的 zookeeper
中没有经纪人的详细信息
在这种情况下,您需要重新启动您的代理和动物园管理员。
已更新:
这个问题一般不会发生。因为您的 zookeeper 服务器正在关闭(杀死)或自动丢失代理路径。
为了克服这个问题,最好多维护两个 zookeeper 意味着完成 3 个 zookeepers 节点。
如果是本地使用localhost:2181,localhost:2182,localhost:2183.
如果是集群使用三个实例zookeeper1:2181,zookeeper2:2181,zookeeper3:2181
您最多可以容忍两次失败。
用于创建主题并使用以下命令:
./kafka-topics.sh --create --zookeeper
localhost:2181,localhost:2182,localhost:2183 --replication-factor 1
--partitions 1 --topic
我正在使用单节点 Kafka V 0.10.2(16 GB RAM,8 核)和单节点 zookeeper V 3.4.9(4 GB RAM,1 核)。我有 64 个消费者组和 500 个主题,每个主题有 250 个分区。我能够执行只需要 Kafka 代理及其 运行 的命令 前任。
./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group
但是当我执行创建主题、更改主题等管理命令时,例如
./kafka-topics.sh --create --zookeeper :2181 --replication-factor 1 --partitions 1 --topic
正在显示以下异常:
Error while executing topic command : replication factor: 1 larger than available brokers: 0 [2017-11-16 11:22:13,592] ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException: replication factor: 1 larger than available brokers: 0 (kafka.admin.TopicCommand$)
我检查过我的经纪人已经上线了。 server.log 中有以下警告
[2017-11-16 11:14:26,959] WARN Client session timed out, have not heard from server in 15843ms for sessionid 0x15aa7f586e1c061 (org.apache.zookeeper.ClientCnxn)
[2017-11-16 11:14:28,795] WARN Unable to reconnect to ZooKeeper service, session 0x15aa7f586e1c061 has expired (org.apache.zookeeper.ClientCnxn)
[2017-11-16 11:21:46,055] WARN Unable to reconnect to ZooKeeper service, session 0x15aa7f586e1c067 has expired (org.apache.zookeeper.ClientCnxn)
下面提到的是我的 Kafka 服务器配置:
broker.id=1
delete.topic.enable=true
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/kafka/data/logs
num.partitions=1
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=<zookeeperIP>:2181
zookeeper.connection.timeout.ms=6000
Zookeeper 配置为:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/zookeeper/data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
autopurge.snapRetainCount=20
# Purge task interval in hours
# Set to "0" to disable auto purge feature
autopurge.purgeInterval=48
我不知道要调整哪个配置。我缺少什么。任何帮助将不胜感激。
当你是 运行 消费者时,zookeeper 参数如
./kafka-topics.sh --create --zookeeper :2181 --replication-factor 1 --partitions 1 --topic
这意味着消费者将去询问 zookeeper 有关经纪人的详细信息。如果 zookeeper 中提供了代理详细信息,它就可以连接到代理。
在您的场景中,我认为 zookeeper 丢失了代理详细信息。 zookeeper 通常将所有配置存储在树路径中。
要检查 zookeeper 是否有代理路径,您需要使用 /bin/zkCli.sh -server localhost:2181
连接成功后ls /
你会看到这样的输出
[controller, controller_epoch, brokers, zookeeper, admin, isr_change_notification, consumers, config]
然后执行 ls /brokers
输出将是 [ids, topics, seqid]
然后执行 ls /brokers/ids
输出将是 [0]
- 它是经纪人 ID 的数组。如果你的数组是空的 []
这意味着你的 zookeeper
在这种情况下,您需要重新启动您的代理和动物园管理员。
已更新:
这个问题一般不会发生。因为您的 zookeeper 服务器正在关闭(杀死)或自动丢失代理路径。
为了克服这个问题,最好多维护两个 zookeeper 意味着完成 3 个 zookeepers 节点。
如果是本地使用localhost:2181,localhost:2182,localhost:2183.
如果是集群使用三个实例zookeeper1:2181,zookeeper2:2181,zookeeper3:2181
您最多可以容忍两次失败。
用于创建主题并使用以下命令:
./kafka-topics.sh --create --zookeeper localhost:2181,localhost:2182,localhost:2183 --replication-factor 1 --partitions 1 --topic