#!/bin/sh # ===================================================================== # deploy/integration/es-init/init-flight-hts.sh(ACM2-76) # 一次性初始化 ES 历史索引 flight_hts:建 flight_hts2、挂别名、套 mapping。 # 幂等:索引已存在即整体跳过;可随 `compose up` 重复执行。 # 映射文件 v1.2.0_20190428_flightHstMapping.json 原样取自 admin-api 仓库 # src/main/resources/es/(CRLF、自带 PUT 命令行),此处只提取 JSON 体。 # ===================================================================== set -e ES="http://elasticsearch:9200" if curl -fsS -o /dev/null "$ES/_cat/indices/flight_hts2"; then echo "flight_hts2 已存在,跳过初始化" exit 0 fi curl -fsS -X PUT "$ES/flight_hts2"; echo curl -fsS -X PUT "$ES/flight_hts2/_alias/flight_hts"; echo tr -d '\r' < /init/v1.2.0_20190428_flightHstMapping.json | sed -n '/^{/,$p' > /tmp/flight_hts_mapping.json curl -fsS -X PUT -H 'Content-Type: application/json' --data-binary @/tmp/flight_hts_mapping.json "$ES/flight_hts2/_doc/_mapping"; echo # 单节点联调栈:副本置 0,避免未分配副本分片让集群一直 yellow。 curl -fsS -X PUT -H 'Content-Type: application/json' "$ES/flight_hts2/_settings" -d '{"index":{"number_of_replicas":0}}'; echo echo "flight_hts 初始化完成"