Elasticsearch installation issues

After installing Elasticsearch, when I try to start the elasticsearch.service service, it fails to start and I receive the following error.

system is Ubuntu 20.04.
Elasticsearch version is 7.17.14

 sudo systemctl status elasticsearch.service 
● elasticsearch.service - Elasticsearch
     Loaded: loaded (/etc/systemd/system/elasticsearch.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2023-11-07 12:04:54 CST; 9s ago
       Docs: https://www.elastic.co
    Process: 25875 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=1/FAILURE)
   Main PID: 25875 (code=exited, status=1/FAILURE)
      Tasks: 0 (limit: 9424)
     Memory: 16.0M
     CGroup: /system.slice/elasticsearch.service

Nov 07 12:04:53 CNSHCHJ-DEV10849 systemd-entrypoint[25875]:         at java.base/java.lang.Class.forName(Class.java:412)
Nov 07 12:04:53 CNSHCHJ-DEV10849 systemd-entrypoint[25875]:         at org.elasticsearch.bootstrap.Natives.<clinit>(Natives.java:34)
Nov 07 12:04:53 CNSHCHJ-DEV10849 systemd-entrypoint[25875]:         at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106)
Nov 07 12:04:53 CNSHCHJ-DEV10849 systemd-entrypoint[25875]:         at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:183)
Nov 07 12:04:53 CNSHCHJ-DEV10849 systemd-entrypoint[25875]:         at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:434)
Nov 07 12:04:53 CNSHCHJ-DEV10849 systemd-entrypoint[25875]:         ... 7 more
Nov 07 12:04:53 CNSHCHJ-DEV10849 systemd-entrypoint[25875]: ERROR: Elasticsearch did not exit normally - check the logs at /var/log/elasticsearch/elasticsearch.log
Nov 07 12:04:54 CNSHCHJ-DEV10849 systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Nov 07 12:04:54 CNSHCHJ-DEV10849 systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
Nov 07 12:04:54 CNSHCHJ-DEV10849 systemd[1]: Failed to start Elasticsearch.

I found the following error in the log file "/var/log/elasticsearch/elasticsearch.log."

[2023-11-07T12:04:53,558][INFO ][o.e.n.Node               ] [CNSHCHJ-DEV10849] started
[2023-11-07T12:04:53,559][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [CNSHCHJ-DEV10849] fatal error in thread [main], exiting
java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native
	at org.elasticsearch.systemd.Libsystemd.lambda$static$0(Libsystemd.java:23) ~[?:?]
	at java.security.AccessController.doPrivileged(AccessController.java:319) ~[?:?]
	at org.elasticsearch.systemd.Libsystemd.<clinit>(Libsystemd.java:22) ~[?:?]
	at org.elasticsearch.systemd.SystemdPlugin.sd_notify(SystemdPlugin.java:113) ~[?:?]
	at org.elasticsearch.systemd.SystemdPlugin.onNodeStarted(SystemdPlugin.java:124) ~[?:?]
	at java.util.ArrayList.forEach(ArrayList.java:1596) ~[?:?]
	at org.elasticsearch.node.Node.start(Node.java:1277) ~[elasticsearch-7.17.14.jar:7.17.14]
	at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:335) ~[elasticsearch-7.17.14.jar:7.17.14]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:443) ~[elasticsearch-7.17.14.jar:7.17.14]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:169) ~[elasticsearch-7.17.14.jar:7.17.14]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:160) ~[elasticsearch-7.17.14.jar:7.17.14]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:77) ~[elasticsearch-7.17.14.jar:7.17.14]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112) ~[elasticsearch-cli-7.17.14.jar:7.17.14]
	at org.elasticsearch.cli.Command.main(Command.java:77) ~[elasticsearch-cli-7.17.14.jar:7.17.14]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:125) ~[elasticsearch-7.17.14.jar:7.17.14]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80) ~[elasticsearch-7.17.14.jar:7.17.14]
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsatisfiedLinkError: /tmp/elasticsearch-2814356569535137225/jna13042864340358578611.tmp: /tmp/elasticsearch-2814356569535137225/jna13042864340358578611.tmp: failed to map segment from shared object [in thread "main"]
	at jdk.internal.loader.NativeLibraries.load(Native Method) ~[?:?]
	at jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331) ~[?:?]
	at jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197) ~[?:?]
	at jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139) ~[?:?]
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2418) ~[?:?]
	at java.lang.Runtime.load0(Runtime.java:852) ~[?:?]
	at java.lang.System.load(System.java:2021) ~[?:?]
	at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1045) ~[jna-5.10.0.jar:5.10.0 (b0)]
	at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:1015) ~[jna-5.10.0.jar:5.10.0 (b0)]
	at com.sun.jna.Native.<clinit>(Native.java:221) ~[jna-5.10.0.jar:5.10.0 (b0)]
	at java.lang.Class.forName0(Native Method) ~[?:?]
	at java.lang.Class.forName(Class.java:421) ~[?:?]
	at java.lang.Class.forName(Class.java:412) ~[?:?]
	at org.elasticsearch.bootstrap.Natives.<clinit>(Natives.java:34) ~[elasticsearch-7.17.14.jar:7.17.14]
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-7.17.14.jar:7.17.14]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:183) ~[elasticsearch-7.17.14.jar:7.17.14]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:434) ~[elasticsearch-7.17.14.jar:7.17.14]

Want to ask what I should do to solve this problem

Then I found the solution in this link
"Centos 7 and - java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native · Issue #57018 · elastic/elasticsearch · GitHub"

image
Now my service is running

But I'm still curious about the positioning of this problem

Reading through the Github issue you mentioned, it appears to be an issue which happens when the location is not writable to the process.

Which i.m.o is not an elastic issue but has to do with the system configuration.

However, elastic could improve the error if that is the case.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.