This commit is contained in:
2025-11-01 16:18:57 +08:00
parent a5572a157e
commit 1117815a9a
3 changed files with 78 additions and 23 deletions

65
check-es-connection.sh Executable file
View File

@@ -0,0 +1,65 @@
#!/bin/bash
echo "=== Elasticsearch 容器连接检查 ==="
echo
# 检查 es 容器是否存在
if ! docker ps -a --format "table {{.Names}}" | grep -q "^es$"; then
echo "❌ 未找到名为 'es' 的容器"
echo "请确保 Elasticsearch 容器已创建且名称为 'es'"
exit 1
fi
echo "✓ 找到 'es' 容器"
# 检查 proxy 网络是否存在
if ! docker network ls --format "table {{.Name}}" | grep -q "^proxy$"; then
echo "❌ 未找到 'proxy' 网络"
echo "正在创建 proxy 网络..."
docker network create proxy
echo "✓ proxy 网络创建成功"
else
echo "✓ 找到 'proxy' 网络"
fi
# 检查 es 容器是否已连接到 proxy 网络
if ! docker network inspect proxy --format '{{range .Containers}}{{.Name}} {{end}}' | grep -q "es"; then
echo "⚠️ 'es' 容器未连接到 'proxy' 网络"
echo "正在连接 'es' 容器到 'proxy' 网络..."
docker network connect proxy es
echo "✓ 'es' 容器已连接到 'proxy' 网络"
else
echo "✓ 'es' 容器已连接到 'proxy' 网络"
fi
# 检查 es 容器状态
ES_STATUS=$(docker inspect es --format '{{.State.Status}}')
if [ "$ES_STATUS" = "running" ]; then
echo "✓ 'es' 容器正在运行"
else
echo "⚠️ 'es' 容器状态: $ES_STATUS"
echo "正在启动 'es' 容器..."
docker start es
echo "✓ 'es' 容器已启动"
fi
# 测试 Elasticsearch 连接
echo
echo "🧪 测试 Elasticsearch 连接..."
if docker exec es curl -s http://localhost:9200/_cluster/health > /dev/null; then
echo "✓ Elasticsearch 连接正常"
docker exec es curl -s http://localhost:9200/_cluster/health | grep -o '"status":"[^"]*"' | cut -d'"' -f4
else
echo "❌ Elasticsearch 连接失败"
echo "请检查 Elasticsearch 配置"
fi
echo
echo "=== 检查完成 ==="
echo
echo "📋 网络中的容器:"
docker network inspect proxy --format '{{range .Containers}}{{.Name}} ({{.Name}}){{end}}'
echo
echo "🚀 现在可以部署数字档案系统:"
echo " ./archive-manager.sh deploy"

View File

@@ -30,6 +30,10 @@ services:
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=Abc123456
# Elasticsearch配置 - 使用已有的 "es" 容器
- ELASTICSEARCH_HOST=es
- ELASTICSEARCH_PORT=9200
- ELASTICSEARCH_SCHEME=http
# OCR配置
- TESS_PATH=/usr/bin/tesseract
# 其他配置
@@ -40,7 +44,7 @@ services:
- database
- redis
networks:
- archive-network
- proxy
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9081/point-strategy/actuator/health"]
@@ -63,7 +67,7 @@ services:
- ./data/database:/var/lib/kingbase/data
- ./init-scripts:/docker-entrypoint-initdb.d
networks:
- archive-network
- proxy
restart: unless-stopped
# Redis缓存
@@ -76,25 +80,11 @@ services:
volumes:
- ./data/redis:/data
networks:
- archive-network
- proxy
restart: unless-stopped
# Elasticsearch(可选,用于全文检索)
elasticsearch:
image: elasticsearch:7.17.0
container_name: digital-archive-elasticsearch
ports:
- "9200:9200"
- "9300:9300"
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.security.enabled=false
volumes:
- ./data/elasticsearch:/usr/share/elasticsearch/data
networks:
- archive-network
restart: unless-stopped
# Elasticsearch - 使用已有的 "es" 容器
# 注意:确保已有的 "es" 容器已连接到 proxy 网络
# Nginx反向代理可选
nginx:
@@ -109,12 +99,12 @@ services:
depends_on:
- app
networks:
- archive-network
- proxy
restart: unless-stopped
networks:
archive-network:
driver: bridge
proxy:
external: true
volumes:
upload-data:

View File

@@ -39,7 +39,7 @@ spring:
# Elasticsearch配置
elasticsearch:
rest:
uris: ${ELASTICSEARCH_URIS:http://127.0.0.1:9200}
uris: ${ELASTICSEARCH_SCHEME:http}://${ELASTICSEARCH_HOST:127.0.0.1}:${ELASTICSEARCH_PORT:9200}
# MyBatis配置
mybatis: