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

配置项作用 #

transient 不是单独的配置项,而是 Easysearch 中临时设置类别,用于定义仅在当前会话期间生效、集群重启后丢失的配置。

配置项属性 #

  • 配置路径: N/A(这是一个类别,不是具体配置项)
  • 数据类型: N/A(包含多种类型的设置)
  • 默认值: N/A
  • 作用域: 可变(取决于具体设置,可以是 NodeScope、IndexScope 等)
  • 动态更新: 是(临时设置本质上就是可动态更新的)

使用方式 #

通过 API 设置临时配置 #

PUT /_cluster/settings
{
  "transient": {
    "indices.memory.index_buffer_size": "30%",
    "thread_pool.search.queue_size": "1000"
  }
}

混合使用临时和持久设置 #

PUT /_cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.enable": "all"
  },
  "transient": {
    "cluster.routing.allocation.enable": "none"
  }
}

设置类别说明 #

Transient(临时设置) #

  • 仅在当前会话期间生效
  • 集群重启后丢失
  • 优先级高于持久设置

Persistent(持久设置) #

  • 保存到配置文件
  • 集群重启后仍然生效
  • 除非被覆盖,否则永久生效

使用建议 #

测试配置变更 #

PUT /_cluster/settings
{
  "transient": {
    "indices.memory.index_buffer_size": "40%"
  }
}

使用临时设置测试配置,确认效果后再改为持久设置。

维护操作临时调整 #

PUT /_cluster/settings
{
  "transient": {
    "cluster.routing.rebalance.enable": "none"
  }
}

在维护期间临时禁用分片重平衡。

性能调优实验 #

PUT /_cluster/settings
{
  "transient": {
    "thread_pool.search.size": "20"
  }
}

临时调整线程池大小以测试性能效果。

注意事项 #

  1. 重启丢失: 临时设置在集群重启后会丢失,不会持久化保存。

  2. 优先级: 临时设置的优先级高于持久设置,当两者同时存在时,临时设置会覆盖持久设置。

  3. 测试用途: 最适合用于测试配置变更,在确认效果后再改为持久设置。

  4. 文档记录: 由于临时设置不会持久化,建议对重要的临时设置进行文档记录,以便需要时重新应用。

  5. 清除临时设置: 可以通过设置为 null 来清除临时设置:

PUT /_cluster/settings
{
  "transient": {
    "indices.memory.index_buffer_size": null
  }
}
  1. 生产环境: 避免在生产环境中使用临时设置配置关键的生产参数,这些应该使用持久设置。

设置优先级 #

设置值的优先级从高到低:

  1. Transient 设置(临时设置)
  2. Persistent 设置(持久设置)
  3. 默认配置(easysearch.yml 或静态配置)