2

我们面临来自多个用户的问题,他们无法在他们的机器上使用 Elasticsearch(无法启动 Windows 服务)。正在使用的版本是 6.6.0。

我们从现场获得的信息非常差,不足以对问题做出良好的诊断(希望我们能得到更好的信息)。但是,以下是我们所知道的:

  • 标准输出日志文件指出以下内容:
2019-08-20 08:38:23 Commons Daemon procrun stdout initialized
ERROR: the system property [es.path.conf] must be set
  • 服务安装/启动批处理文件指出服务已正确安装和启动。此外,-Des.path.conf="C:\ProgramData\Elastic\Elasticsearch\config"是在安装过程中设置的
...
C:\Program Files\Elastic\Elasticsearch>set ES_PARAMS=-Delasticsearch;-Des.path.home="C:\Program Files\Elastic\Elasticsearch";-Des.path.conf="C:\ProgramData\Elastic\Elasticsearch\config";-Des.distribution.flavor="default";-Des.distribution.type="zip" 

C:\Program Files\Elastic\Elasticsearch>if "auto" == "" set ES_START_TYPE=manual 

C:\Program Files\Elastic\Elasticsearch>if "" == "" set ES_STOP_TIMEOUT=0 

C:\Program Files\Elastic\Elasticsearch>if "" == "" set SERVICE_DISPLAY_NAME=Elasticsearch 6.6.0 (elasticsearch-service-x64) 

C:\Program Files\Elastic\Elasticsearch>if "" == "" set SERVICE_DESCRIPTION=Elasticsearch 6.6.0 Windows Service - https://elastic.co 

C:\Program Files\Elastic\Elasticsearch>if not "" == "" (if not "" == "" (set SERVICE_PARAMS= --ServiceUser "" --ServicePassword "" ) ) 

C:\Program Files\Elastic\Elasticsearch>"C:\Program Files\Elastic\Elasticsearch\bin\elasticsearch-service-x64.exe" //IS//elasticsearch-service-x64 --Startup auto --StopTimeout 0 --StartClass org.elasticsearch.bootstrap.Elasticsearch --StartMethod main ++StartParams --quiet --StopClass org.elasticsearch.bootstrap.Elasticsearch --StopMethod close --Classpath "C:\Program Files\Elastic\Elasticsearch\lib\*" --JvmMs 256  --JvmMx 256  --JvmSs 1024 --JvmOptions -Xms256m;-Xmx256m;-XX:+UseConcMarkSweepGC;-XX:CMSInitiatingOccupancyFraction=75;-XX:+UseCMSInitiatingOccupancyOnly;-Des.networkaddress.cache.ttl=60;-Des.networkaddress.cache.negative.ttl=10;-XX:+AlwaysPreTouch;-Xss1m;-Djava.awt.headless=true;-Dfile.encoding=UTF-8;-Djna.nosys=true;-XX:-OmitStackTraceInFastThrow;-Dio.netty.noUnsafe=true;-Dio.netty.noKeySetOptimization=true;-Dio.netty.recycler.maxCapacityPerThread=0;-Dlog4j.shutdownHookEnabled=false;-Dlog4j2.disable.jmx=true;-Djava.io.tmpdir=C:\Users\KE'SBU~1\AppData\Local\Temp\elasticsearch;-XX:+HeapDumpOnOutOfMemoryError;-XX:HeapDumpPath=data;-XX:ErrorFile=logs/hs_err_pid%p.log;-XX:+PrintGCDetails;-XX:+PrintGCDateStamps;-XX:+PrintTenuringDistribution;-XX:+PrintGCApplicationStoppedTime;-Xloggc:logs/gc.log;-XX:+UseGCLogFileRotation;-XX:NumberOfGCLogFiles=32;-XX:GCLogFileSize=64m ++JvmOptions -Delasticsearch;-Des.path.home="C:\Program Files\Elastic\Elasticsearch";-Des.path.conf="C:\ProgramData\Elastic\Elasticsearch\config";-Des.distribution.flavor="default";-Des.distribution.type="zip" --LogPath "C:\Program Files\Elastic\Elasticsearch\logs" --LogPrefix "elasticsearch-service-x64" --StdError auto --StdOutput auto --PidFile "elasticsearch-service-x64.pid" --DisplayName "Elasticsearch 6.6.0 (elasticsearch-service-x64)" --Description "Elasticsearch 6.6.0 Windows Service - https://elastic.co" --Jvm "C:\Program Files\Elastic\Elasticsearch\jdk\jre\bin\server\jvm.dll" --StartMode jvm --StopMode jvm --StartPath "C:\Program Files\Elastic\Elasticsearch"  ++Environment HOSTNAME="%COMPUTERNAME%" 

