Reparar un Redis que no arranca por un AOF corrupto (redis-check-aof, redis-check-rdb)
RedisPersistenciaComando
# With Redis stopped, copy the files first:
cp -a /var/lib/redis/appendonlydir /var/lib/redis/appendonlydir.bak
# Check (7.0+ multi-part AOF: pass the manifest file):
redis-check-aof /var/lib/redis/appendonlydir/appendonly.aof.manifest
# Repair by truncating everything after the first corrupt point (asks for confirmation):
redis-check-aof --fix /var/lib/redis/appendonlydir/appendonly.aof.manifest
# Verify the RDB file:
redis-check-rdb /var/lib/redis/dump.rdbQué hace
Valida los archivos AOF (base + incr + manifest) y el archivo RDB; trunca la cola incompleta o corrupta del AOF para que Redis pueda volver a arrancar.
Cuándo usarlo
Cuando Redis no arranca con 'Bad file format reading the append only file' o 'Unexpected EOF' tras un corte de luz, un disco lleno o un apagado repentino.
Precaución
--fix borra todo desde el primer punto corrupto hasta el final del archivo; si la corrupción está en mitad del archivo, se pierden todas las escrituras posteriores. Compruebe en la salida cuántos bytes se truncarán (ok_up_to, diff) antes de confirmar. Un último comando incompleto (p. ej. un HSET grande) se descarta por completo. Haga siempre primero una copia.