📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

适用版本: 8.8-8.9

1. 错误异常的基本描述 #

Both an endpoint suffix as well as a primary endpoint were set 表示 Elasticsearch 在构造 Azure 存储连接串时,发现你同时配置了 endpoint_suffixprimary endpoint。这两种方式都可以决定主服务地址,但语义重叠,因此实现明确禁止同时存在。

常见现象 #

  • Azure 仓库或相关客户端初始化失败。
  • 日志中直接出现 SettingsException,而不是后续网络连接超时。
  • 常见于从标准公有云切到自定义 endpoint 时,旧参数未清理干净。

典型报错与异常栈 #

SettingsException: Both an endpoint suffix as well as a primary endpoint were set

2. 为什么会发生这个错误 #

源码会先判断 endpoint_suffixendpointsecondary_endpoint 三个值是否存在。只要 endpoint_suffixendpoint 同时非空,就直接抛出该异常。

其根因是:

  • endpoint_suffix 适合通过账号名自动推导标准 endpoint。
  • primary endpoint 适合显式指定完整主 endpoint。

两者并存时,系统无法确定应以哪种方式生成连接串。

3. 如何排查和解决这个异常和解决这个异常 #

  1. 检查 elasticsearch.yml、keystore 或环境变量中的 Azure client 配置。
  2. 确认同一个 client 下是否同时存在 endpoint_suffixendpoint
  3. 使用标准 Azure 云环境时通常保留 endpoint_suffix
  4. 使用私有云或自定义服务地址时通常删除 endpoint_suffix,仅保留 endpoint

排查时需要注意的问题 #

  • 不同 client 名称下的配置不要混看。
  • 参数若来自多处叠加,要核对最终生效值。
  • 清理这个冲突后,还应检查 secondary endpoint 是否也有冲突。

4. 如何解决这个错误 #

常用修复思路 #

  • 二选一保留 endpoint_suffixprimary endpoint
  • 标准云环境用 endpoint_suffix,自定义服务地址用显式 endpoint
  • 清理迁移时遗留的旧参数。

后续注意事项与推荐建议 #

  • 为 Azure client 配置建立互斥校验。
  • 将标准云和私有云模板分开维护。

借助 INFINI 产品提升排障效率 #

  • INFINI Console 可用于对比多集群 Azure 仓库配置差异。
  • INFINI Gateway 适合记录配置变更调用,追踪冲突参数来源。

5. 小结 #

Both an endpoint suffix as well as a primary endpoint were set 的根因是 Azure 主 endpoint 的两种定义方式同时生效。把配置收敛为单一路径即可解决。

相关错误 #

附:日志上下文 #

final boolean hasEndpointSuffix = Strings.hasText(endpointSuffix);
final boolean hasEndpoint = Strings.hasText(endpoint);
final boolean hasSecondaryEndpoint = Strings.hasText(secondaryEndpoint);  if (hasEndpointSuffix && hasEndpoint) {
throw new SettingsException("Both an endpoint suffix as well as a primary endpoint were set");
}  if (hasEndpointSuffix && hasSecondaryEndpoint) {
throw new SettingsException("Both an endpoint suffix as well as a secondary endpoint were set");
}