C:\Program Files\Elastic\Elasticsearch>if not errorlevel 1 goto installed 

C:\Program Files\Elastic\Elasticsearch>echo The service 'elasticsearch-service-x64' has been installed. 
The service 'elasticsearch-service-x64' has been installed.

C:\Program Files\Elastic\Elasticsearch>goto:eof
C:\Program Files\Elastic\Elasticsearch>"C:\Program Files\Elastic\Elasticsearch\bin\elasticsearch-service-x64.exe" //ES//elasticsearch-service-x64 --LogPath "C:\Program Files\Elastic\Elasticsearch\logs" --LogPrefix "elasticsearch-service-x64" --StdError auto --StdOutput auto 

C:\Program Files\Elastic\Elasticsearch>if not errorlevel 1 goto started 

C:\Program Files\Elastic\Elasticsearch>echo The service 'elasticsearch-service-x64' has been started 
The service 'elasticsearch-service-x64' has been started

C:\Program Files\Elastic\Elasticsearch>goto:eof
  • 据我们所知,设置了 ES_HOME 和 ES_PATH_CONF:
C:\>echo %ES_HOME%
C:\Program Files\Elastic\Elasticsearch


C:\>echo %ES_PATH_CONF%
C:\ProgramData\Elastic\Elasticsearch\config

从我在 ES 源代码中看到的内容来看,错误消息似乎来自“EnviromentAwareComand.java”。似乎在那个级别,System.getProperty("es.path.conf")正在回归null

作为总结,我看到以下内容:

  • 环境变量集
  • 使用 Java 选项安装的 Windows 服务-Des.path.conf="C:\ProgramData\Elastic\Elasticsearch\config"
  • Windows服务说ERROR: the system property [es.path.conf] must be set

不幸的是,我们无法访问注册表或 ,elasticsearch-service-mgr.exe因此我们可以检查es.path.conf.

我们在这里缺少什么?有谁知道为什么 ES 会抛出这个错误?

提前致谢!

更新

我们能够连接到其中一台有问题的机器。问题的罪魁祸首不知何故是 Window 用户名。

从前面的日志文件中我们可以看到对服务的调用如下:

