fix: reduce dnf memory footprint for Redis install - clean cache, drop caches, disable weak deps

main
Anthony 2026-02-28 18:50:06 +08:00
parent 3f2ed3c8f3
commit 1e816edf95
1 changed files with 8 additions and 2 deletions

View File

@ -131,8 +131,14 @@ step_install() {
lock_retries=$((lock_retries - 1))
done
if ! dnf install -y redis 2>&1; then
error_exit "dnf install redis failed. Check: (1) internet connectivity, (2) dnf repo config, (3) run: dnf install -y redis"
# Free memory: clean dnf cache and drop OS caches before install
dnf clean all >/dev/null 2>&1 || true
sync; echo 3 > /proc/sys/vm/drop_caches 2>/dev/null || true
if ! dnf install -y --setopt=install_weak_deps=False --setopt=keepcache=False redis 2>&1; then
local mem_avail
mem_avail=$(awk '/MemAvailable/{print int($2/1024)"MB"}' /proc/meminfo 2>/dev/null || echo "unknown")
error_exit "dnf install redis failed (available RAM: $mem_avail). If OOM, scale up the node first. Then run: dnf install -y redis"
fi
# Verify binary appeared post-install