码迷,mamicode.com
首页 > 其他好文 > 详细

如何在docker中部署Elasticsearch集群和kibana

时间:2018-11-22 18:13:13      阅读:506      评论:0      收藏:0      [点我收藏+]

标签:www   ima   image   ref   discover   clust   批量   html   ack   

做实验时需要了解Elasticsearch集群如何操作?通过使用docker-compose可以批量创建docker容器,启动ES集群。

先配置文件docker-compose.yml文件如下:

 1 version: ‘2.2‘
 2 networks:
 3   esnet:
 4 services:
 5   es00:
 6     image: docker.elastic.co/elasticsearch/elasticsearch:6.5.1
 7     container_name: es00
 8     environment:
 9       - cluster.name=esdocker-cluster
10       - node.name=node-00
11       - bootstrap.memory_lock=true
12       - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
13       - http.cors.enabled=true
14       - http.cors.allow-origin=*
15     ulimits:
16       memlock:
17         soft: -1
18         hard: -1
19     volumes:
20       - .\es00:/usr/share/elasticsearch/data
21     ports:
22       - 9200:9200
23       - 9300:9300
24     networks:
25       - esnet
26   es01:
27     image: docker.elastic.co/elasticsearch/elasticsearch:6.5.1
28     container_name: es01
29     environment:
30       - cluster.name=esdocker-cluster
31       - node.name=node-01
32       - bootstrap.memory_lock=true
33       - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
34       - "discovery.zen.ping.unicast.hosts=es00"
35     ulimits:
36       memlock:
37         soft: -1
38         hard: -1
39     volumes:
40       - .\es01:/usr/share/elasticsearch/data
41     ports:
42       - 9201:9200
43       - 9301:9300
44     networks:
45       - esnet
46     depends_on:
47       - es00
48   es02:
49     image: docker.elastic.co/elasticsearch/elasticsearch:6.5.1
50     container_name: es02
51     environment:
52       - cluster.name=esdocker-cluster
53       - node.name=node-02
54       - bootstrap.memory_lock=true
55       - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
56       - "discovery.zen.ping.unicast.hosts=es00"
57     ulimits:
58       memlock:
59         soft: -1
60         hard: -1
61     volumes:
62       - .\es02:/usr/share/elasticsearch/data
63     ports:
64       - 9202:9200
65       - 9302:9300
66     networks:
67       - esnet
68     depends_on:
69       - es00
70 
71   kibana:
72     image: docker.elastic.co/kibana/kibana:6.5.1
73     container_name: kibana
74     environment:
75       - SERVER_NAME=kibana
76       - ELASTICSEARCH_URL=http://es00:9200
77       - XPACK_MONITORING_ENABLED=true
78     ports:
79       - 5601:5601
80     networks:
81       - esnet
82     depends_on:
83       - es00
84     external_links:
85       - es00

说明:

第一个networks貌似得放前面,不然后面网络找不到es00,貌似这是和官方文档唯一的区别,坑了好久。
也可以像下面这样写,但是必须在启动之前先创建docker网络,运行命令(docker network create esnet)即可。
1 networks:
2   esnet:
3     external: true

 

运行docker-compose up即可启动Elasticsearch集群和kibana。

docker-compose down 删除docker。

 

参考官方文档:

https://www.elastic.co/guide/en/kibana/6.5/docker.html#environment-variable-config

https://www.elastic.co/guide/en/kibana/6.5/docker.html#environment-variable-config

 

如何在docker中部署Elasticsearch集群和kibana

标签:www   ima   image   ref   discover   clust   批量   html   ack   

原文地址:https://www.cnblogs.com/tryc/p/10002423.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!