C:\Program Files\Elastic\Elasticsearch>"C:\Program Files\Elastic\Elasticsearch\bin\elasticsearch-service-x64.exe" //IS//elasticsearch-service-x64 --Startup auto --StopTimeout 0 --StartClass org.elasticsearch.bootstrap.Elasticsearch --StartMethod main ++StartParams --quiet --StopClass org.elasticsearch.bootstrap.Elasticsearch --StopMethod close --Classpath "C:\Program Files\Elastic\Elasticsearch\lib\*" --JvmMs 256  --JvmMx 256  --JvmSs 1024 --JvmOptions -Xms256m;-Xmx256m;-XX:+UseConcMarkSweepGC;-XX:CMSInitiatingOccupancyFraction=75;-XX:+UseCMSInitiatingOccupancyOnly;-Des.networkaddress.cache.ttl=60;-Des.networkaddress.cache.negative.ttl=10;-XX:+AlwaysPreTouch;-Xss1m;-Djava.awt.headless=true;-Dfile.encoding=UTF-8;-Djna.nosys=true;-XX:-OmitStackTraceInFastThrow;-Dio.netty.noUnsafe=true;-Dio.netty.noKeySetOptimization=true;-Dio.netty.recycler.maxCapacityPerThread=0;-Dlog4j.shutdownHookEnabled=false;-Dlog4j2.disable.jmx=true;-Djava.io.tmpdir=C:\Users\KE'SBU~1\AppData\Local\Temp\elasticsearch;-XX:+HeapDumpOnOutOfMemoryError;-XX:HeapDumpPath=data;-XX:ErrorFile=logs/hs_err_pid%p.log;-XX:+PrintGCDetails;-XX:+PrintGCDateStamps;-XX:+PrintTenuringDistribution;-XX:+PrintGCApplicationStoppedTime;-Xloggc:logs/gc.log;-XX:+UseGCLogFileRotation;-XX:NumberOfGCLogFiles=32;-XX:GCLogFileSize=64m ++JvmOptions -Delasticsearch;-Des.path.home="C:\Program Files\Elastic\Elasticsearch";-Des.path.conf="C:\ProgramData\Elastic\Elasticsearch\config";-Des.distribution.flavor="default";-Des.distribution.type="zip" --LogPath "C:\Program Files\Elastic\Elasticsearch\logs" --LogPrefix "elasticsearch-service-x64" --StdError auto --StdOutput auto --PidFile "elasticsearch-service-x64.pid" --DisplayName "Elasticsearch 6.6.0 (elasticsearch-service-x64)" --Description "Elasticsearch 6.6.0 Windows Service - https://elastic.co" --Jvm "C:\Program Files\Elastic\Elasticsearch\jdk\jre\bin\server\jvm.dll" --StartMode jvm --StopMode jvm --StartPath "C:\Program Files\Elastic\Elasticsearch"  ++Environment HOSTNAME="%COMPUTERNAME%" 

有趣的部分是如何-Djava.io.tmpdir=C:\Users\KE'SBU~1\AppData\Local\Temp\elasticsearch设置。如您所见,路径包含一个单引号字符。

通过查看 procrun 存储 java 参数的注册表项,我们可以看到所有 java 选项都因此而损坏(单引号不存在,其余的 JvmOptions-Djava.io.tmpdir似乎没有被解析):

-Xms256m
-Xmx256m
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
-Des.networkaddress.cache.ttl=60
-Des.networkaddress.cache.negative.ttl=10
-XX:+AlwaysPreTouch
-Xss1m
-Djava.awt.headless=true
-Dfile.encoding=UTF-8
-Djna.nosys=true
-XX:-OmitStackTraceInFastThrow
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true
-Djava.io.tmpdir=C:\Users\KESBU~1\AppData\Local\Temp\elasticsearch;-        XX:+HeapDumpOnOutOfMemoryError;-XX:HeapDumpPath=data;-XX:ErrorFile=logs/hs_err_pid%p.log;-XX:+PrintGCDetails;-XX:+PrintGCDateStamps;-XX:+PrintTenuringDistribution;-XX:+PrintGCApplicationStoppedTime;-Xloggc:logs/gc.log;-XX:+UseGCLogFileRotation;-XX:NumberOfGCLogFiles=32;-XX:GCLogFileSize=64m

-Delasticsearch
-Des.path.home=C:\Program Files\Elastic\Elasticsearch
-Des.path.conf=C:\ProgramData\Elastic\Elasticsearch\config
-Des.distribution.flavor=default
-Des.distribution.type=zip

所以从我的角度来看,问题出在解析 JvmOptions 的地方,不允许使用单引号字符。

更新 2

从 Procrun 文档中:

++JvmOptions 将传递给 JVM 的 -D 或 -X 形式的选项列表。使用 # 或 ; 分隔选项 人物。如果您需要嵌入 # 或 ; 字符将它们放在单引号内。(不用于 exe 模式。)

这在某种程度上意味着单引号是 # 和 ; 的转义字符。...但是,如何转义单引号?

更新 3 为 ES 打开了一个问题,包含解决方法-> ES 问题

4

0 回答 0