使用docker-compose安装elasticsearch6.8.1

创建配置文件docker-compose.yml

version: '3.1'
services:
    elasticsearch:
        image: elasticsearch:6.8.1
        container_name: es
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        volumes:
          - ./data:/usr/share/elasticsearch/data
          - ./node/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
          - ./plugins:/usr/share/elasticsearch/plugins
        environment:
          - TZ=Asia/Shanghai
          - "ES_JAVA_OPTS=-Xms300m -Xmx300m"
          - ES_CLUSTERNAME=elasticsearch
          - discovery.type=single-node
        ports:
          - "9200:9200"
          - "9300:9300"

下载ik分词器(必须对应版本)

https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v6.8.1
解压到elasticsearch根目录的plugins/ik下

常见问题

  • 闪退并报错
    Failed to create node environment

/usr/share/elasticsearch/data映射的文件夹权限不足

  • Java启动ES报错
    NoNodeAvailableException[None of the configured nodes are available

application.yml中设置正确的cluster_name(和elasticsearch配置中对应)

你可能感兴趣的:(Java,Elasticsearch,CentOS)