无法加载 JNA 本机支持库 Elasticsearch 6.x
Unable to load JNA native support library Elasticsearch 6.x
我在 Debian 7 (wheezy)
中安装了 Elasticsearch 6.x。我尝试从 service elasticsearch start
开始,但它给我一条错误消息
root@debian:~# sudo -i service elasticsearch start
[FAIL] Starting Elasticsearch Server: failed!
我试图查看 nano /var/log/elasticsearch/elasticsearch.log
处的 elasticsearch 日志文件,但出现此错误
[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
我该如何解决这个问题?我已经安装了 java,它是 version javac 1.8.0_151
我的代码可能出了什么问题?
`
检查您的 /tmp/
目录的权限。它一定有 noexec
.
/tmp
需要 exec
来支持 JNA。解决方法是在 elasticsearch sysconfig 文件中指定 tmp
目录。
类似于export JAVA_OPTS="-Djava.io.tmpdir=$ES_HOME/tmp"
确保存在 $ES_HOME/tmp
目录并且 elasticsearch
用户对其具有写入权限。
我在使用强化的 OS 时遇到了这个问题,还因为默认的 umask 是 0027
。
我在 Windows 10 从命令提示符 运行ning 时遇到了同样的问题:
unable to load JNA native support library, native methods will be disabled.
要解决此问题,只需 运行 elasticsearch.exe 具有管理员权限 (单击开始 -> 输入 "Command" -> 右击 "Command Prompt" -> select "Run as Administrator")
好的,我找到了解决方案。显然,我的虚拟机内存存储 (RAM) 为 1 GB - 2 GB,因此我将虚拟机的 RAM 容量增加到至少 4GB,然后重新启动机器。弹性搜索开始工作得很好。
- 转到
/etc/sysconfig/elasticsearch
添加ES_JAVA_OPTS="-Djna.tmpdir=/var/lib/elasticsearch/tmp"
.
(对于较新的 Elasticsearch,使用 Djava.io.tmpdir
而不是 Djna.tmpdir
)
- 使用
systemctl start elasticsearch
或 service start elasticsearch
启动 Elasticsearch。
- 您现在可以看到在
/var/lib/elasticsearch/
中创建了 tmp
文件夹。
- 此文件夹应具有
elasticsearch
用户 的执行权限
- 检查名称
i -l /var/lib/elasticsearch
的权限
确保权限文件有如下权限
dr-xr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root lib
drwxr-x--- elasticsearch elasticsearch elasticsearch
希望您的问题得到解决。
我在通过 YUM 安装了 ElasticSearch 7.8 的 CentOS7 cPanel 服务器上遇到了同样的问题。
根据 ,我做了以下操作:
- 在
/etc/sysconfig/elasticsearch
中设置ES_JAVA_OPTS="-Djna.tmpdir=/var/lib/elasticsearch/tmp"
mkdir -p /var/lib/elasticsearch/tmp
chown -R elasticsearch.elasticsearch /var/lib/elasticsearch/tmp
下面对我有用:
PUT your_index_name/_settings
{
"index": {
"blocks": {
"read_only_allow_delete": "false"
}
}
}
我关注了下面link:
https://discuss.elastic.co/t/forbidden-12-index-read-only-allow-delete-api/110282/4
在 Ubuntu 18.04,解决方案是
sudo systemctl edit --full elasticsearch.service
添加一行
Environment=ES_JAVA_OPTS="-Djava.io.tmpdir=/var/lib/elasticsearch/tmp"
在 vi 中使用 -x 退出
正在重新启动服务
sudo systemctl restart elasticsearch.service
我在 Debian 7 (wheezy)
中安装了 Elasticsearch 6.x。我尝试从 service elasticsearch start
开始,但它给我一条错误消息
root@debian:~# sudo -i service elasticsearch start
[FAIL] Starting Elasticsearch Server: failed!
我试图查看 nano /var/log/elasticsearch/elasticsearch.log
处的 elasticsearch 日志文件,但出现此错误
[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
我该如何解决这个问题?我已经安装了 java,它是 version javac 1.8.0_151
我的代码可能出了什么问题? `
检查您的 /tmp/
目录的权限。它一定有 noexec
.
/tmp
需要 exec
来支持 JNA。解决方法是在 elasticsearch sysconfig 文件中指定 tmp
目录。
类似于export JAVA_OPTS="-Djava.io.tmpdir=$ES_HOME/tmp"
确保存在 $ES_HOME/tmp
目录并且 elasticsearch
用户对其具有写入权限。
我在使用强化的 OS 时遇到了这个问题,还因为默认的 umask 是 0027
。
我在 Windows 10 从命令提示符 运行ning 时遇到了同样的问题:
unable to load JNA native support library, native methods will be disabled.
要解决此问题,只需 运行 elasticsearch.exe 具有管理员权限 (单击开始 -> 输入 "Command" -> 右击 "Command Prompt" -> select "Run as Administrator")
好的,我找到了解决方案。显然,我的虚拟机内存存储 (RAM) 为 1 GB - 2 GB,因此我将虚拟机的 RAM 容量增加到至少 4GB,然后重新启动机器。弹性搜索开始工作得很好。
- 转到
/etc/sysconfig/elasticsearch
添加
ES_JAVA_OPTS="-Djna.tmpdir=/var/lib/elasticsearch/tmp"
.(对于较新的 Elasticsearch,使用
Djava.io.tmpdir
而不是Djna.tmpdir
)- 使用
systemctl start elasticsearch
或service start elasticsearch
启动 Elasticsearch。 - 您现在可以看到在
/var/lib/elasticsearch/
中创建了tmp
文件夹。 - 此文件夹应具有
elasticsearch
用户 的执行权限
- 检查名称
i -l /var/lib/elasticsearch
的权限
确保权限文件有如下权限
dr-xr-xr-x root root / drwxr-xr-x root root var drwxr-xr-x root root lib drwxr-x--- elasticsearch elasticsearch elasticsearch
希望您的问题得到解决。
我在通过 YUM 安装了 ElasticSearch 7.8 的 CentOS7 cPanel 服务器上遇到了同样的问题。
根据
- 在
/etc/sysconfig/elasticsearch
中设置 mkdir -p /var/lib/elasticsearch/tmp
chown -R elasticsearch.elasticsearch /var/lib/elasticsearch/tmp
ES_JAVA_OPTS="-Djna.tmpdir=/var/lib/elasticsearch/tmp"
下面对我有用:
PUT your_index_name/_settings
{
"index": {
"blocks": {
"read_only_allow_delete": "false"
}
}
}
我关注了下面link:
https://discuss.elastic.co/t/forbidden-12-index-read-only-allow-delete-api/110282/4
在 Ubuntu 18.04,解决方案是
sudo systemctl edit --full elasticsearch.service
添加一行
Environment=ES_JAVA_OPTS="-Djava.io.tmpdir=/var/lib/elasticsearch/tmp"
在 vi 中使用 -x 退出
正在重新启动服务
sudo systemctl restart elasticsearch.service