Unable to load JNA native support library Elasticsearch 6.x

Gagantous picture Gagantous · Dec 15, 2017 · Viewed 10.6k times · Source

I have installed Elasticsearch 6.x in my Debian 7 (wheezy). I tried to start with service elasticsearch start but its give me an error message

root@debian:~# sudo -i service elasticsearch start
[FAIL] Starting Elasticsearch Server: failed!

I tried to look at the elasticsearch log files at nano /var/log/elasticsearch/elasticsearch.log, and i got this error

[2017-12-14T11:25:39,153][WARN ][o.e.b.Natives            ] unable to load JNA native support library, native methods will be disabled.
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/linux-x86/libjnidispatch.so) not found in resource path ([file:/usr/share/elasticsearch/lib/lucene-spatial-$
        at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:962) ~[jna-4.4.0-1.jar:4.4.0 (b0)]
        at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:922) ~[jna-4.4.0-1.jar:4.4.0 (b0)]
        at com.sun.jna.Native.<clinit>(Native.java:190) ~[jna-4.4.0-1.jar:4.4.0 (b0)]
        at java.lang.Class.forName0(Native Method) ~[?:1.8.0_151]
        at java.lang.Class.forName(Class.java:264) ~[?:1.8.0_151]
        at org.elasticsearch.bootstrap.Natives.<clinit>(Natives.java:45) [elasticsearch-6.1.0.jar:6.1.0]
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) [elasticsearch-6.1.0.jar:6.1.0]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) [elasticsearch-6.1.0.jar:6.1.0]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:322) [elasticsearch-6.1.0.jar:6.1.0]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) [elasticsearch-6.1.0.jar:6.1.0]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) [elasticsearch-6.1.0.jar:6.1.0]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) [elasticsearch-6.1.0.jar:6.1.0]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) [elasticsearch-cli-6.1.0.jar:6.1.0]
        at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-cli-6.1.0.jar:6.1.0]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) [elasticsearch-6.1.0.jar:6.1.0]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) [elasticsearch-6.1.0.jar:6.1.0]
[2017-12-14T11:25:39,212][WARN ][o.e.b.Natives            ] cannot check if running as root because JNA is not available
[2017-12-14T11:25:39,212][WARN ][o.e.b.Natives            ] cannot install system call filter because JNA is not available
[2017-12-14T11:25:39,215][WARN ][o.e.b.Natives            ] cannot register console handler because JNA is not available
[2017-12-14T11:25:39,256][WARN ][o.e.b.Natives            ] cannot getrlimit RLIMIT_NPROC because JNA is not available
[2017-12-14T11:25:39,256][WARN ][o.e.b.Natives            ] cannot getrlimit RLIMIT_AS beacuse JNA is not available
[2017-12-14T11:25:39,256][WARN ][o.e.b.Natives            ] cannot getrlimit RLIMIT_FSIZE because JNA is not available

How can i fixed this ? i have installed java, and it's version javac 1.8.0_151

what could go wrong with my code ? `

Answer

rajdeepbs29 picture rajdeepbs29 · May 16, 2018
  1. Go to /etc/sysconfig/elasticsearch
  2. Add ES_JAVA_OPTS="-Djna.tmpdir=/var/lib/elasticsearch/tmp".

    (For newer Elasticsearch, use Djava.io.tmpdir instead of Djna.tmpdir)

  3. Start Elasticsearch using systemctl start elasticsearch or service start elasticsearch.
  4. You can see now tmp folder created inside /var/lib/elasticsearch/.
  5. This folder should have execute permission for elasticsearch user
  6. Check the permission with name i -l /var/lib/elasticsearch
  7. Make sure the permission file have something like below permission

    dr-xr-xr-x root          root          /
    drwxr-xr-x root          root          var
    drwxr-xr-x root          root          lib
    drwxr-x--- elasticsearch elasticsearch elasticsearch
    

I hope your issue will be resolved.