写点什么

Docker Compose 部署 Kibana 和 Elasticsearch 本地集群 8.1.3

作者:kenny
  • 2022 年 4 月 22 日
  • 本文字数:1651 字

    阅读完需:约 5 分钟

利用 Docker Compose 可非常快搭建好开发所依赖的环境(如数据库,中间件),且可以很方便切换不同版本,大大降低学习新知识难度。本文带你快速搭建 Elasticsearch 的学习环境


1. 环境准备

当然需要安装 docker 和 docker compose。无论那类操作系统,网上安装文档非常多,这里不再赘述。


2. 准备 docker-compose.yml 文件

这里部署的是单机集群环境

version: '3.0'

services:

kibana:

image: docker.elastic.co/kibana/kibana:8.1.3

container_name: kib #容器名

environment:

#- I18N_LOCALE=zh-CN #本地化

- XPACK_GRAPH_ENABLED=false

- TIMELION_ENABLED=true

- XPACK_MONITORING_COLLECTION_ENABLED="false"

ports:

- "5601:5601"

networks:

- elastic #docker networds

volumes:

- /Users/kenny/Downloads/kibana.yml:/usr/share/kibana/config/kibana.yml:rw

depends_on:

- es02

es02:

image: docker.elastic.co/elasticsearch/elasticsearch:8.1.2

container_name: es02

environment:

- node.name=es02

- cluster.name=es-docker-cluster

- discovery.seed_hosts=es03,es04

- cluster.initial_master_nodes=es02

- bootstrap.memory_lock=true

- network.publish_host=es02

- network.host=0.0.0.0

- xpack.security.transport.ssl.enabled=false

- xpack.security.enabled=false

- http.cors.enabled=true

- http.cors.allow-origin=*

# 设置虚拟机内存

- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"

ulimits:

# 使用系统内存 无限制

memlock:

soft: -1

hard: -1

volumes:

- data02:/usr/share/elasticsearch/data

ports:

- 9202:9200

networks:

- elastic

es03:

image: docker.elastic.co/elasticsearch/elasticsearch:8.1.2

container_name: es03

environment:

- node.name=es03

- cluster.name=es-docker-cluster

- discovery.seed_hosts=es02,es04

- cluster.initial_master_nodes=es02

- network.host=0.0.0.0

- bootstrap.memory_lock=true

- network.publish_host=es03

- xpack.security.transport.ssl.enabled=false

- xpack.security.enabled=false

- http.cors.enabled=true

- http.cors.allow-origin=*

- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"

ulimits:

memlock:

soft: -1

hard: -1

volumes:

- data03:/usr/share/elasticsearch/data

networks:

- elastic

es04:

image: docker.elastic.co/elasticsearch/elasticsearch:8.1.2

container_name: es04

environment:

- node.name=es04

- cluster.name=es-docker-cluster

- discovery.seed_hosts=es02,es03

- cluster.initial_master_nodes=es02

- network.host=0.0.0.0

- bootstrap.memory_lock=true

- network.publish_host=es04

- xpack.security.transport.ssl.enabled=false

- xpack.security.enabled=false

- http.cors.enabled=true

- http.cors.allow-origin=*

- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"

ulimits:

memlock:

soft: -1

hard: -1

volumes:

- data04:/usr/share/elasticsearch/data

networks:

- elastic

volumes:

data02:

driver: local

data03:

driver: local

data04:

driver: local

networks:

elastic:

driver: bridge


3. 准备 kibana.yml

kibana.yml

#

# ** THIS IS AN AUTO-GENERATED FILE **

#

# Default Kibana configuration for docker target

server.host: "0.0.0.0"

server.shutdownTimeout: "5s"

elasticsearch.hosts: [ "http://es02:9202" ] #es02节点

monitoring.ui.container.elasticsearch.enabled: true


4. 执行构建命令


docker compose up -d

发布于: 刚刚阅读数: 2
用户头像

kenny

关注

还未添加个人签名 2020.08.26 加入

还未添加个人简介

评论

发布
暂无评论
Docker Compose 部署Kibana和 Elasticsearch本地集群 8.1.3_elasticsearch_kenny_InfoQ写作社区