-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REFACTOR] Docker-compose Elasticsearch 7.7 แบบ Clustering และ XPACK
- Loading branch information
1 parent
54c212f
commit f473d77
Showing
4 changed files
with
149 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
version: '3.3' | ||
services: | ||
elasticsearch: | ||
# Project MeetU ใช้ Version นี้ซึ่งเป้นตัวเก่า | ||
image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0 | ||
container_name: elasticsearch1 | ||
restart: always | ||
environment: | ||
- node.name=elasticsearch1 | ||
- discovery.type=single-node | ||
- bootstrap.memory_lock=true | ||
- "ES_JAVA_OPTS=-Xms256M -Xmx256M" | ||
- http.cors.enabled=true | ||
- http.cors.allow-origin=* | ||
- network.host=_eth0_ | ||
volumes: | ||
- .:/usr/share/elasticsearch/data | ||
networks: | ||
- elastic | ||
# - ingress | ||
ports: | ||
- 9200:9200 | ||
- 9300:9300 | ||
|
||
kibana: | ||
image: docker.elastic.co/kibana/kibana:7.2.0 | ||
container_name: kibana | ||
restart: always | ||
environment: | ||
SERVER_NAME: localhost | ||
ELASTICSEARCH_URL: http://elasticsearch1:9200/ | ||
ports: | ||
- 5601:5601 | ||
volumes: | ||
- .:/your/local/path | ||
networks: | ||
- elastic | ||
# - ingress | ||
|
||
networks: | ||
elastic: | ||
#ingress: | ||
|
||
volumes: # volume แบบใช้ในตัว dcoker machine ให้จัดการเอง | ||
esdata: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,120 @@ | ||
version: '3.3' | ||
services: | ||
elasticsearch: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0 | ||
elasticsearch1: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:7.7.0 | ||
container_name: elasticsearch1 | ||
restart: always | ||
environment: | ||
- node.name=elasticsearch1 | ||
- discovery.type=single-node | ||
# จะทำให้มันไม่ยอมเข้าไปอยู่ใน cluster และเอาตัวเองเป้น master เสมอเลย | ||
# - discovery.type=single-node | ||
- cluster.name=es-docker-cluster | ||
# เวลา scan Elasticsearch จะเช็ค Auto internal Transport Layer บน Port 9300-9305 ทันทีและรวบเข้า Cluster | ||
# ระหว่างทางสามารถเพิ่มลดได้ตามใจชอบระบบจะ Detect เองอัตโนมัติ | ||
- discovery.seed_hosts=elasticsearch1,elasticsearch2,elasticsearch3 | ||
- cluster.initial_master_nodes=elasticsearch1,elasticsearch2,elasticsearch3 | ||
- bootstrap.memory_lock=true | ||
- "ES_JAVA_OPTS=-Xms256M -Xmx256M" | ||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" | ||
- http.cors.enabled=true | ||
- http.cors.allow-origin=* | ||
# ผูกเข้ากับ interface คอมเราผ่าน ifconfig | ||
- network.host=_eth0_ | ||
# หลังติดตั้งเสร็จแล้วต้องรันคำสั่ง bin/elasticsearch-setup-passwords interactive | ||
# เพื่อให้ xpack module ที่ลงไว้ทำการตั้ง password ตามที่เราตั้งด้วยนั่นเอง | ||
# ถ้าใช้ xpack บน cluster mode จะโดน bootstrap สั่งให้ทำ TLS ด้วยทันทีไม่งั้นจะ bootstrap ไม่ผ่าน | ||
# - xpack.security.enabled=true | ||
# จำเป็นต้องปิดการ swap memory เมื่อทำ cluster node เพราะว่า | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
volumes: | ||
- esdata:/usr/share/elasticsearch/data | ||
- data01:/usr/share/elasticsearch/data | ||
networks: | ||
- elastic | ||
- ingress | ||
ports: | ||
- 9200:9200 | ||
- 9300:9300 | ||
|
||
elasticsearch2: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:7.7.0 | ||
container_name: elasticsearch2 | ||
restart: always | ||
environment: | ||
- node.name=elasticsearch2 | ||
- cluster.name=es-docker-cluster | ||
- discovery.seed_hosts=elasticsearch1,elasticsearch2,elasticsearch3 | ||
- cluster.initial_master_nodes=elasticsearch1,elasticsearch2,elasticsearch3 | ||
- bootstrap.memory_lock=true | ||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" | ||
- http.cors.enabled=true | ||
- http.cors.allow-origin=* | ||
- network.host=_eth0_ | ||
# หลังติดตั้งเสร็จแล้วต้องรันคำสั่ง bin/elasticsearch-setup-passwords interactive | ||
# เพื่อให้ xpack module ที่ลงไว้ทำการตั้ง password ตามที่เราตั้งด้วยนั่นเอง | ||
# ถ้าใช้ xpack บน cluster mode จะโดน bootstrap สั่งให้ทำ TLS ด้วยทันทีไม่งั้นจะ bootstrap ไม่ผ่าน | ||
# - xpack.security.enabled=true | ||
# จำเป็นต้องปิดการ swap memory เมื่อทำ cluster node เพราะว่า | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
volumes: | ||
- data02:/usr/share/elasticsearch/data | ||
networks: | ||
- elastic | ||
|
||
|
||
elasticsearch3: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:7.7.0 | ||
container_name: elasticsearch3 | ||
restart: always | ||
environment: | ||
- node.name=elasticsearch3 | ||
- cluster.name=es-docker-cluster | ||
- discovery.seed_hosts=elasticsearch1,elasticsearch2,elasticsearch3 | ||
- cluster.initial_master_nodes=elasticsearch1,elasticsearch2,elasticsearch3 | ||
- bootstrap.memory_lock=true | ||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" | ||
- http.cors.enabled=true | ||
- http.cors.allow-origin=* | ||
- network.host=_eth0_ | ||
# หลังติดตั้งเสร็จแล้วต้องรันคำสั่ง bin/elasticsearch-setup-passwords interactive | ||
# เพื่อให้ xpack module ที่ลงไว้ทำการตั้ง password ตามที่เราตั้งด้วยนั่นเอง | ||
# ถ้าใช้ xpack บน cluster mode จะโดน bootstrap สั่งให้ทำ TLS ด้วยทันทีไม่งั้นจะ bootstrap ไม่ผ่าน | ||
# - xpack.security.enabled=true | ||
# จำเป็นต้องปิดการ swap memory เมื่อทำ cluster node เพราะว่า | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
volumes: | ||
- data03:/usr/share/elasticsearch/data | ||
networks: | ||
- elastic | ||
|
||
kibana: | ||
image: docker.elastic.co/kibana/kibana:7.2.0 | ||
image: docker.elastic.co/kibana/kibana:7.7.0 | ||
container_name: kibana | ||
restart: always | ||
environment: | ||
SERVER_NAME: localhost | ||
ELASTICSEARCH_URL: http://elasticsearch1:9200/ | ||
# environment: | ||
# env ที่อยู่ตรงนี้คือตัวเดียวกับใน kibana.yml แต่จะเขียนด้วย format KEY_PROPERTY: value | ||
# ซึ่งถ้าเป้นใน kibana.yml จะเขียนด้วย key.property: value แทนนั่นเอง มีค่าเท่ากัน | ||
# SERVER_NAME: localhost | ||
# ELASTICSEARCH_URL: http://elasticsearch:9200 | ||
ports: | ||
- 5601:5601 | ||
volumes: | ||
- .:/your/local/path | ||
- ./kibana.yml:/usr/share/kibana/config/kibana.yml | ||
networks: | ||
- elastic | ||
- ingress | ||
|
||
networks: | ||
elastic: | ||
ingress: | ||
|
||
volumes: # volume แบบใช้ในตัว dcoker machine ให้จัดการเอง | ||
esdata: | ||
data01: | ||
driver: local | ||
data02: | ||
driver: local | ||
data03: | ||
driver: local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# โดยปกติ Kibana จะ Compliance ตาม Elasticsearch อยู่แล้วแต่เขียนเอาไว้อุ่นใจกว่าให้แน่ใจ | ||
# xpack.security.audit.enabled: true | ||
# ถ้าไม่ระบุ host จะเข้าไม่ได้ถึงแม้ default จะระบุเป็น localhost ก็ตาม | ||
server.host: 0.0.0.0 | ||
# hostname ที่อยู่ของ elasticsearch | ||
elasticsearch.hosts: [ "http://elasticsearch1:9200","http://elasticsearch2:9200" ,"http://elasticsearch3:9200" ] | ||
# user ต้องเป้น user ชื่อ kibana เท่านั้นเพราะเงื่อนไขการติดต่อคือ | ||
# user ต้องตรงกับ app เช่น apm ต้องใช้ apm ไม่งั้นจะเข้าไมไ่ด้ !!! | ||
# ส่วน user elastic มีไว้ใช้ login กับ elastic ไม่เกีย่วกับ user ของ kibana !!! | ||
elasticsearch.username: "kibana" | ||
elasticsearch.password: "hellomyproduction" |