test
This commit is contained in:
65
check-es-connection.sh
Executable file
65
check-es-connection.sh
Executable 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"
|
||||||
@@ -30,6 +30,10 @@ services:
|
|||||||
- REDIS_HOST=redis
|
- REDIS_HOST=redis
|
||||||
- REDIS_PORT=6379
|
- REDIS_PORT=6379
|
||||||
- REDIS_PASSWORD=Abc123456
|
- REDIS_PASSWORD=Abc123456
|
||||||
|
# Elasticsearch配置 - 使用已有的 "es" 容器
|
||||||
|
- ELASTICSEARCH_HOST=es
|
||||||
|
- ELASTICSEARCH_PORT=9200
|
||||||
|
- ELASTICSEARCH_SCHEME=http
|
||||||
# OCR配置
|
# OCR配置
|
||||||
- TESS_PATH=/usr/bin/tesseract
|
- TESS_PATH=/usr/bin/tesseract
|
||||||
# 其他配置
|
# 其他配置
|
||||||
@@ -40,7 +44,7 @@ services:
|
|||||||
- database
|
- database
|
||||||
- redis
|
- redis
|
||||||
networks:
|
networks:
|
||||||
- archive-network
|
- proxy
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:9081/point-strategy/actuator/health"]
|
test: ["CMD", "curl", "-f", "http://localhost:9081/point-strategy/actuator/health"]
|
||||||
@@ -63,7 +67,7 @@ services:
|
|||||||
- ./data/database:/var/lib/kingbase/data
|
- ./data/database:/var/lib/kingbase/data
|
||||||
- ./init-scripts:/docker-entrypoint-initdb.d
|
- ./init-scripts:/docker-entrypoint-initdb.d
|
||||||
networks:
|
networks:
|
||||||
- archive-network
|
- proxy
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
# Redis缓存
|
# Redis缓存
|
||||||
@@ -76,25 +80,11 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./data/redis:/data
|
- ./data/redis:/data
|
||||||
networks:
|
networks:
|
||||||
- archive-network
|
- proxy
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
# Elasticsearch(可选,用于全文检索)
|
# Elasticsearch - 使用已有的 "es" 容器
|
||||||
elasticsearch:
|
# 注意:确保已有的 "es" 容器已连接到 proxy 网络
|
||||||
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
|
|
||||||
|
|
||||||
# Nginx反向代理(可选)
|
# Nginx反向代理(可选)
|
||||||
nginx:
|
nginx:
|
||||||
@@ -109,12 +99,12 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- app
|
- app
|
||||||
networks:
|
networks:
|
||||||
- archive-network
|
- proxy
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
archive-network:
|
proxy:
|
||||||
driver: bridge
|
external: true
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
upload-data:
|
upload-data:
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ spring:
|
|||||||
# Elasticsearch配置
|
# Elasticsearch配置
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
rest:
|
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配置
|
||||||
mybatis:
|
mybatis:
|
||||||
|
|||||||
Reference in New Issue
Block a user