提交合并

Signed-off-by: 萌森 <qyg2297248353@163.com>
This commit is contained in:
2024-07-17 16:30:13 +08:00
committed by qyg2297248353
commit 6c18fe434d
449 changed files with 21391 additions and 0 deletions
+99
View File
@@ -0,0 +1,99 @@
additionalProperties:
formFields:
- default: "docker-cluster"
edit: true
envKey: CLUSTER_NAME
labelEn: cluster name
labelZh: 集群名称 与现有集群名称一致
required: true
type: text
- default: "elastic-net"
edit: true
envKey: CLUSTER_NETWORK
labelEn: cluster network
labelZh: 集群网络 与现有集群网络一致
required: true
type: text
- default: "es04"
edit: true
envKey: ES_NODE_NAME
labelEn: node name
labelZh: 节点名称 与现有节点名称不一致
required: true
type: text
- default: ""
edit: true
envKey: ELASTIC_PASSWORD
labelEn: Password for the 'elastic' user, Numbers and letters
labelZh: elastic 用户的密码 数字与字母组合
required: true
random: true
type: password
- default: "es01,es02,es03"
edit: true
envKey: ES_SEED_HOSTS
labelEn: Seed hosts
labelZh: 其他节点的名称 节点发现
required: true
type: text
- default: "es01,es02,es03,es04"
edit: true
envKey: ES_INITIAL_MASTER_NODES
labelEn: Initial master nodes
labelZh: 主节点选举 es04为当前节点
required: true
type: text
- default: "/home/elastic/cluster"
edit: true
envKey: ES_ROOT_PATH
labelEn: data persistence root path
labelZh: 集群根路径 与现有集群根路径一致
required: true
type: text
- default: 1073741824
edit: true
envKey: MEM_LIMIT
labelEn: Increase or decrease based on the available host memory (in bytes)
labelZh: 根据可用主机内存增加或减少(以字节为单位)
required: true
type: number
- default: "9200"
edit: true
envKey: PANEL_APP_PORT_HTTPS
labelEn: Port to expose Elasticsearch HTTP API to the host
labelZh: 开放API的端口
required: false
type: text
- default: "9300"
edit: true
envKey: ES_COMMUNICATION_PORT
labelEn: Port to expose Elasticsearch communication to the host
labelZh: Elasticsearch通讯端口 9300
required: false
type: text
- default: "512m"
edit: true
envKey: ES_JAVA_OPTS_XMS
labelEn: JVM memory allocation pool
labelZh: JVM内存分配池 初始化内存
required: true
type: text
- default: "512m"
edit: true
envKey: ES_JAVA_OPTS_XMX
labelEn: JVM memory allocation pool
labelZh: JVM内存分配池 运行内存
required: true
type: text
- default: "true"
edit: true
envKey: ES_XPACK_SECURITY_ENABLED
labelEn: Enable security verification (recommended)
labelZh: 证书安全验证(推荐开启)
required: true
type: select
values:
- label: "开启"
value: "true"
- label: "关闭"
value: "false"
@@ -0,0 +1,84 @@
version: "3.8"
networks:
${DOCKER_NET}:
external: true
services:
es-node:
container_name: ${CONTAINER_NAME}-${ES_NODE_NAME}
restart: always
image: docker.elastic.co/elasticsearch/elasticsearch:8.12.0
volumes:
- ${ES_ROOT_PATH}/certs:/usr/share/elasticsearch/config/certs
- ${ES_ROOT_PATH}/${ES_NODE_NAME}/data:/usr/share/elasticsearch/data
- ${ES_ROOT_PATH}/${ES_NODE_NAME}/logs:/usr/share/elasticsearch/logs
- ${ES_ROOT_PATH}/${ES_NODE_NAME}/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- ${ES_ROOT_PATH}/${ES_NODE_NAME}/plugins:/usr/share/elasticsearch/plugins
ports:
- "${PANEL_APP_PORT_HTTPS}:9200"
- "${ES_COMMUNICATION_PORT}:9300"
networks:
- ${CLUSTER_NETWORK}
command: >
bash -c '
echo "start es-node";
if [ ! -f config/certs/${ES_NODE_NAME}.zip ]; then
echo "Creating certs";
echo -ne \
"instances:\n"\
" - name: ${ES_NODE_NAME}\n"\
" dns:\n"\
" - ${ES_NODE_NAME}\n"\
" - localhost\n"\
" ip:\n"\
" - 127.0.0.1\n"\
> config/certs/${ES_NODE_NAME}.yml;
bin/elasticsearch-certutil cert --silent --pem -out config/certs/${ES_NODE_NAME}.zip --in config/certs/${ES_NODE_NAME}.yml --ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key;
unzip config/certs/${ES_NODE_NAME}.zip -d config/certs;
fi;
echo "Setting file permissions"
chown -R root:root config/certs;
exec /usr/local/bin/docker-entrypoint.sh elasticsearch
'
environment:
- node.name=${ES_NODE_NAME}
- cluster.name=${CLUSTER_NAME}
- cluster.initial_master_nodes=${ES_INITIAL_MASTER_NODES}
- discovery.seed_hosts=${ES_SEED_HOSTS}
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
- bootstrap.memory_lock=true
- xpack.security.enabled=${ES_XPACK_SECURITY_ENABLED}
- xpack.security.http.ssl.enabled=${ES_XPACK_SECURITY_ENABLED}
- xpack.security.http.ssl.key=certs/${ES_NODE_NAME}/${ES_NODE_NAME}.key
- xpack.security.http.ssl.certificate=certs/${ES_NODE_NAME}/${ES_NODE_NAME}.crt
- xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
- xpack.security.transport.ssl.enabled=${ES_XPACK_SECURITY_ENABLED}
- xpack.security.transport.ssl.key=certs/${ES_NODE_NAME}/${ES_NODE_NAME}.key
- xpack.security.transport.ssl.certificate=certs/${ES_NODE_NAME}/${ES_NODE_NAME}.crt
- xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.license.self_generated.type=basic
- ES_JAVA_OPTS=-Xms${ES_JAVA_OPTS_XMS} -Xmx${ES_JAVA_OPTS_XMX}
mem_limit: ${MEM_LIMIT}
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
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
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
# 检查 .env 文件是否存在
if [ -f .env ]; then
# 导入 .env 文件中的变量
source .env
# 替换 docker-compose.yml 中的网络变量
sed -i "s/\${DOCKER_NET}/$CLUSTER_NETWORK/" docker-compose.yml
# 创建并设置权限
mkdir -p "$ES_ROOT_PATH"
mkdir -p "$ES_ROOT_PATH/$ES_NODE_NAME/data"
mkdir -p "$ES_ROOT_PATH/$ES_NODE_NAME/logs"
mkdir -p "$ES_ROOT_PATH/$ES_NODE_NAME/config"
mkdir -p "$ES_ROOT_PATH/$ES_NODE_NAME/plugins"
# 生成 elasticsearch.yml 文件
elasticsearch_config="cluster.name: \"$CLUSTER_NAME\"\nnetwork.host: 0.0.0.0"
echo -e "$elasticsearch_config" > elasticsearch.yml
cp elasticsearch.yml "$ES_ROOT_PATH/$ES_NODE_NAME/config/elasticsearch.yml"
chmod -R 777 "$ES_ROOT_PATH"
echo "Directories and permissions set successfully."
else
echo "Error: .env file not found."
exit 1
fi