Files
dsh_shenxian/scripts/push-parallel-47to106.sh
T
admin 5ec99ce227
build / build-and-scan (push) Canceled after 0s
chore: 文档库全量重新入库(2026-10-20)
2026-10-20 15:05:55 +08:00

39 lines
1.6 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
. "$(cd "$(dirname "$0")/.." && pwd)/config/load.sh"
# 存量数据并行搬运 47 → 106(4 路并发;瓶颈在源端小文件 IOPS,单流只 ~0.4MB/s)
# 搬完写 /root/push-parallel.done,供后续 cutover 判断
set -uo pipefail
KEY=/root/.ssh/dshworker_ed25519
DST=root@"$DSH_PEER_PUBLIC_IP"
SSHO="-i $KEY -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o Compression=no"
SRC="$DSHS_DATA_ROOT"
LOG=/root/push-parallel.log
: > "$LOG"
ssh -n $SSHO "$DST" "mkdir -p $DSHS_DATA_ROOT"
echo "[$(date +%T)] 目标端就绪" >> "$LOG"
# 按"大小"分组:大用户单开一路,其余合流(每路一个 tar→ssh)
one() { # $1=组名 其余=相对路径列表
local name="$1"; shift
(
cd "$SRC" || exit 1
{ for p in "$@"; do [ -e "$p" ] && echo "$p"; done; } > "/tmp/list-$name.txt"
tar --numeric-owner --files-from="/tmp/list-$name.txt" -cf - \
| ssh $SSHO "$DST" "tar -C "$DSHS_DATA_ROOT" --numeric-owner -xf -"
echo "[$(date +%T)] $name 完成 rc=$?" >> "$LOG"
) &
}
# 组划分(按实际内容:1 个大用户 + 若干小目录)
one g1 "users/4092b965-2f68-4977-9989-68b3966f7df0"
one g2 "users/cce6d1cd-b376-4304-80f0-0e1c58c9ffde" "users/3ec95f69-6a4e-4d16-a415-56aa09396fc5"
one g3 "users/4eaeb26b-9e0c-4c68-9b61-0daf70664ae5" "users/74e8804a-e0c8-4645-84de-90dd3fae6c2b"
one g4 "users/7ba268be-6103-438c-8e6b-609b422ccbca" "users/ca3f36e0-937f-437e-b850-53b8230f20f8" \
"bundled-skills" "business-plugins" "whitelist-cache"
wait
echo "[$(date +%T)] 全部完成" >> "$LOG"
ssh -n $SSHO "$DST" "du -sm $DSHS_DATA_ROOT | cut -f1" >> "$LOG" 2>&1
touch /root/push-parallel.done