elasticsearch系列(一): elasticsearch安装(docker方式)
单节点安装
创建es.yml
,内容如下:
version: '3'
services:
elasticsearch:
image: elasticsearch:6.6.2
container_name: elasticsearch
environment:
- cluster.name=elasticsearch-cluster
- node.name=node0
- node.master=true
- node.data=true
- http.cors.enabled=true
- http.cors.allow-origin=*
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ports:
- 9200:9200
- 9300:9300
启动容器:
docker-compose -f es.yml up -d
- -f 指定文件
- -d 后台运行
查看日志:
docker logs -f elasticsearch
创建带ik插件镜像
创建es-ik.yml
,内容如下:
FROM elasticsearch:6.6.2
ENV VERSION=6.6.2
# https://github.com/medcl/elasticsearch-analysis-ik/releases
ADD https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v${VERSION}/elasticsearch-analysis-ik-$VERSION.zip /tmp/
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install -b file:///tmp/elasticsearch-analysis-ik-$VERSION.zip
RUN rm -rf /tmp/*
创建镜像:
docker build -t es-ik:6.6.2 -f es-ik.yml .
- -t 指定名字和标签
- -f 指定文件
- . 指定上下文环境,不要漏掉
查看镜像:
docker image ls
集群安装
创建esclu.yml
,集成kibana管理.内容如下:
version: '3'
services:
elasticsearch_n0:
image: elasticsearch:6.6.2 # 或者使用es-ik:6.6.2镜像↑
container_name: elasticsearch_n0
privileged: true
environment:
- cluster.name=elasticsearch-cluster
- node.name=node0
- node.master=true
- node.data=true
- http.cors.enabled=true
- http.cors.allow-origin=*
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch_n0,elasticsearch_n1,elasticsearch_n2"
- "discovery.zen.minimum_master_nodes=2"
ports:
- 9200:9200
- 9300:9300
elasticsearch_n1:
image: elasticsearch:6.6.2
container_name: elasticsearch_n1
privileged: true
environment:
- cluster.name=elasticsearch-cluster
- node.name=node1
- node.master=true
- node.data=true
- http.cors.enabled=true
- http.cors.allow-origin=*
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch_n0,elasticsearch_n1,elasticsearch_n2"
- "discovery.zen.minimum_master_nodes=2"
ports:
- 9201:9200
- 9301:9300
elasticsearch_n2:
image: elasticsearch:6.6.2
container_name: elasticsearch_n2
privileged: true
environment:
- cluster.name=elasticsearch-cluster
- node.name=node2
- node.master=true
- node.data=true
- http.cors.enabled=true
- http.cors.allow-origin=*
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch_n0,elasticsearch_n1,elasticsearch_n2"
- "discovery.zen.minimum_master_nodes=2"
ports:
- 9202:9200
- 9302:9300
kibana:
image: kibana:6.6.2
container_name: kibana
environment:
- SERVER_NAME=kibana
- ELASTICSEARCH_URL=http://elasticsearch_n0:9200
- XPACK_MONITORING_ENABLED=true
ports:
- 5601:5601
depends_on:
- elasticsearch_n0
启动容器:
docker-compose -f esclu.yml up -d
查看启动
使用elasticsearch-head
和kibana
都可以
elasticsearch-head
elasticsearch-head最简单操作,安装chrom插件,免去其他多余操作.输入 http://192.168.183.220:9200/ 连接即可
kibana
访问 http://192.168.183.220:5601/ 找到DEV TOOLS
参考: