在linux虚拟机安装Elasticsearch遇到的问题及解决方法
[0] unable to load JNA native support library, native methods will be disabled
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: JVM is using the client VM [Java HotSpot(TM) Client VM] but should be using a server VM for the best performance
[4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
[0] unable to load JNA native support library, native methods will be disabled
[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:/home/leyou/elasticsearch/lib/jts-core-1.15.0.jar, file:/home/leyou/elasticsearch/lib/elasticsearch-core-6.3.0.jar, file:/home/leyou/elasticsearch/lib/jna-4.5.1.jar, file:/home/leyou/elasticsearch/lib/lucene-analyzers-common-7.3.1.jar, file:/home/leyou/elasticsearch/lib/lucene-spatial-7.3.1.jar, file:/home/leyou/elasticsearch/lib/lucene-queries-7.3.1.jar, file:/home/leyou/elasticsearch/lib/lucene-suggest-7.3.1.jar, file:/home/leyou/elasticsearch/lib/snakeyaml-1.17.jar, file:/home/leyou/elasticsearch/lib/lucene-spatial3d-7.3.1.jar, file:/home/leyou/elasticsearch/lib/lucene-grouping-7.3.1.jar, file:/home/leyou/elasticsearch/lib/elasticsearch-6.3.0.jar, file:/home/leyou/elasticsearch/lib/log4j-api-2.9.1.jar, file:/home/leyou/elasticsearch/lib/t-digest-3.2.jar, file:/home/leyou/elasticsearch/lib/lucene-spatial-extras-7.3.1.jar, file:/home/leyou/elasticsearch/lib/lucene-queryparser-7.3.1.jar, file:/home/leyou/elasticsearch/lib/spatial4j-0.7.jar, file:/home/leyou/elasticsearch/lib/hppc-0.7.1.jar, file:/home/leyou/elasticsearch/lib/jackson-dataformat-smile-2.8.10.jar, file:/home/leyou/elasticsearch/lib/lucene-memory-7.3.1.jar, file:/home/leyou/elasticsearch/lib/lucene-sandbox-7.3.1.jar, file:/home/leyou/elasticsearch/lib/jackson-dataformat-yaml-2.8.10.jar, file:/home/leyou/elasticsearch/lib/elasticsearch-launchers-6.3.0.jar, file:/home/leyou/elasticsearch/lib/jopt-simple-5.0.2.jar, file:/home/leyou/elasticsearch/lib/plugin-cli-6.3.0.jar, file:/home/leyou/elasticsearch/lib/lucene-core-7.3.1.jar, file:/home/leyou/elasticsearch/lib/log4j-1.2-api-2.9.1.jar, file:/home/leyou/elasticsearch/lib/jackson-dataformat-cbor-2.8.10.jar, file:/home/leyou/elasticsearch/lib/lucene-highlighter-7.3.1.jar, file:/home/leyou/elasticsearch/lib/elasticsearch-x-content-6.3.0.jar, file:/home/leyou/elasticsearch/lib/lucene-backward-codecs-7.3.1.jar, file:/home/leyou/elasticsearch/lib/HdrHistogram-2.1.9.jar, file:/home/leyou/elasticsearch/lib/plugin-classloader-6.3.0.jar, file:/home/leyou/elasticsearch/lib/joda-time-2.9.9.jar, file:/home/leyou/elasticsearch/lib/elasticsearch-cli-6.3.0.jar, file:/home/leyou/elasticsearch/lib/log4j-core-2.9.1.jar, file:/home/leyou/elasticsearch/lib/lucene-join-7.3.1.jar, file:/home/leyou/elasticsearch/lib/jackson-core-2.8.10.jar, file:/home/leyou/elasticsearch/lib/lucene-misc-7.3.1.jar, file:/home/leyou/elasticsearch/lib/elasticsearch-secure-sm-6.3.0.jar]) at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:962) ~[jna-4.5.1.jar:4.5.1 (b0)] at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:922) ~[jna-4.5.1.jar:4.5.1 (b0)] at com.sun.jna.Native.<clinit>(Native.java:190) ~[jna-4.5.1.jar:4.5.1 (b0)] at java.lang.Class.forName0(Native Method) ~[?:1.8.0_05] at java.lang.Class.forName(Class.java:259) ~[?:1.8.0_05] at org.elasticsearch.bootstrap.Natives.<clinit>(Natives.java:45) [elasticsearch-6.3.0.jar:6.3.0] at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) [elasticsearch-6.3.0.jar:6.3.0] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) [elasticsearch-6.3.0.jar:6.3.0] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) [elasticsearch-6.3.0.jar:6.3.0] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) [elasticsearch-6.3.0.jar:6.3.0] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) [elasticsearch-6.3.0.jar:6.3.0] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) [elasticsearch-6.3.0.jar:6.3.0] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) [elasticsearch-cli-6.3.0.jar:6.3.0] at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-cli-6.3.0.jar:6.3.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) [elasticsearch-6.3.0.jar:6.3.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) [elasticsearch-6.3.0.jar:6.3.0]
抛出的异常是说找不到JNA的本地依赖。
解决:
在elasticsearch的安装目录的bin下直接下载需要的JNA jar包
wget https://repo1.maven.org/maven2/net/java/dev/jna/jna/4.5.1/jna-4.5.1.jar。
或者把原来的JNA 的jar包删除,在windows下重新下载jna jar包,后上传到elasticsearch的lib文件中。
重新运行: ./elasticsearch
下面提供jna 4.5.1 jar包:
链接:https://pan.baidu.com/s/1ZkO557yf1JC2r-o0ysb1YA
提取码:u86i
运行之后出现新的错误
ERROR: [4] bootstrap checks failed [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] [3]: JVM is using the client VM [Java HotSpot(TM) Client VM] but should be using a server VM for the best performance [4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
编辑 /etc/security/limits.conf,追加以下内容;
soft nofile 65536
hard nofile 65536
此文件修改后需要重新登录用户,才会生效
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
编辑 /etc/sysctl.conf,追加以下内容:
vm.max_map_count=655360
保存后,执行:
sysctl -p
[3]: JVM is using the client VM [Java HotSpot™ Client VM] but should be using a server VM for the best performance
意思是当前jvm是Java HotSpot Client VM(-client),而应该使用的是Java HotSpot Server VM(-server),前者如其名称,应该适合在客户端使用,后者则适合在服务器环境中使用。
所以只需要从Java HotSpot Client VM(-client)切换到Java HotSpot Server VM(-server)就行。
找到jre目录,切换到该下
cd /usr/local/jdk/jdk1.8.0_05/jre
然后修改 ./lib/i386/jvm.cfg这个文件,把-server KNOWN移到第一行,就是-client上面,保存退出即可。
[4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
在 config/elasticsearch.yml 末尾加上一句
bootstrap.system_call_filter: false
重新运行: ./elasticsearch
出现这些信息就是启动成功了。
我这里是要访问 192.168.237.128:9200