--- title: 機房伺服器斷線(電)導致Bitnami Redis AOF檔案異常,在K8s修復方案,以gitlab為例 disqus: hackmd --- 機房伺服器斷線導致Bitnami Redis AOF檔案異常,在K8s修復方案,以gitlab為例 === ## 索引 [TOC] ## 注意事項 * 在正常狀況下是不太有可能發生此問題,除非pvc突然斷開也會導致 ## 異常檔案位置(k8s bitnami redis) * 指令`ubuntu@csie406-223:/$ kubectl exec -it -n gitlab-gpu gitlab-gpu-redis-master-0 -c redis -- bash` ``` I have no name!@gitlab-gpu-redis-master-0:/$ cd /data I have no name!@gitlab-gpu-redis-master-0:/data$ ls appendonly.aof I have no name!@gitlab-gpu-redis-master-0:/data$ mv appendonly.aof appendonly.bak.aof ``` 這裡處理完以後應該redis會轉換為Running ## 檔案資訊顯示 ``` I have no name!@gitlab-gpu-redis-master-0:/data$ ls -l -l total 18715120 -rw-r--r-- 1 1001 1001 121773 Aug 16 04:01 appendonly.aof -rw-rw-r-- 1 1001 1001 19164127232 Aug 14 03:19 appendonly.bak.aof I have no name!@gitlab-gpu-redis-master-0:/data$ ls -l ``` ## Reference and FAQ * [debug-running-pod](https://kubernetes.io/zh/docs/tasks/debug-application-cluster/debug-running-pod/) * [服务器重启导致redis aof文件损坏(Bad file format reading the append only file: make a backup of your AOF file)](https://zhuanlan.zhihu.com/p/378659903) * [配置 Pod 以使用 PersistentVolume 作为存储](https://kubernetes.io/zh/docs/tasks/configure-pod-container/configure-persistent-volume-storage/) * [redis突然掉电导致aof文件损坏修复一例](https://blog.51cto.com/imysqldba/1403866) :::info **Find this document incomplete?** Leave a comment! ::: ###### tags: `Bitnami Redis` `Documentation`