You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows环境Elasticsearch 8.10.2安装报错与配置问题求助

Elasticsearch 8.10.2 Windows安装问题解决指南

遇到的错误

1. Log4j插件缺失错误

2024-07-09 16:27:58,817 main ERROR Unable to locate plugin type for IfFileName
2024-07-09 16:27:58,823 main ERROR Unable to locate plugin type for IfFileName
2024-07-09 16:27:58,843 main ERROR Unable to locate plugin for IfAccumulatedFileSize
2024-07-09 16:27:58,844 main ERROR Unable to locate plugin for IfFileName

2. 配置目录所有权不匹配警告

Aborting auto configuration because of config dir ownership mismatch. Config dir is owned by BUILTIN\Administrators but auto-configuration directory would be owned by DESKTOP-9RS8J15\Lenovo

当前log4j2.properties配置片段

######## Server JSON ############################
appender.rolling.type = RollingFile
appender.rolling.name = rolling
appender.rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_server.json
appender.rolling.layout.type = ECSJsonLayout
appender.rolling.layout.dataset = elasticsearch.server

appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.json.gz
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size = 128MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.fileIndex = nomax
appender.rolling.strategy.action.type = Delete
appender.rolling.strategy.action.basepath = ${sys:es.logs.base_path}
appender.rolling.strategy.action.condition.type = IfFileName
appender.rolling.strategy.action.condition.glob = ${sys:es.logs.cluster_name}-*
appender.rolling.strategy.action.condition.nested_condition.type = IfAccumulatedFileSize
appender.rolling.strategy.action.condition.nested_condition.exceeds = 2GB

######## Server -  old style pattern ###########
appender.rolling_old.type = RollingFile
appender.rolling_old.name = rolling_old
appender.rolling_old.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}.log
appender.rolling_old.layout.type = PatternLayout
appender.rolling_old.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %m%n

appender.rolling_old.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.log.gz
appender.rolling_old.policies.type = Policies
appender.rolling_old.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling_old.policies.time.interval = 1
appender.rolling_old.policies.time.modulate = true
appender.rolling_old.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling_old.policies.size.size = 128MB
appender.rolling_old.strategy.type = DefaultRolloverStrategy
appender.rolling_old.strategy.fileIndex = nomax
appender.rolling_old.strategy.action.type = Delete
appender.rolling_old.strategy.action.basepath = ${sys:es.logs.base_path}
appender.rolling_old.strategy.action.condition.type = IfFileName
appender.rolling_old.strategy.action.condition.glob = ${sys:es.logs.cluster_name}-*
appender.rolling_old.strategy.action.condition.nested_condition.type = IfAccumulatedFileSize
appender.rolling_old.strategy.action.condition.nested_condition.exceeds = 2GB
################################################

解决方案

1. 解决IfFileName和IfAccumulatedFileSize插件缺失问题

Elasticsearch 8.x自带的Log4j已包含这些插件,错误源于配置语法不完整。修改log4j2.properties中的条件配置,使用完整类名:

  • 将IfFileName替换为org.apache.logging.log4j.core.appender.rolling.action.IfFileName
  • 将IfAccumulatedFileSize替换为org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileSize

修改后的示例片段:

appender.rolling.strategy.action.condition.type = org.apache.logging.log4j.core.appender.rolling.action.IfFileName
appender.rolling.strategy.action.condition.glob = ${sys:es.logs.cluster_name}-*
appender.rolling.strategy.action.condition.nested_condition.type = org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileSize
appender.rolling.strategy.action.condition.nested_condition.exceeds = 2GB

也可以直接使用解压包config目录下的官方默认log4j2.properties文件,避免自定义配置的语法错误。

2. 解决配置目录所有权不匹配问题

调整目录所有者以统一权限:

  1. 找到Elasticsearch的config目录,右键选择属性→安全→高级
  2. 点击更改(所有者),输入当前用户名DESKTOP-9RS8J15\Lenovo,点击检查名称确认后保存
  3. 勾选替换子容器和对象的所有者,应用更改
  4. 返回安全选项卡,给当前用户分配完全控制权限,保存设置

启动elasticsearch.bat时使用当前用户(而非管理员),避免权限不一致。

3. 让Elasticsearch使用指定的JAVA_HOME

强制Elasticsearch使用自定义JDK有两种方式:

  • 修改启动脚本:打开安装目录bin文件夹下的elasticsearch-env.bat,找到set "ES_JAVA_HOME=",修改为set "ES_JAVA_HOME=C:\Program Files\Java\jdk-21.0.1",保存后重启服务
  • 设置系统环境变量:添加系统环境变量ES_JAVA_HOME,值设为C:\Program Files\Java\jdk-21.0.1,优先级高于捆绑JDK

注意:Elasticsearch 8.10.2官方推荐使用JDK17,JDK21可能存在兼容性问题,建议优先使用JDK17版本。


内容的提问来源于stack exchange,提问作者Sena

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 03:34:53