Mariadb 에러 대처
오늘 갑자기 사이트 데이터베이스 접속 오류가 난다. 깜짝 놀라 서버를 열어보니 웅? 디비는 안 죽어 있다. 이게 뭐지 하고 아무생각 없이 DB 재시작. 아… 안올라온다. 에러 로그 확인.
]# tail /var/log/mariadb/mysqld-error.log
2026-03-18 21:41:25 51117 [ERROR] Got an error from thread_id=51117, /home/buildbot/buildbot/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX/mariadb-10.11.4/storage/myisam/mi_update.c:227
2026-03-18 21:41:25 51117 [ERROR] MariaDB thread id 51117, OS thread handle 139863601764096, query id 2451373 localhost phobezzang Updating
UPDATE `wp_options` SET `option_value` = '1773837685.5027720928192138671875' WHERE `option_name` = '_transient_doing_cron'
2026-03-18 21:41:25 51117 [ERROR] mariadbd: Table 'wp_options' is marked as crashed and should be repaired
2026-03-18 21:41:26 51119 [Warning] mariadbd: Disk is full writing '/var/log/mariadb/mysqld-bin.000150' (Errcode: 28 "No space left on device"). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)
2026-03-18 21:41:26 51119 [Warning] mariadbd: Retry in 60 secs. Message reprinted in 600 secs
2026-03-18 21:41:30 51120 [ERROR] mariadbd: Disk full (/tmp/#sql-temptable-6e5-c7b0-35.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
2026-03-18 21:41:36 51122 [ERROR] mariadbd: Disk full (/tmp/#sql-temptable-6e5-c7b2-36.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
2026-03-18 21:41:41 51124 [ERROR] mariadbd: Disk full (/tmp/#sql-temptable-6e5-c7b4-37.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")뭐가 많기도 한데, 워드프레스 옵션 테이블이 크래쉬 났다…뭐 근데 그게 디스크가 풀난거 아니냐? 등…
재시작 명령덕에 디비에 접속 할 수는 없고, 디스크 풀 문제는 일단 바이너리 로그파일이 커진게 문제인데. 내 바이너리 로그는 디비 파티션에는 없고, log 폴더에 생성되게 커스터마이징 함.
]# df -h /tmp <- 여기도 문제고
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p4 83G 79G 0 100% /
]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 32G 0 32G 0% /dev
tmpfs 32G 0 32G 0% /dev/shm
tmpfs 32G 18M 32G 1% /run
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/nvme0n1p4 83G 79G 0 100% / < - 뭐 꽉 차인거
/dev/loop0 64M 64M 0 100% /var/lib/snapd/snap/core20/2379
/dev/loop7 72M 72M 0 100% /var/lib/snapd/snap/certbot/5451
/dev/loop1 64M 64M 0 100% /var/lib/snapd/snap/core20/2434
/dev/loop3 105M 105M 0 100% /var/lib/snapd/snap/core/17272
/dev/loop2 67M 67M 0 100% /var/lib/snapd/snap/core24/1499
/dev/loop5 73M 73M 0 100% /var/lib/snapd/snap/certbot/5370
/dev/loop4 67M 67M 0 100% /var/lib/snapd/snap/core24/1349
/dev/nvme0n1p2 976M 181M 728M 20% /boot
/dev/nvme0n1p1 200M 12M 189M 6% /boot/efi
/dev/nvme0n1p3 315G 54G 246G 18% /host
/dev/nvme0n1p5 63G 219M 60G 1% /var/lib/mysql
/dev/loop8 106M 106M 0 100% /var/lib/snapd/snap/core/17284
tmpfs 6.3G 0 6.3G 0% /run/user/1000
그래서 확인하고, 바이너리 로그를 지울 수 밖에 없음. 표준으로는 디비에 접속해서 바이너리 로그를 퍼지 해야 하지만 일단 접근하지도 못하는 상황이라, OS 차원에서 파일삭제 시도
원래는 DB 접속 후 정식 삭제 (중요)
DB가 올라왔다면 반드시 접속해서 인덱스 파일과 동기화되도록 정식 삭제 명령을 수행
]# ll /var/log/mariadb/
합계 249936
-rw-rw----. 1 mysql mysql 393216 3월 18 18:36 aria_log.00000001
-rw-rw----. 1 mysql mysql 52 3월 18 18:36 aria_log_control
-rw-rw----. 1 mysql mysql 9 2월 8 10:38 ddl_recovery-backup.log
-rw-rw----. 1 mysql mysql 104873311 3월 10 00:33 mysqld-bin.000148
-rw-rw----. 1 mysql mysql 82038784 3월 15 09:03 mysqld-bin.000149
-rw-rw----. 1 mysql mysql 47222784 3월 19 14:47 mysqld-bin.000150
-rw-rw----. 1 mysql mysql 105 3월 15 09:06 mysqld-bin.index
-rw-rw----. 1 mysql mysql 21364736 3월 19 14:42 mysqld-error.log
-rw-rw----. 1 mysql mysql 8192 3월 19 14:12 mysqld-slow.log
[root@server tmp]# rm -f /var/log/mariadb/mysqld-bin.000148 <- 오래된 놈부터 삭제
[root@server tmp]# ll /var/log/mariadb/
합계 147516
-rw-rw----. 1 mysql mysql 393216 3월 18 18:36 aria_log.00000001
-rw-rw----. 1 mysql mysql 52 3월 18 18:36 aria_log_control
-rw-rw----. 1 mysql mysql 9 2월 8 10:38 ddl_recovery-backup.log
-rw-rw----. 1 mysql mysql 82038784 3월 15 09:03 mysqld-bin.000149
-rw-rw----. 1 mysql mysql 47222784 3월 19 14:47 mysqld-bin.000150
-rw-rw----. 1 mysql mysql 105 3월 15 09:06 mysqld-bin.index
-rw-rw----. 1 mysql mysql 21364736 3월 19 14:42 mysqld-error.log
-rw-rw----. 1 mysql mysql 8192 3월 19 14:12 mysqld-slow.log
]# systemctl start mariadb <- 삭제 후 데몬 재시작
]# mysql mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.11.4-MariaDB-log MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root[mysql]>PURGE BINARY LOGS BEFORE NOW(); <- 접속 후 바이너리 퍼지 시도
Query OK, 0 rows affected, 1 warning (0.031 sec)
Warning (Code 1612): Being purged log /var/log/mariadb/mysqld-bin.000148 was not found
root[mysql]>SHOW BINARY LOGS;
+-------------------+-----------+
| Log_name | File_size |
+-------------------+-----------+
| mysqld-bin.000151 | 72039 |
+-------------------+-----------+
1 row in set (0.001 sec)경고(Warning 1612)는 아까 DB가 꺼져 있을 때 rm 명령어로 직접 파일을 지웠기 때문에 발생하는 지극히 정상적인 반응. SHOW BINARY LOGS; 로 실제 파일과 일치하는지 확인.
인덱스 파일 강제 동기화 (선택 사항)
만약 여전히 목록에 깨진 정보가 남아있다면, 현재 로그를 다음 번호로 넘기면서 정리
]# mysql mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.11.4-MariaDB-log MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root[mysql]>FLUSH LOGS;
PURGE BINARY LOGS BEFORE NOW();


