执行elasticsearch.bat遇'Unrecognized VM option UseConcMarkSweepGC'错误求助
解决Elasticsearch启动时的Unrecognized VM option 'UseConcMarkSweepGC'错误
问题描述
执行elasticsearch.bat启动Elasticsearch时,出现以下错误提示:
Unrecognized VM option 'UseConcMarkSweepGC'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
完整错误栈信息:
Unrecognized VM option 'UseConcMarkSweepGC' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. at org.elasticsearch.server.cli.JvmOption.flagsFinal(JvmOption.java:113) at org.elasticsearch.server.cli.JvmOption.findFinalOptions(JvmOption.java:80) at org.elasticsearch.server.cli.MachineDependentHeap.determineHeapSettings(MachineDependentHeap.java:59) at org.elasticsearch.server.cli.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:140) at org.elasticsearch.server.cli.JvmOptionsParser.determineJvmOptions(JvmOptionsParser.java:92) at org.elasticsearch.server.cli.ServerProcess.createProcess(ServerProcess.java:214) at org.elasticsearch.server.cli.ServerProcess.start(ServerProcess.java:108) at org.elasticsearch.server.cli.ServerProcess.start(ServerProcess.java:91) at org.elasticsearch.server.cli.ServerCli.startServer(ServerCli.java:234) at org.elasticsearch.server.cli.ServerCli.execute(ServerCli.java:91) at org.elasticsearch.common.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:54) at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85) at org.elasticsearch.cli.Command.main(Command.java:50) at org.elasticsearch.launcher.CliToolLauncher.main(CliToolLauncher.java:64)
当前使用的jvm.options文件内容:
################################################################ ## ## JVM configuration ## ################################################################ ## ## WARNING: DO NOT EDIT THIS FILE. If you want to override the ## JVM options in this file, or set any additional options, you ## should create one or more files in the jvm.options.d ## directory containing your adjustments. ## ## See https://www.elastic.co/guide/en/elasticsearch/reference/@project.minor.version@/jvm-options.html ## for more information. ## ################################################################ ################################################################ ## IMPORTANT: JVM heap size ################################################################ ## ## The heap size is automatically configured by Elasticsearch ## based on the available memory in your system and the roles ## each node is configured to fulfill. If specifying heap is ## required, it should be done through a file in jvm.options.d, ## which should be named with .options suffix, and the min and ## max should be set to the same value. For example, to set the ## heap to 4 GB, create a new file in the jvm.options.d ## directory containing these lines: ## ## -Xms4g ## -Xmx4g ## ## See https://www.elastic.co/guide/en/elasticsearch/reference/@project.minor.version@/heap-size.html ## for more information ## ################################################################ ################################################################ ## Expert settings ################################################################ ## ## All settings below here are considered expert settings. Do ## not adjust them unless you understand what you are doing. Do ## not edit them in this file; instead, create a new file in the ## jvm.options.d directory containing your adjustments. ## ################################################################ -XX:+UseG1GC ## JVM temporary directory -Djava.io.tmpdir=${ES_TMPDIR} ## heap dumps # generate a heap dump when an allocation from the Java heap fails; heap dumps # are created in the working directory of the JVM unless an alternative path is # specified -XX:+HeapDumpOnOutOfMemoryError # exit right after heap dump on out of memory error -XX:+ExitOnOutOfMemoryError # specify an alternative path for heap dumps; ensure the directory exists and # has sufficient space @heap.dump.path@ # specify an alternative path for JVM fatal error logs @error.file@ ## GC logging -Xlog:gc*,gc+age=trace,safepoint:file=@loggc@:utctime,level,pid,tags:filecount=32,filesize=64m
问题原因
UseConcMarkSweepGC是Java 8及更早版本的垃圾收集器选项,Java 9及以上版本已移除该选项。当前使用的JDK版本高于Java 8,但Elasticsearch启动配置中仍在尝试启用这个已废弃的参数。
解决步骤
- 检查JDK版本:执行
java -version确认当前使用的JDK版本。 - 排查配置来源:查看Elasticsearch安装目录下的
jvm.options.d文件夹,检查是否有自定义.options文件包含-XX:+UseConcMarkSweepGC;同时检查系统环境变量或启动脚本,确认是否有传入该参数。 - 移除废弃选项:找到包含该参数的位置,删除
-XX:+UseConcMarkSweepGC这一行。 - 确认GC配置:从提供的
jvm.options来看,已配置-XX:+UseG1GC(Java 9+推荐的垃圾收集器),确保没有其他配置覆盖该设置。 - 重新启动:再次执行
elasticsearch.bat验证启动状态。
内容的提问来源于stack exchange,提问作者ANoos123
相关产品推荐
相关产品推荐

