docker安装Elasticsearch以及分词器

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

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值