-
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.
- mysql - adminer - redis - redis-commander - elasticsearch - kibana
- Loading branch information
Showing
8 changed files
with
536 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# | ||
# https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html | ||
# | ||
# Password for the 'elastic' user (at least 6 characters) | ||
ELASTIC_PASSWORD=m12345 | ||
|
||
# Password for the 'kibana_system' user (at least 6 characters) | ||
KIBANA_PASSWORD=m12345 | ||
|
||
# Version of Elastic products | ||
STACK_VERSION=8.6.1 | ||
|
||
# Set the cluster name | ||
CLUSTER_NAME=docker-cluster | ||
|
||
# Set to 'basic' or 'trial' to automatically start the 30-day trial | ||
LICENSE=basic | ||
#LICENSE=trial | ||
|
||
# Port to expose Elasticsearch HTTP API to the host | ||
ES_PORT=9200 | ||
#ES_PORT=127.0.0.1:9200 | ||
|
||
# Port to expose Kibana to the host | ||
#KIBANA_PORT=5601 | ||
KIBANA_PORT=3309 | ||
#KIBANA_PORT=80 | ||
|
||
# Increase or decrease based on the available host memory (in bytes) | ||
MEM_LIMIT=1073741824 | ||
|
||
# Project namespace (defaults to the current folder name if not set) | ||
#COMPOSE_PROJECT_NAME=myproject |
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,107 @@ | ||
# | ||
# docker-compose -f docker-compose-dev.yml up --remove-orphans --force-recreate && docker-compose restart elasticsearch # 一键启动 + 删除暂时未用到的容器(再次用到需要重新下载镜像) | ||
# docker-compose -f docker-compose-dev.yml up --force-recreate && docker-compose restart elasticsearch # 一键启动 + 不删除暂时未用到的容器(避免重新下载镜像) | ||
# docker-compose -f docker-compose-dev.yml up && docker-compose restart elasticsearch # 非首次启动(插件等在之前已经安装好) | ||
# docker-compose -f docker-compose-dev.yml up -d && docker-compose restart elasticsearch # 非首次启动(插件等在之前已经安装好) + 后台运行 | ||
# | ||
# docker-compose -f docker-compose-dev.yml down # 关闭所有容器 | ||
# | ||
# docker-compose restart elasticsearch # 重启指定容器(安装 elasticsearch 插件后需要重启容器) | ||
# | ||
# docker exec -it elasticsearch bash # 进入 elasticsearch 容器内部 | ||
# | ||
# docker-compose ps # 列出所有容器 | ||
# | ||
# | ||
# mysql-adminer visit http://localhost:3307/ | ||
# redis-commander visit http://localhost:3308/ | ||
# elasticsearch-kibana visit http://localhost:3309/ | ||
# | ||
services: | ||
mysql: | ||
platform: linux/x86_64 | ||
image: mysql:5.7 | ||
container_name: mysql | ||
hostname: mysql | ||
restart: always | ||
privileged: true | ||
ports: | ||
- 3306:3306 | ||
expose: | ||
- 3306 | ||
command: | ||
--default-authentication-plugin=mysql_native_password | ||
--init-file /data/application/init.sql | ||
--character-set-server=utf8mb4 | ||
--collation-server=utf8mb4_general_ci | ||
--explicit_defaults_for_timestamp=true | ||
--lower_case_table_names=1 | ||
environment: | ||
- TZ=Asia/Shanghai | ||
- MYSQL_ROOT_PASSWORD=88888888 | ||
- MYSQL_TCP_PORT=3306 | ||
volumes: | ||
# - /etc/localtime:/etc/localtime:ro # not for mac | ||
- mysql_data:/var/lib/mysql:rw | ||
- ./mysql/mysql-init.sql:/data/application/init.sql | ||
networks: | ||
- default_network | ||
|
||
adminer: | ||
image: adminer | ||
hostname: mysql-adminer | ||
container_name: mysql-adminer | ||
privileged: true | ||
restart: always | ||
ports: | ||
- 3307:8080 | ||
environment: | ||
ADMINER_DEFAULT_SERVER: mysql | ||
networks: | ||
- default_network | ||
|
||
redis: | ||
image: redis:latest | ||
hostname: redis | ||
container_name: redis | ||
privileged: true | ||
restart: always | ||
command: redis-server /etc/redis.conf --requirepass 88888888 | ||
environment: | ||
- TZ=Asia/Shanghai | ||
volumes: | ||
# - /etc/localtime:/etc/localtime:ro # not for mac | ||
- redis_data:/data:rw | ||
- ./redis/redis.conf:/etc/redis.conf | ||
ports: | ||
- "6379:6379" | ||
networks: | ||
- default_network | ||
|
||
redis-commander: | ||
container_name: redis-commander | ||
hostname: redis-commander | ||
image: rediscommander/redis-commander:latest | ||
platform: linux/x86_64 | ||
restart: always | ||
privileged: true | ||
environment: | ||
- REDIS_HOSTS=redis | ||
- REDIS_HOST=redis | ||
- REDIS_PORT=redis:6379 | ||
- REDIS_PASSWORD=88888888 | ||
- HTTP_USER=root | ||
- HTTP_PASSWORD=88888888 | ||
ports: | ||
- "3308:8081" | ||
networks: | ||
- default_network | ||
|
||
# docker volume inspect [卷标名称] | ||
# docker volume ls | ||
volumes: | ||
mysql_data: | ||
redis_data: | ||
|
||
networks: | ||
default_network: |
145 changes: 145 additions & 0 deletions
145
service/springcloud/env/docker-compose-elasticsearch.yml
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,145 @@ | ||
# version: "2.2" | ||
# | ||
# max virtual memory areas vm.max_map_count [65530] is too low | ||
# https://www.elastic.co/guide/en/elasticsearch/reference/8.4/docker.html#_set_vm_max_map_count_to_at_least_262144 | ||
# rdctl shell sudo sysctl -w vm.max_map_count=262144 | ||
# | ||
# http://localhost:5601 | ||
# | ||
# docker-compose down # stop the cluster | ||
# docker-compose down -v # To delete the network, containers, and volumes when stop the cluster | ||
# | ||
# | ||
# docker-compose -f docker-compose-elasticsearch.yml up --remove-orphans --force-recreate && docker-compose restart es01 # 一键启动 + 删除暂时未用到的容器(再次用到需要重新下载镜像) | ||
# docker-compose -f docker-compose-elasticsearch.yml up --force-recreate && docker-compose restart es01 # 一键启动 + 不删除暂时未用到的容器(避免重新下载镜像) | ||
# docker-compose -f docker-compose-elasticsearch.yml up && docker-compose restart es01 # 非首次启动(插件等在之前已经安装好) | ||
# docker-compose -f docker-compose-elasticsearch.yml up -d && docker-compose restart es01 # 非首次启动(插件等在之前已经安装好) + 后台运行 | ||
# | ||
services: | ||
setup: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION} | ||
volumes: | ||
- certs:/usr/share/elasticsearch/config/certs | ||
user: "0" | ||
command: > | ||
bash -c ' | ||
if [ x${ELASTIC_PASSWORD} == x ]; then | ||
echo "Set the ELASTIC_PASSWORD environment variable in the .env file"; | ||
exit 1; | ||
elif [ x${KIBANA_PASSWORD} == x ]; then | ||
echo "Set the KIBANA_PASSWORD environment variable in the .env file"; | ||
exit 1; | ||
fi; | ||
if [ ! -f config/certs/ca.zip ]; then | ||
echo "Creating CA"; | ||
bin/elasticsearch-certutil ca --silent --pem -out config/certs/ca.zip; | ||
unzip config/certs/ca.zip -d config/certs; | ||
fi; | ||
if [ ! -f config/certs/certs.zip ]; then | ||
echo "Creating certs"; | ||
echo -ne \ | ||
"instances:\n"\ | ||
" - name: es01\n"\ | ||
" dns:\n"\ | ||
" - es01\n"\ | ||
" - localhost\n"\ | ||
" ip:\n"\ | ||
" - 127.0.0.1\n"\ | ||
> config/certs/instances.yml; | ||
bin/elasticsearch-certutil cert --silent --pem -out config/certs/certs.zip --in config/certs/instances.yml --ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key; | ||
unzip config/certs/certs.zip -d config/certs; | ||
fi; | ||
echo "Setting file permissions" | ||
chown -R root:root config/certs; | ||
find . -type d -exec chmod 750 \{\} \;; | ||
find . -type f -exec chmod 640 \{\} \;; | ||
echo "Waiting for Elasticsearch availability"; | ||
until curl -s --cacert config/certs/ca/ca.crt https://es01:9200 | grep -q "missing authentication credentials"; do sleep 30; done; | ||
echo "Setting kibana_system password"; | ||
until curl -s -X POST --cacert config/certs/ca/ca.crt -u "elastic:${ELASTIC_PASSWORD}" -H "Content-Type: application/json" https://es01:9200/_security/user/kibana_system/_password -d "{\"password\":\"${KIBANA_PASSWORD}\"}" | grep -q "^{}"; do sleep 10; done; | ||
echo "All done!"; | ||
' | ||
healthcheck: | ||
test: ["CMD-SHELL", "[ -f config/certs/es01/es01.crt ]"] | ||
interval: 1s | ||
timeout: 5s | ||
retries: 120 | ||
|
||
es01: | ||
depends_on: | ||
setup: | ||
condition: service_healthy | ||
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION} | ||
volumes: | ||
- certs:/usr/share/elasticsearch/config/certs | ||
- esdata01:/usr/share/elasticsearch/data | ||
- ./elasticsearch/shell:/usr/share/elasticsearch/shell | ||
entrypoint: [ "sh", "/usr/share/elasticsearch/shell/docker-entrypoint-es-plugins.sh" ] | ||
ports: | ||
- ${ES_PORT}:9200 | ||
environment: | ||
- node.name=es01 | ||
- cluster.name=${CLUSTER_NAME} | ||
- cluster.initial_master_nodes=es01 | ||
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD} | ||
- bootstrap.memory_lock=true | ||
- xpack.security.enabled=true | ||
- xpack.security.http.ssl.enabled=true | ||
- xpack.security.http.ssl.key=certs/es01/es01.key | ||
- xpack.security.http.ssl.certificate=certs/es01/es01.crt | ||
- xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt | ||
- xpack.security.transport.ssl.enabled=true | ||
- xpack.security.transport.ssl.key=certs/es01/es01.key | ||
- xpack.security.transport.ssl.certificate=certs/es01/es01.crt | ||
- xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt | ||
- xpack.security.transport.ssl.verification_mode=certificate | ||
- xpack.license.self_generated.type=${LICENSE} | ||
mem_limit: ${MEM_LIMIT} | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
healthcheck: | ||
test: | ||
[ | ||
"CMD-SHELL", | ||
"curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 | grep -q 'missing authentication credentials'", | ||
] | ||
interval: 10s | ||
timeout: 10s | ||
retries: 120 | ||
|
||
kibana: | ||
depends_on: | ||
es01: | ||
condition: service_healthy | ||
image: docker.elastic.co/kibana/kibana:${STACK_VERSION} | ||
volumes: | ||
- certs:/usr/share/kibana/config/certs | ||
- kibanadata:/usr/share/kibana/data | ||
ports: | ||
- ${KIBANA_PORT}:5601 | ||
environment: | ||
- SERVERNAME=kibana | ||
- ELASTICSEARCH_HOSTS=https://es01:9200 | ||
- ELASTICSEARCH_USERNAME=kibana_system | ||
- ELASTICSEARCH_PASSWORD=${KIBANA_PASSWORD} | ||
- ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES=config/certs/ca/ca.crt | ||
mem_limit: ${MEM_LIMIT} | ||
healthcheck: | ||
test: | ||
[ | ||
"CMD-SHELL", | ||
"curl -s -I http://localhost:5601 | grep -q 'HTTP/1.1 302 Found'", | ||
] | ||
interval: 10s | ||
timeout: 10s | ||
retries: 120 | ||
|
||
volumes: | ||
certs: | ||
driver: local | ||
esdata01: | ||
driver: local | ||
kibanadata: | ||
driver: local |
Oops, something went wrong.