Unable to load JNA native support library Elasticsearch 6.x

余生颓废 提交于 2020-12-22 06:59:12

问题


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


回答1:


  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.




回答2:


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.




回答3:


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



回答4:


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")




回答5:


For me below worked:

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

I followed below link:

https://discuss.elastic.co/t/forbidden-12-index-read-only-allow-delete-api/110282/4




回答6:


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




回答7:


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.



来源:https://stackoverflow.com/questions/47824643/unable-to-load-jna-native-support-library-elasticsearch-6-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!