-
Mysql MyISAM recovering 테이블 복구└ Mysql 2013. 9. 16. 17:32
세상사 내 맘처럼 되는법이 없는것처럼..
언제나 내앞에 장애물은 생기고~생기고~ ;;
1. 사건의 발단
용량 많은 테이블 data 보정할 일이 생겨서 임시(spare)서버에 데이터를 복사해서 테스트 할려고 복사했다.
-rw-rw---- 1 mysql mysql 8.9K Aug 29 13:00 willow_log_20130830.frm
-rw-rw---- 1 mysql mysql 17G Aug 31 00:00 willow_log_20130830.MYD
-rw-rw---- 1 mysql mysql 13G Aug 31 00:00 willow_log_20130830.MYI
-rw-rw---- 1 mysql mysql 8.9K Aug 30 13:00 willow_log_20130831.frm
-rw-rw---- 1 mysql mysql 25G Aug 31 23:59 willow_log_20130831.MYD
-rw-rw---- 1 mysql mysql 19G Aug 31 23:59 willow_log_20130831.MYI
2. 위기
아..근데 데이터 볼려고 select 했더니 check tables 프로세스가 도는게 아닌가..
Id User Host db Command Time State Info
------ ------ --------------- ------ ------- ------ -------------- ---------------------
16 root 127.0.0.1:57021 test Query 242 Checking table willow_log_20130831
17 root 127.0.0.1:57024 (NULL) Sleep 6119 (NULL)
19 root 127.0.0.1:57032 (NULL) Query 0 (NULL) SHOW PROCESSLIST
20 root 127.0.0.1:57035 (NULL) Sleep 4 (NULL)
넘 오래 걸려서 걍 kill 해버렸더니..데이터가 깨져버렸다. OTL
내가 언제 이렇게 큰 MyIsam 테이블을 복사 할 일 있었어야 말이지~! ㅠㅠ
Table './test/willow_log_20130831' is marked as crashed and last (automatic?) repair failed
다른 테이블은 check table 돌려놓고 금욜 퇴근.
월욜날 출근해서 보니 완료 되어서 잘 select 되는구낭~
3. 극복시도
이제 깨진 테이블 복구 해볼까낭~?
먼저 mysql 데몬을 내리고~
[root@sparedb04 /data/ismdata/test]$ /mysql/bin/mysqladmin shutdown -p
데이터 디렉토리 가서 봤더니 첨 보는 확장자가 있네. 뭐지?
찾아보니 The .TMD file is an intermediate data file for a table that needs to recreate its data file
테이블 재 생성시 생기는 임시 파일이라는구낭.
-rw-rw---- 1 mysql mysql 8.9K Aug 30 13:00 willow_log_20130831.frm
-rw-rw---- 1 mysql mysql 25G Aug 31 23:59 willow_log_20130831.MYD
-rw-rw---- 1 mysql mysql 19G Sep 16 13:34 willow_log_20130831.MYI
-rw-r----- 1 root root 25G Sep 16 13:19 willow_log_20130831.TMD
4. 위기2
왜.. 멈춘거냐?
[root@sparedb04 /data/ismdata/test]$ /mysql/bin/myisamchk -r willow_log_20130831
- recovering (with sort) MyISAM-table 'willow_log_20130831'
Data records: 0
- Fixing index 1
- Fixing index 2
- Fixing index 3
/mysql/bin/myisamchk: Disk is full writing '/tmp/STZN500L' (Errcode: 28). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)
/mysql/bin/myisamchk: Retry in 60 secs. Message reprinted in 600 secs
/mysql/bin/myisamchk: Retry in 60 secs. Message reprinted in 600 secs
/mysql/bin/myisamchk: Retry in 60 secs. Message reprinted in 600 secs
/mysql/bin/myisamchk: Retry in 60 secs. Message reprinted in 600 secs
/mysql/bin/myisamchk: Retry in 60 secs. Message reprinted in 600 secs
왜왜!!!
/tmp 디스크.. full... 이런 사태가..
[root@sparedb04 /tmp]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/cciss/c0d0p3 9.7G 9.7G 0 100% /tmp
5. 극복 시도2
옵션에 tmp 디렉토리 변경이 있어서 해줘봤다.
[root@sparedb04 /data/ismdata/test]$ /mysql/bin/myisamchk -rf willow_log_20130831 -tmpdir=/data/tmp_data
- recovering (with sort) MyISAM-table 'willow_log_20130831'
Data records: 0
- Fixing index 1
/mysql/bin/myisamchk: Can't create/write to file 'mpdir=/data/tmp_data/STLYTTYX' (Errcode: 2)
myisamchk: error: 2 when fixing table
MyISAM-table 'willow_log_20130831' is not fixed because of errors
Try fixing it by using the --safe-recover (-o), the --force (-f) option or by not using the --quick (-q) flag
옵션..너에 대해 알려줘
-r, --recover Can fix almost anything except unique keys that aren't unique.
-f, --force Overwrite old temporary files.
-o, --safe-recover Uses old recovery method; Slower than '-r' but can handle a couple of cases where '-r' reports that it can't fix the data file.
6. 극복 시도3
옵션 더 넣어보라고 뭐라 뭐라 한다. 힝~!
잘되야 할텐데......
[root@sparedb04 /data/ismdata/test]$ /mysql/bin/myisamchk -rfo willow_log_20130831 -tmpdir=/data/tmp_data
- recovering (with keycache) MyISAM-table 'willow_log_20130831'
Data records: 24403103
22012000
.
.
.
.
.
기다리는동안 궁금해서 구글링 해보니
mysqlcheck 유틸과 check table, repair table 명령의 차이는 셧다운이란거~
운영중인 DB인 경우는 check table 해줘야겠네~
URL : http://www.techrepublic.com/article/checking-and-repairing-mysql-tables/
An option here is to use the mysqlcheck utility, which provides a command line front end to the CHECK TABLE and REPAIR TABLE commands, allowing you to check and repair tables without first taking the server down. Everything that you can do with CHECK TABLE and REPAIR TABLE can be done with mysqlcheck, by passing appropriate command line options to the program.
'└ Mysql' 카테고리의 다른 글
Mysql Slave (replication) (0) 2013.10.04 mysql client version 이랑 DB version 다를때 (0) 2013.09.10 python mysql (0) 2013.06.24