docker安装elasticsearch和kibana
主要介绍如何使用docker 安装elasticsearch 和elasticsearch ,使用的都是7.5的版本。
1. 安装docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
2. 拉取es镜像
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.5.0
3. 单节点运行es
docker run -d --restart=always -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.5.0
4. 多节点运行es
- 创建一个docker-compose.yml 文件
version: '2.2'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.5.0
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es02,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data01:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- elastic
es02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.5.0
container_name: es02
environment:
- node.name=es02
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data02:/usr/share/elasticsearch/data
networks:
- elastic
es03:
image: docker.elastic.co/elasticsearch/elasticsearch:7.5.0
container_name: es03
environment:
- node.name=es03
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es02
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data03:/usr/share/elasticsearch/data
networks:
- elastic
volumes:
data01:
driver: local
data02:
driver: local
data03:
driver: local
networks:
elastic:
driver: bridge
- 节点 es01 监听 localhost:9200, es02 和 es03 类似
- 数据卷 data01,data02,data03。可以持久化
- 启动:docker-compose up
- 停止:docker-compose down
- 停止并删除数据卷:docker-compose down -v
- 查看节点是否启动
curl -X GET "localhost:9200/_cat/nodes?v&pretty"
4. 设置 vm.max_map_count
The vm.max_map_count kernel setting must be set to at least 262144 for production use.
grep vm.max_map_count /etc/sysctl.conf
vm.max_map_count=262144
To apply the setting on a live system, run:
sysctl -w vm.max_map_count=262144
5. 安装kibana
docker pull docker.elastic.co/kibana/kibana:7.5.0
6. 设置kibana
docker run --link YOUR_ELASTICSEARCH_CONTAINER_NAME_OR_ID:elasticsearch -p 5601:5601 {docker-repo}:{version}
docker run -d --restart=always --link a72adb9bf49a:elasticsearch -p 5601:5601 docker.elastic.co/kibana/kibana:7.5.0
7. 拉取logstash镜像
docker pull docker.elastic.co/logstash/logstash:7.5.0
7. 安装elasticsearch head插件监控管理
docker pull mobz/elasticsearch-head:5
docker run -d -p 9100:9100 docker.io/mobz/elasticsearch-head:5