Elasticsearch权威指南
Kibana用户手册

版本对应:
在这里插入图片描述

# docker pull docker.elastic.co/elasticsearch/elasticsearch:6.2.2

# docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 --name es_server docker.elastic.co/elasticsearch/elasticsearch:6.2.2

参数 -d 后台运行容器,不指定可以看容器启动记录。

可能碰到的问题:
虚拟内存太小 [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决:
在宿主机执行:

# sysctl -w vm.max_map_count=262144

安装分词器(https://github.com/medcl/elasticsearch-analysis-ik/tree/v6.2.2)
进入es容器,这个目录
在这里插入图片描述
1.download or compile 安装分词器

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.2/elasticsearch-analysis-ik-6.2.2.zip

2.restart elasticsearch 重启Elasticsearch
在这里插入图片描述
elasticSearch启动报错:elasticsearch: OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
在jvm.options 中加入:(/usr/local/elasticsearch/config/jvm.options)
-XX:+AssumeMP

项目集成es:

// https://mvnrepository.com/artifact/org.springframework.data/spring-data-elasticsearch
compile group: 'org.springframework.data', name: 'spring-data-elasticsearch', version: '3.1.4.RELEASE'

spring data 集成es的start:

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-elasticsearch
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-elasticsearch', version: '2.1.2.RELEASE'

先看你的gradle文件是否用了redis

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>

如果在同时使用elastic search,请加上版本号

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
        <version>2.0.4.RELEASE</version>
    </dependency>

如果启动还是报错, 请尝试在Application.class类中加上一句:

  //  System.setProperty("es.set.netty.runtime.available.processors", "false");
    public class SpringBootTestApplication extends SpringBootServletInitializer {
 
    public static void main(String[] args) throws Exception {
        System.setProperty("es.set.netty.runtime.available.processors", "false");
        SpringApplication.run(SpringBootTestApplication.class, args);
    }
}

application.yml全局配置:

server:
  port: 80
spring:
    data:
        elasticsearch:
          cluster-name: docker-cluster
          cluster-nodes: 127.0.0.1:9300

下篇 安装Kibana : https://blog.csdn.net/wangxudongx/article/details/87268384

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