MariaDB

xtrabackup로 MyISAM 테이블 백업 시 데이터 정합성 이슈

kkimdubi·2018년 2월 23일·조회 2,116
 

-.0 요약

xtrabackup으로는 myisam 엔진 테이블들에 대해 데이터 정합성을 보장할 수 없음
 

 

-1. 백업 프로세스 

=> 아래는 xtrabackup tool 의 innobackupex 커맨드를 사용하여 full 백업 및 apply-log 를 적용했던 간략한 로그

 
innodb 관련 파일 copy (테이블,ibdata등)
12:51 시작
 
non-innodb 관련 파일 copy (myisam 테이블, performance_schema,information_schema 등)
16:05 완료
 
apply-log 적용 후 완료
16:05 시작
16:32 완료
 
 

-2. 백업 본 확인

 
[testuser@TEST02V 2018-02-17_12-51-04]$ ls -ltr
total 25574080
drwxr-x--- 2 testuser testuser        4096 Feb 17 16:05 sys
drwxr-x--- 2 testuser testuser        8192 Feb 17 16:05 mysql
drwxr-x--- 2 testuser testuser       20480 Feb 17 16:05 TEST2
drwxr-x--- 2 testuser testuser        8192 Feb 17 16:05 performance_schema
drwxr-x--- 2 testuser testuser       69632 Feb 17 16:05 TEST
-rw-r----- 1 testuser testuser          44 Feb 17 16:05 xtrabackup_binlog_info
-rw-r----- 1 testuser testuser      962710 Feb 17 16:05 ib_buffer_pool
-rw-r----- 1 testuser testuser         464 Feb 17 16:05 backup-my.cnf
-rw-r----- 1 testuser testuser         617 Feb 17 16:05 xtrabackup_info
-rw-r--r-- 1 testuser testuser          53 Feb 17 16:32 xtrabackup_binlog_pos_innodb
-rw-r----- 1 testuser testuser  2147483648 Feb 17 16:32 ibdata2
-rw-r----- 1 testuser testuser  2147483648 Feb 17 16:32 ibdata3
-rw-r----- 1 testuser testuser         125 Feb 17 16:32 xtrabackup_checkpoints
-rw-r----- 1 testuser testuser  2180644864 Feb 17 16:32 xtrabackup_logfile
-rw-r----- 1 testuser testuser  1073741824 Feb 17 16:32 ib_logfile1
-rw-r----- 1 testuser testuser  1073741824 Feb 17 16:32 ib_logfile2
-rw-r----- 1 testuser testuser 14227079168 Feb 17 16:32 ibdata4
-rw-r----- 1 testuser testuser  1073741824 Feb 17 16:32 ib_logfile0
-rw-r----- 1 testuser testuser  2147483648 Feb 17 16:32 ibdata1
-rw-r----- 1 testuser testuser    12582912 Feb 17 16:32 ibtmp1
 
=> 시간대를 보면 16:05, 16:32 
 
16:05분은 non-innodb 테이블 copy 작업 후 완료
16:32분은 innodb 테이블 copy 후 apply-log 반영 후 완료
 
xtrabackup_binlog_info 는 백업 완료시점의 binary log position 기록
xtrabackup_binlog_pos_innodb 는 백업이 완료되는 시점의 innodb 의 변경 분 포지션 기록
xtrabackup_logfile 은 백업 시작부터 완료될 때 까지 innodb 의 변경분 데이터가 저장됨 
(myisam 엔진 제외, transaction 을 지원하는 엔진에 한해서 innodb,xtradb)
 
 
-3. 엔진 별 테이블 백업 완료 시점 확인
 
-- innodb
 
