1. 내용
1.1 환경
- MariaDB Version : v10.1.12
- AWS 환경
1.2 내용
- MariaDB 재부팅 후 DB 비정상 동작
2. 원인 분석
2.1 로그 분석
- ibdata의 시퀀스 넘버와 ib_logfiles의 시퀀스 넘버가 일치하지 않음
- MariaDB가 정상적으로 종료되지 않아 MariaDB 시작 시 복구 진행을 시도하지만
실제로는 복구된 항목 없이 DB가 시작됨
[Note] InnoDB : The log sequence numbers 1616840 and 1616840 in ibdata files do not match the log sequence number 31169132 in the ib_logfiles
[Note] Database was not shutdown normally!
[Note] Starting crash recovery.
...중략
[ERROR] Got an error from thread_id=4, /home/buildbot/buildbot/build/storage/myisam/ha_myisam.cc:951
[ERROR] MySQL thread id 4, OS thread handle 0x7f6218066b00, qurey id 9 localhost root Checking table CHECK TABLE 'SQ_JOB_LOCK_ID'
[ERROR] mysqld: Table './APPAMDB/SQ_JOB_LOCK_ID' is marked as crashed and should be repaired
[Warning] Checking table: './APPAMDB/SQ_JOB_LOCK_ID'
[Warning] REcovering table : './APPAMDB/SQ_JOB_LOCK_ID'
[Note] Found 0 of 1 rows when repairing './APPAMDB/SQ_JOB_LOCK_ID'
...중략
2.2 테이블 점검
- 로그에 나온 테이블 상태 점검 시 에러 발생
- 명령어
전체 테이블 : mysqlcheck -uroot -proot -A
특정 테이블 : mysqlchekck -uroot -proot -a [DB] [Table]
DB.TABLE
Warning : 1 client is using or hasn't cloesd the table properly
Warning : Size of datafile is:13 Should be :0
Error : Record-count is not ok; is 1 Should be :0
Warning : Found 1 key parts. Should be :0
Error : Corrupt
2.3 분석 결과
- MariaDB 재부팅 후 MyISAM 엔진을 사용하고 있는 테이블이 깨져 DB가 정상동작하지 않음
3. 해결
1) mysqlcheck를 통한 강제 복구
- 명령어 : mysqlcheck -uroot -proot --auto-repair [DB] [Table]
2) innodb_force_recovery=1 옵션 설정 후 DB 재부팅
- /etc/my.cnf 파일에서 옵션 수정
3) DB 재구성