# org.apache.kafka.common.errors.BrokerIdConflictException: 代理 ID 1 已被另一个地址为 192.168.1.10:9092 的代理注册

- **ID:** `kafka/broker-id-conflict`
- **领域:** kafka
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

同一 Kafka 集群中的两个代理具有相同的 `broker.id` 值，导致 ZooKeeper 或 KRaft 元数据中的冲突。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| kafka_2.13-3.4.0 | active | — | — |
| kafka_2.13-3.5.1 | active | — | — |
| kafka_2.13-3.6.0 | active | — | — |

## 解决方案

1. ```
   Change the `broker.id` in one broker's `server.properties` to a unique value (e.g., from 1 to 2) and restart that broker. Verify no other broker uses ID 2.
   ```
2. ```
   If using KRaft, check `meta.properties` in the log directory and ensure `broker.id` is unique across all nodes; regenerate the cluster ID if necessary.
   ```
3. ```
   Use a script to list all registered brokers: `zookeeper-shell.sh localhost:2181 get /brokers/ids/1` and compare the `endpoints` field to identify the conflicting broker, then update its ID.
   ```

## 无效尝试

- **** — The conflict persists because the same IDs are still assigned; ZooKeeper still sees both with the same ID. (98% 失败率)
- **** — This removes the conflicting registration but the broker re-registers with the same ID on restart, causing the error again. (90% 失败率)
- **** — This only affects automatic ID assignment, not manual conflicts; it does not resolve existing duplicate IDs. (85% 失败率)
