45 lines
1.8 KiB
Bash
45 lines
1.8 KiB
Bash
#!/usr/bin/env bash
|
||||
|
|
# 起一台 **cluster 模式的 Manager**(T08 跨机演练用;在 Manager 那台机器上跑)。
|
|||
|
|
#
|
|||
|
|
# 现场的对照(2026-09-15 演练实测):
|
|||
|
|
# · Manager 在 **47**(本脚本所在机器),监听 `127.0.0.1:13080`(**不公网暴露**)
|
|||
|
|
# · Worker agent 在 **106**,经 SSH 反向隧道出现在本机 `127.0.0.1:19000` / `19001`
|
|||
|
|
# · 控制面 PG 也在 **106**,经同一条隧道出现在本机 `127.0.0.1:15432`
|
|||
|
|
# 用法:bash scripts/start-cluster-manager.sh (env 见下方 manager.env)
|
|||
|
|
在 47 上:建 manager.env、bootstrap 管理员、起 cluster Manager(127.0.0.1:13080)
|
|||
|
|
set -uo pipefail
|
|||
|
|
cd /opt/dshs-cluster || exit 1
|
|||
|
|
|
|||
|
|
cat > /opt/dshs-cluster/manager.env <<'ENVEOF'
|
|||
|
|
DSHS_DEPLOY_MODE=cluster
|
|||
|
|
DSHS_DB_URL=postgres://dshs:[email protected]:15432/dshs_cross
|
|||
|
|
DSHS_DATA_ROOT=/opt/dshs-cluster/data
|
|||
|
|
DSHS_CLUSTER_HOST_ID=m-47
|
|||
|
|
DSHS_CLUSTER_AGENT_URL=http://127.0.0.1:19000
|
|||
|
|
DSHS_CLUSTER_AGENT_TOKEN=cross-machine-token
|
|||
|
|
DSHS_CLUSTER_INSTANCE_HOST=127.0.0.1
|
|||
|
|
DSHS_CLUSTER_WORKER_DATA_ROOT=/opt/dshs-cluster/live-data
|
|||
|
|
DSHS_CLUSTER_CAPACITY_MB=-1
|
|||
|
|
DSHS_CLUSTER_REGISTER_SELF=0
|
|||
|
|
DSHS_CLUSTER_LEASE_TTL_MS=30000
|
|||
|
|
ENVEOF
|
|||
|
|
|
|||
|
|
set -a
|
|||
|
|
# shellcheck disable=SC1091
|
|||
|
|
. /opt/dshs-cluster/manager.env
|
|||
|
|
set +a
|
|||
|
|
|
|||
|
|
echo "--- bootstrap 管理员 ---"
|
|||
|
|
node lib/cli.js bootstrap-admin --username root --password crossmgr123 2>&1 | tail -1
|
|||
|
|
|
|||
|
|
echo "--- 起 Manager ---"
|
|||
|
|
pkill -f "dshs-cluster/lib/cli.js --port 13080" 2>/dev/null
|
|||
|
|
sleep 1
|
|||
|
|
nohup node lib/cli.js --port 13080 --host 127.0.0.1 --log-level warn > /tmp/manager-47.log 2>&1 &
|
|||
|
|
sleep 7
|
|||
|
|
|
|||
|
|
echo "--- 自检 ---"
|
|||
|
|
echo " login.html : $(curl -s -o /dev/null -w '%{http_code}' -m 6 http://127.0.0.1:13080/login.html)"
|
|||
|
|
echo " 进程 : $(pgrep -cf 'dshs-cluster/lib/cli.js --port 13080')"
|
|||
|
|
echo " 日志尾部 :"
|
|||
|
|
tail -4 /tmp/manager-47.log 2>/dev/null | sed 's/^/ /'
|