Skip to content

Commit d34da0e

Browse files
pugnascotiarjernst
authored andcommitted
Check glibc version (#62728)
Java 15 requires at last glibc 2.14, but we support older Linux OSs that ship with older versions. Rather than continue to ship Java 14, which is now EOL and therefore unsupported, ES will detect this situation and print a helpful message, instead of the cryptic error that would otherwise be printed. Users on older OSs will have to set JAVA_HOME instead of using the bundled JVM. This doesn't affect v8.0.0 because these older Linux OSs will not be supported, and all the supported ones have glibc 2.14.
1 parent 7c77c2c commit d34da0e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

distribution/src/bin/elasticsearch-env

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,43 @@ ES_HOME=`dirname "$ES_HOME"`
3535
# now set the classpath
3636
ES_CLASSPATH="$ES_HOME/lib/*"
3737

38+
39+
# On systems that are built upon glibc, We need to check the version of
40+
# glibc because Elasticsearch bundles JDK 15, which requires glibc >= 2.14
41+
check_glibc_version() {
42+
local GETCONF="$( getconf GNU_LIBC_VERSION 2>/dev/null )"
43+
if [[ $? -ne 0 ]]; then
44+
# Must be on a POSIX system that isn't using glibc.
45+
return 0
46+
fi
47+
48+
local GLIBC_VERSION="$( echo "$GETCONF" | cut -d' ' -f2 )"
49+
local MAJOR="$( echo $GLIBC_VERSION | cut -d. -f1 )"
50+
local MINOR="$( echo $GLIBC_VERSION | cut -d. -f2 )"
51+
52+
local STATUS=pass
53+
54+
if [[ "$MAJOR" -lt 2 ]]; then
55+
STATUS=fail
56+
elif [[ "$MAJOR" -eq 2 && "$MINOR" -lt 14 ]]; then
57+
STATUS=fail
58+
fi
59+
60+
if [[ "$STATUS" == "fail" ]]; then
61+
cat >&2 <<EOF
62+
63+
ERROR: The JDK bundled with Elasticsearch requires glibc >= 2.14, but
64+
you have version $GLIBC_VERSION. Please set the JAVA_HOME environment variable
65+
to point to a working JDK installation. For more information, see:
66+
67+
https://www.elastic.co/support/matrix#matrix_jvm
68+
69+
EOF
70+
exit 1
71+
fi
72+
}
73+
74+
3875
# now set the path to java
3976
if [ ! -z "$JAVA_HOME" ]; then
4077
JAVA="$JAVA_HOME/bin/java"
@@ -44,6 +81,7 @@ else
4481
# macOS has a different structure
4582
JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java"
4683
else
84+
check_glibc_version
4785
JAVA="$ES_HOME/jdk/bin/java"
4886
fi
4987
JAVA_TYPE="bundled jdk"

0 commit comments

Comments
 (0)