概述
elasticsearch是软件开发过程中常用的中间件,本文介绍如何在本地快速搭建es开发环境。
相关应用介绍
<ul>
<li>elasticsearch: 即es服务,本例中会启动两个节点,双主模式,以满足开发过程中,副本shard的需要</li>
<li>kibana:可以对es中的数据进行可视化分析,搜索等</li>
<li>cerebro:是es集群的可视化管理工具</li>
</ul>
docker-compose.yml
其中,es采用7.14.0版本
version: '2.2'
services:
cerebro:
image: lmenezes/cerebro:0.8.3
container_name: cerebro
ports:
- "9005:9000"
command:
- -Dhosts.0.host=http://my-elasticsearch:9200
networks:
- es7net
kibana:
image: kibana:7.14.0
container_name: kibana7
environment:
- I18N_LOCALE=zh-CN
- XPACK_GRAPH_ENABLED=true
- TIMELION_ENABLED=true
- XPACK_MONITORING_COLLECTION_ENABLED="true"
- ELASTICSEARCH_HOSTS=["http://my-elasticsearch:9200"]
ports:
- "5601:5601"
networks:
- es7net
my-elasticsearch:
image: elasticsearch:7.14.0
container_name: es7_01
environment:
- cluster.name=es-cluster
- node.name=es7_01
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.seed_hosts=es7_01,es7_02
- cluster.initial_master_nodes=es7_01,es7_02
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- ./es7data1:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- es7net
my-elasticsearch2:
image: elasticsearch:7.14.0
container_name: es7_02
environment:
- cluster.name=es-cluster
- node.name=es7_02
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.seed_hosts=es7_01,es7_02
- cluster.initial_master_nodes=es7_01,es7_02
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- ./es7data2:/usr/share/elasticsearch/data
networks:
- es7net
networks:
es7net:
driver: bridge
启动过程
<ol>
<li>初始化data目录</li>
在docker-compose目录下新建 es7data1 es7data2 文件下
<li>docker compose up指令启动</li>
</ol>
查看状态
<ol>
<li>cerebro查看</li>
访问http://localhost:9205, node address输入http://my-elasticsearch:9200,连接查看集群状态
<li>kibana查看</li>
访问http://localhost:5601
</ol>