[masvc01@LGEDGLAP02V glapp]$ ls -ltr *ibd
-rw-r----- 1 masvc01 masvc01       163840 Feb 17 12:52 tb_li_xxapf_cll_invo_lines.ibd
-rw-r----- 1 masvc01 masvc01     41943040 Feb 17 12:53 tb_lm_dq_execute_list.ibd
-rw-r----- 1 masvc01 masvc01       114688 Feb 17 12:53 tb_li_xxapf_cll_invo_parents.ibd
-rw-r----- 1 masvc01 masvc01     24117248 Feb 17 12:53 tb_li_xxacf_out_transport.ibd
-rw-r----- 1 masvc01 masvc01       475136 Feb 17 12:53 tb_lm_menuauth_bk20170401.ibd
-rw-r----- 1 masvc01 masvc01       278528 Feb 17 12:53 tb_li_cps_history_temp.ibd
 
--MyISAM
 
[testuser@TEST02V TESTp]$ ls -ltr *MYD
 
-rw-r----- 1 testuser testuser 200291064 Feb 17 16:05 tb1.MYD
-rw-r----- 1 testuser testuser        17 Feb 17 16:05 tb2.MYD
-rw-r----- 1 testuser testuser        17 Feb 17 16:05 tb3.MYD
-rw-r----- 1 testuser testuser        17 Feb 17 16:05 tb4.MYD
-rw-r----- 1 testuser testuser        17 Feb 17 16:05 tb5.MYD
-rw-r----- 1 testuser testuser        17 Feb 17 16:05 tb6.MYD
-rw-r----- 1 testuser testuser        17 Feb 17 16:05 tb7.MYD
-rw-r----- 1 testuser testuser        17 Feb 17 16:05 tb8.MYD
-rw-r----- 1 testuser testuser  12592412 Feb 17 16:05 tb9.MYD
-rw-r----- 1 testuser testuser        17 Feb 17 16:05 tb10.MYD
-rw-r----- 1 testuser testuser    205812 Feb 17 16:05 tb11.MYD
-rw-r----- 1 testuser testuser        17 Feb 17 16:05 tb12.MYD
 
 
=>  InnoDB 관련 테이블들은 apply-log 적용 후 16:32 완료 되었으나 MyISAM은  16:05 백업 완료
=>  myisam 엔진 테이블들은 apply-log 적용과는 무관함
 

 

-4. 문제점

 
MyISAM은 트랜잭션을 지원하지 않기 때문에 백업도중 변경분이
Master 서버의 MyISAM 데이터파일 (MYD,MYI) 에 실시간으로 수정됨
 
=> 백업본으로 슬레이브 서버 구성 시  마스터 서버와 데이터 정합성이 깨질 가능성이 있음
 
  
 
 
apply-log 완료 후 xtrabackup_binlog_pos_innodb 는 b 혹은 d 로 결정됨 (rollback 트랜잭션 발생시)
 
백업 중 b~c 사이 혹인 c~d 사이에
myisam 테이블에 대해 트랜잭션 발생 시  myisam 변경 분에 대해서는 트랜잭션 관리가 안됨
 
slave db 서버에 백업본으로 복구 후 b 혹은 d로 replication 을 구성했을 때
slave는 master 의 binary log 를 따라가다가 duplication 혹은 key not found 등의 데이터 정합성 관련 에러를 만날 수 있음
 
 
 
 
-- replication 시 데이터 정합성 에러
 

180217 12:01:02 [ERROR] Slave SQL: Could not execute Update_rows_v1 event on table TEST.tb1; Table './TEST/tb1' is marked as crashed and should be repaired, Error_code: 145; Table 'tb1' is marked as crashed and should be repaired, Error_code: 1194; Can't find record in 'tb1', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mariadb-bin.005487, end_log_pos 745654908, Gtid 1-2-2196814761, Internal MariaDB error code: 1032

180217 12:01:02 [Warning] Slave: Table './TEST/tb1' is marked as crashed and should be repaired Error_code: 145
180217 12:01:02 [Warning] Slave: Table 'tb1' is marked as crashed and should be repaired Error_code: 1194
180217 12:01:02 [Warning] Slave: Can't find record in 'tb1' Error_code: 1032
180217 12:01:02 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mariadb-bin.005487' position 745654759
 

댓글 1

로그인 후 댓글을 남길 수 있습니다.

  • kkimdubi· 2018년 3월 6일
    그림이 잘 못되어 수정했습니다.