我正在运行 Ubuntu 18.04.4 LTS,在 Ruby 2.6.3 上运行 Ruby on Rails 6.0.3 生产应用程序,使用 elasticsearch 7.17。在我接触之前,JVM 已经安装在系统上了。我相信它是在设置服务器后安装的。
跑
sudo systemctl start elasticsearch.service
但失败了。
Ran
systemctl status elasticsearch.service
它给了我:
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2023-11-14 15:46:10 UTC; 936ms ago
Docs: https://www.elastic.co
Process: 13188 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=1/FAILURE)
Main PID: 13188 (code=exited, status=1/FAILURE)
Nov 14 15:46:10 appserver systemd-entrypoint[13188]: Error: Could not create the Java Virtual Machine.
Nov 14 15:46:10 appserver systemd-entrypoint[13188]: Error: A fatal exception has occurred. Program will exit.
Nov 14 15:46:10 appserver systemd-entrypoint[13188]: at org.elasticsearch.tools.launchers.JvmOption.flagsFinal(JvmOption.java:119)
Nov 14 15:46:10 appserver systemd-entrypoint[13188]: at org.elasticsearch.tools.launchers.JvmOption.findFinalOptions(JvmOption.java:81)
Nov 14 15:46:10 appserver systemd-entrypoint[13188]: at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:38)
Nov 14 15:46:10 appserver systemd-entrypoint[13188]: at org.elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:135)
Nov 14 15:46:10 appserver systemd-entrypoint[13188]: at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:86)
Nov 14 15:46:10 appserver systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Nov 14 15:46:10 appserver systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
Nov 14 15:46:10 appserver systemd[1]: Failed to start Elasticsearch.
journalctl -xe
给出:
-- Unit elasticsearch.service has begun starting up.
Nov 14 16:22:21 appserver systemd-entrypoint[16564]: Exception in thread "main" java.lang.RuntimeException: starting java failed with [1]
Nov 14 16:22:21 appserver systemd-entrypoint[16564]: output:
Nov 14 16:22:21 appserver systemd-entrypoint[16564]: error:
Nov 14 16:22:21 appserver systemd-entrypoint[16564]: Unrecognized VM option 'UseConcMarkSweepGC'
Nov 14 16:22:21 appserver systemd-entrypoint[16564]: Error: Could not create the Java Virtual Machine.
Nov 14 16:22:21 appserver systemd-entrypoint[16564]: Error: A fatal exception has occurred. Program will exit.
Nov 14 16:22:21 appserver systemd-entrypoint[16564]: at org.elasticsearch.tools.launchers.JvmOption.flagsFinal(JvmOption.java:119)
Nov 14 16:22:21 appserver systemd-entrypoint[16564]: at org.elasticsearch.tools.launchers.JvmOption.findFinalOptions(JvmOption.java:81)
Nov 14 16:22:21 appserver systemd-entrypoint[16564]: at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:38)
Nov 14 16:22:21 appserver systemd-entrypoint[16564]: at org.elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:135)
Nov 14 16:22:21 appserver systemd-entrypoint[16564]: at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:86)
Nov 14 16:22:21 appserver systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Nov 14 16:22:21 appserver systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
Nov 14 16:22:21 appserver systemd[1]: Failed to start Elasticsearch.
-- Subject: Unit elasticsearch.service has failed
jvm.options 文件:
################################################################
## IMPORTANT: JVM heap size
################################################################
##
-Xms8g
-Xmx8g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/7.17/heap-size.html
## for more information
##
################################################################
################################################################
## Expert settings
################################################################
## GC configuration
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
## G1GC Configuration
# NOTE: G1 GC is only supported on JDK version 10 or later
# to use G1GC, uncomment the next two lines and update the version on the
# following three lines to your version of the JDK
# 10-13:-XX:-UseConcMarkSweepGC
# 10-13:-XX:-UseCMSInitiatingOccupancyOnly
#14-:-XX:+UseG1GC
#14-:-XX:G1ReservePercent=25
#14-:-XX:InitiatingHeapOccupancyPercent=30
## 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. Recommended to also use
# on java 8 for supported versions (8u92+).
9-:-XX:+ExitOnOutOfMemoryError
# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=/var/lib/elasticsearch
# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=/var/log/elasticsearch/gc.log
## JDK 8 GC logging
8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringDistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:/var/log/elasticsearch/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m
# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m
我之前在 Elasticsearch 方面遇到过多个问题,需要一些指导来指导我该怎么做。
最终重新安装了 Elasticsearch,现在可以使用了。
100% 不确定问题是什么,但现在可以了!