ElasticSearch常见问题解决 - 1. 启动与客户端依赖

本文基于ElasticSearch 7.0.1

修改配置ip为外部ip时,相关错误

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

修改最大打开进程数,切换到root权限用户,修改/etc/security/limits.conf, 给启动elasticsearch的用户配置(例如用户为centos):

centos soft nproc 65536
centos hard nproc 65536
centos soft nofile 65536
centos hard nofile 65536
centos soft memlock 4000000
centos hard memlock 4000000

之后修改/etc/profile,在末尾添加:

ulimit -n 65535

切换回centos用户

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

切换到root权限用户,修改/etc/security/limits.conf,添加:

vm.max_map_count=655360

然后执行sysctl -p

the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

在修改host之后,就一定要配置discovery,配置discovery.seed_hosts最简单,就是集群中所有elasticsearch实例地址,例如:

discovery.seed_hosts: ["10.238.6.67","10.238.6.68"]

SpringBoot下使用ElasticSearch客户端时,出现ElasticSearch依赖不对

官网配置说引入下面maven依赖就够:


    org.elasticsearch.client
    elasticsearch-rest-high-level-client
    7.0.1

但是在Springboot依赖环境下可能出现的报错:

 java.lang.NoClassDefFoundError: org/elasticsearch/common/xcontent/DeprecationHandler
    at com.lv.springboot.datasource.ClientUTis.main(ClientUTis.java:13)
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.common.xcontent.DeprecationHandler
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 1 more

我们通过mvn dependency tree 可以发现,依赖不对:

org.elasticsearch.client:elasticsearch-rest-high-level-client:7.0.1
|--org.elasticsearch:elasticsearch:5.6.16
|--org.elasticsearch.client:elasticsearch-rest-client:7.0.1
|--org.elasticsearch.plugin:parent-join-client:7.0.1
|--org.elasticsearch.plugin:aggs-matrix-stats-client:7.0.1
|--org.elasticsearch.plugin:rank-eval-client:7.0.1
|--org.elasticsearch.plugin:lang-mustache-client:7.0.1

我们查看SpringBoot的DependencyManagement发现,org.elasticsearch:elasticsearch已经被包含了(以下为节选):

org.springframework.boot
spring-boot-dependencies
2.0.9.RELEASE


5.6.16





org.elasticsearch
elasticsearch
${elasticsearch.version}




一个解决办法就是,在自己的项目加入dependencyManagement来覆盖掉springboot这个parent里面的:




org.elasticsearch
elasticsearch
7.0.1



你可能感兴趣的:(搜索引擎ES)