docker之elasticsearch部署

es搭建

es发行了许多版本,了解的有6,7,8。8不向下兼容,且springboot中没有相应的包,这里主要演示搭建单机的7X,具体版本为7.14.0。

es单机部署很简单,这里用dockerfile演示
version: '3'
services:
  elasticsearch:
    image: elasticsearch:7.14.0
    container_name: es
    restart: always
    ports:
      - 9200:9200
      - 9300:9300
    environment:
      discovery.type: single-node
      ELASTICSEARCH_USERNAME: 'root'
      ELASTICSEARCH_PASSWORD: '123456a'
      xpack.security.enabled: "false"
      xpack.security.transport.ssl.enabled: "false"
由于使用的官方的镜像,没有附带任何插件,这里自己做了个镜像上传到dockerhub,也可以使用以下配置
version: '3'
services:
  elasticsearch:
    image: stone1998/ik-es
    container_name: es
    restart: always
    ports:
      - 9200:9200
      - 9300:9300
    environment:
      discovery.type: single-node
      ELASTICSEARCH_USERNAME: 'root'
      ELASTICSEARCH_PASSWORD: '123456a'
      xpack.security.enabled: "false"
      xpack.security.transport.ssl.enabled: "false"
为了方便使用也可以可以安装下面的,不过需要docker-compose,连接了kibana容器
version: '3'
services:
  elasticsearch:
    image: stone1998/ik-es
    container_name: es
    networks:
      - elasticsearch
    restart: always
    ports:
      - 9200:9200
      - 9300:9300
    environment:
      discovery.type: single-node
      ELASTICSEARCH_USERNAME: 'root'
      ELASTICSEARCH_PASSWORD: '123456a'
      xpack.security.enabled: "false"
      xpack.security.transport.ssl.enabled: "false"
  kibana:
   image: kibana:7.14.0
   container_name: webEs
   restart: always
   networks:
     - elasticsearch
   links:
     - elasticsearch
   ports:
     - 5601:5601
   environment:
   # 下面是自己的elasticsearch的ip,可以通过inspect查看
     ELASTICSEARCH_URL: "http://127.0.0.1:9200"
     ELASTICSEARCH_USERNAME: 'root'
     ELASTICSEARCH_PASSWORD: '123456a'
networks:
  elasticsearch:
以上是最近搭建es的配置,建议最好不要用es8,因为文档的type的完全移除,springboot的集成缺少,只能通过自己导入es官方提供的jar包,这样就少了很多的spring-api,操作很麻烦。
posted @ 2023-01-12 15:56  站在巨人肩上的人  阅读(469)  评论(0编辑  收藏  举报