Unable to load JNA native support library Elasticsearch 6.x

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 ? `

7 Answers

  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.

9

I had the same issue on a CentOS7 cPanel server with ElasticSearch 7.8 installed via YUM. As per the answer, I did the following:

  1. Set ES_JAVA_OPTS="-Djna.tmpdir=/var/lib/elasticsearch/tmp" in /etc/sysconfig/elasticsearch
  2. mkdir -p /var/lib/elasticsearch/tmp
  3. chown -R elasticsearch.elasticsearch /var/lib/elasticsearch/tmp
1

Check the permissions on your /tmp/ directory. It must have had noexec.

/tmp needs exec to support JNA. A workaround is to specify a tmp directory in elasticsearch sysconfig file.

Something like export JAVA_OPTS="-Djava.io.tmpdir=$ES_HOME/tmp"

Make sure there is a $ES_HOME/tmp directory and elasticsearch user has write permissions to it.

I had this issue as I was using a hardened OS and also because the default umask is 0027.

The same problem happened to me on Windows 10 when running from command prompt:

unable to load JNA native support library, native methods will be disabled.

To solve this, it was enough to run elasticsearch.exe with Admin rights (Click Start -> type "Command" -> right click on "Command Prompt" -> select "Run as Administrator")

0

For me below worked:

PUT your_index_name/_settings { "index": { "blocks": { "read_only_allow_delete": "false" } } }

I followed below link:

On Ubuntu 18.04, the solution was

sudo systemctl edit --full elasticsearch.service

adding a line

Environment=ES_JAVA_OPTS="-Djava.io.tmpdir=/var/lib/elasticsearch/tmp"

exitting with -x as in vi

restarting the service

sudo systemctl restart elasticsearch.service

Okay i have find the solution. Apparently my vm memory storage (RAM) was 1 GB - 2 GB, so i increase my VM's RAM capacity to at least 4GB and i reboot the machine. And elastic search started work just fine.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like