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

docker-compose安装elasticsearch集群

时间:2018-11-16 15:09:08      阅读:1688      评论:0      收藏:0      [点我收藏+]

标签:安装   doc   mini   版本   security   enable   net   clust   node   

文件目录:

技术分享图片

1、编写docker-compose文件

version: ‘3‘
services:
     es-master:
       image:  elasticsearch:6.4.3
       container_name: es-master
       restart: always
       volumes:
         - ./master/data:/usr/share/elasticsearch/data:rw
         - ./master/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
         - ./master/logs:/user/share/elasticsearch/logs:rw
       ports:
         - "9200:9200"
         - "9300:9300"

     es-node1:
       image:  elasticsearch:6.4.3
       container_name: es-node1
       restart: always
       volumes:
         - ./node1/data:/usr/share/elasticsearch/data:rw
         - ./node1/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
         - ./node1/logs:/user/share/elasticsearch/logs:rw
     es-node2:
       image:  elasticsearch:6.4.3
       container_name: es-node2
       restart: always
       volumes:
         - ./node2/data:/usr/share/elasticsearch/data:rw
         - ./node2/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
         - ./node2/logs:/user/share/elasticsearch/logs:rw
     es-head:
       image: tobias74/elasticsearch-head:6
       container_name: es-head
       restart: always
       ports:
       - "9100:9100"

es-master:master节点,确定分片位置,索引的新增、删除请求分配

es-node1:分片的 CRUD,以及搜索和整合操作

es-node2:分片的 CRUD,以及搜索和整合操作

es-head:es的一个插件,目前官方版本只支持5.0。可以浏览和查看数据,可以类比于navcate相对于mysql的作用。

2、编写yml配置文件

(1) master配置文件

bootstrap.memory_lock: false
cluster.name: "es-cluster"
node.name: es-master
node.master: true
node.data: false
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: *.*.*.*:9300, *.*.*.*:9301, *.*.*.*:9302
discovery.zen.minimum_master_nodes: 1

path.logs: /usr/share/elasticsearch/logs
http.cors.enabled: true
http.cors.allow-origin: "*"
xpack.security.audit.enabled: true            
http.cors.enabled: true
http.cors.allow-origin: "*"
上面的配置是为了使es-head能连接到es集群

(2) node配置文件

cluster.name: "es-cluster"
node.name: node2
node.master: false
node.data: true
network.host: 0.0.0.0
http.port: 9202
transport.tcp.port: 9302
discovery.zen.ping.unicast.hosts: *.*.*.*:9300,  *.*.*.*:9301,  *.*.*.*:9302

path.logs: /usr/share/elasticsearch/logs

 node1 的配置和node2的配置基本一致

3、执行命令

docker-compose up

4、ES-HEAD访问

技术分享图片

 

docker-compose安装elasticsearch集群

标签:安装   doc   mini   版本   security   enable   net   clust   node   

原文地址:https://www.cnblogs.com/mxmbk/p/9969008.html

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