安装ElasticSearch_基于Docker

关于new-elasticsearch.yml禁用https的操作是因为默认情况下,Elasticsearch使用HTTPS来加密通信,启动elasticsearch容器会导致Elasticsearch无法正常工作,如果你的服务器是基于HTTPS访问,请忽略该操作

拉取Docker镜像,选择你从来没有玩过的船新版本

docker pull docker.elastic.co/elasticsearch/elasticsearch:8.10.2 // ElasticSearch镜像

docker pull docker.elastic.co/kibana/kibana:8.10.2 // kibana镜像

将Elasticsearch容器中的elasticsearch.yml文件复制到服务器当前目录下

docker cp [Elasticsearch容器ID或Elasticsearch容器名称]:/usr/share/elasticsearch/config/elasticsearch.yml ./new-elasticsearch.yml

修改new-elasticsearch.yml文件

cluster.name: "docker-cluster"
network.host: 0.0.0.0

#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
#
# The following settings, TLS certificates, and keys have been automatically      
# generated to configure Elasticsearch security features on 06-10-2023 09:40:36
#
# --------------------------------------------------------------------------------

# Enable security features
# true --> false 禁用https
xpack.security.enabled: false

xpack.security.enrollment.enabled: true

# 注释以下配置,禁用SSL,确保Elasticsearch不再尝试加载证书
# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
#xpack.security.http.ssl:
#  enabled: true
#  keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
#xpack.security.transport.ssl:
#  enabled: true
#  verification_mode: certificate
#  keystore.path: certs/transport.p12
#  truststore.path: certs/transport.p12
#----------------------- END SECURITY AUTO CONFIGURATION -------------------------

准备docker-compose.yml文件

version: '3.8'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.10.2
    container_name: elasticsearch
    environment:
      - discovery.type=single-node
    ports:
      - 9200:9200
    # new-elasticsearch.yml文件禁用了https,并将此文件挂载到容器内并替换默认的elasticsearch.yml文件
    volumes:
      - ./new-elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    networks:
      - elk

  kibana:
    image: docker.elastic.co/kibana/kibana:8.10.2
    container_name: kibana
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch
    networks:
      - elk

networks:
  elk:
    driver: bridge

docker-compose up -d // 启动

浏览器访问 http://<服务器IP>:9200

浏览器访问kibana http://<服务器IP>:5601

posted @ 2023-10-05 23:30  Ashe|||^_^  阅读(124)  评论(0编辑  收藏  举报