Elasticsearch, Logstash, Kibana
Last active
March 11, 2021 03:26
-
-
Save szy0syz/48bf8dbd52c37523c2f28cd9c9cb7da5 to your computer and use it in GitHub Desktop.
ELK Stack: Elasticsearch, Logstash, Kibana
FROM elasticsearch:7.10.1
ENV VERSION=7.10.1
ADD https://artifacts.elastic.co/downloads/elasticsearch-plugins/ingest-attachment/ingest-attachment-$VERSION.zip /tmp/
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/ingest-attachment-$VERSION.zip
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 --batch file:///tmp/elasticsearch-analysis-ik-$VERSION.zip
RUN rm -rf /tmp/*
FROM docker.elastic.co/elasticsearch/elasticsearch:7.11.1
ENV VERSION=7.11.1
ADD https://artifacts.elastic.co/downloads/elasticsearch-plugins/ingest-attachment/ingest-attachment-$VERSION.zip /tmp/
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/ingest-attachment-$VERSION.zip
ADD https://codeload.github.com/medcl/elasticsearch-analysis-ik/zip/$VERSION /tmp/
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/elasticsearch-analysis-ik-$VERSION.zip
RUN rm -rf /tmp/*
version: '3'
services:
elasticsearch:
# elasticsearch + ik + ingest
image: elasticsearch-plus:$ELASTIC_VERSION
# image: docker.elastic.co/elasticsearch/elasticsearch:$ELASTIC_VERSION
environment:
- bootstrap.memory_lock=true
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms2g -Xmx2g"
- ELASTIC_PASSWORD=$ELASTIC_PASSWORD
- xpack.security.enabled=$ELASTIC_SECURITY
ulimits:
memlock:
soft: -1
hard: -1
ports:
- 9200:9200
networks: ['stack']
kibana:
image: kibana:$ELASTIC_VERSION
# image: docker.elastic.co/kibana/kibana:$ELASTIC_VERSION
environment:
- ELASTICSEARCH_USERNAME=elastic
- ELASTICSEARCH_PASSWORD=$ELASTIC_PASSWORD
ports: ['5601:5601']
networks: ['stack']
links: ['elasticsearch']
depends_on: ['elasticsearch']
networks:
stack: {}
# .env
ELASTIC_VERSION=7.10.1
ELASTIC_SECURITY=true
ELASTIC_PASSWORD=888
docker build -t elasticsearch-plus .
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch-plus
curl -GET "localhost:9200"
// 增加一个叫test001的索引
curl -X PUT http://localhost:9200/test001
// 成功返回 {"acknowledged":true,"shards_acknowledged":true,"index":"test001"}
// ik_smart分词
curl -X POST \
'http://127.0.0.1:9200/test001/_analyze?pretty=true' \
-H 'Content-Type: application/json' \
-d '{"text":"我们是软件工程师","tokenizer":"ik_smart"}'
// ik_max_word分词
curl -X POST \
'http://127.0.0.1:9200/test001/_analyze?pretty=true' \
-H 'Content-Type: application/json' \
-d '{"text":"我们是软件工程师","tokenizer":"ik_max_word"}'
docker export --output="es1.tar" 25e0
cat es1.tar | docker import - es1:latest
docker run -p 9201:9200 -p 9300:9301 -e "discovery.type=single-node" es /tini -- /usr/local/bin/docker-entrypoint.sh eswrapper
version: '2.2'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
container_name: es01
environment:
- node.name=es01
- discovery.seed_hosts=es02
- cluster.initial_master_nodes=es01,es02
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata01:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- esnet
es02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
container_name: es02
environment:
- node.name=es02
- discovery.seed_hosts=es01
- cluster.initial_master_nodes=es01,es02
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata02:/usr/share/elasticsearch/data
networks:
- esnet
volumes:
esdata01:
driver: local
esdata02:
driver: local
networks:
esnet:
docker --help | grep -E "(export|import|load|save)"
export Export a container\'s filesystem as a tar archive
import Import the contents from a tarball to create a filesystem image
load Load an image from a tar archive or STDIN
save Save one or more images to a tar archive (streamed to STDOUT by default)
- https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/7.x/examples.html
- https://isthisit.nz/posts/2020/elasticsearch-plugins-docker/
- https://yeasy.gitbook.io/docker_practice/container/import_export
- https://pspdfkit.com/blog/2019/docker-import-export-vs-load-save/
- https://www.jianshu.com/p/d8b0c736070f
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment