Elasticsearch整合SpringBoot - 配置文件

目录

  • 创建工程,引入依赖
  • 配置yml
  • 版本协调
  • Netty issue fix
  • 附 elasticsearch6.4.3配置文件
  • Don’t forget!

创建工程,引入依赖


	org.springframework.boot
	spring-boot-starter-data-elasticsearch
	
	2.2.2.RELEASE



	org.springframework.boot
	spring-boot-starter-test
	test

配置yml

spring:
  data:
    elasticsearch:
      cluster-name: es6
      cluster-nodes: 192.168.1.187:9300

版本协调

目前springboot-data-elasticsearch中的es版本贴合为es-6.4.3,如此一来版本需要统一,把es进行降级。等springboot升级es版本后可以在对接最新版的7.4。

Netty issue fix

@Configuration
public class ESConfig {

    /**
     * 解决netty引起的issue
     */
    @PostConstruct
    void init() {
        System.setProperty("es.set.netty.runtime.available.processors", "false");
    }

}

附 elasticsearch6.4.3配置文件

elasticsearch.yml

cluster.name: es6
node.name: node0
path.data: /usr/local/elasticsearch-6.4.3/data
path.logs: /usr/local/elasticsearch-6.4.3/logs
network.host: 0.0.0.0

./elasticsearch
如果出现如下错误:
在这里插入图片描述
那么需要切换到root用户下去修改配置如下:

vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096


vim /etc/sysctl.conf
# 添加以下内容
vm.max_map_count=262145

别忘记 sysctl -p 刷新一下
最后再次启动OK

Don’t forget!

中文分词器也需要去配置一下噢别忘记!:)
中文分词器的版本要记得使用6,版本一定要贴合噢~
比如目前的所有版本都是统一为es-6.4.3,那么下载地址为:
https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v6.4.3

你可能感兴趣的:(Elasticsearch)