MySQL 복사 에 실패 한 해결 방안 을 디스크 에 가득 채 웠 습 니 다.
오늘 온라인 에서 문제 가 발견 되 었 습 니 다.모니터링 이 덮어 지지 않 아 한 기계 의 디스크 가 가득 써 서 온라인 MySQL 주종 복사 에 문제 가 생 겼 습 니 다.문 제 는 다음 과 같다.
localhost.(none)>show slave status\G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 10.xx.xx.xx
Master_User: replica
Master_Port: 5511
Connect_Retry: 60
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: relay-bin.001605
Relay_Log_Pos: 9489761
Relay_Master_Log_File:
Slave_IO_Running: No
Slave_SQL_Running: No
Last_Errno: 13121
Last_Error: Relay log read failure: Could not parse relay log event entry.
The possible reasons are: the master's binary log is corrupted (you can check this by running
'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by
running 'mysqlbinlog' on the relay log), a network problem, the server was unable to fetch a
keyring key required to open an encrypted relay log file, or a bug in the master's or
slave's MySQL code. If you want to check the master's binary log or slave's relay log,
you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.
그래서 error log 를 보 니 error log 의 내용 이 다음 과 같 습 니 다.
2021-03-31T11:34:39.367173+08:00 11 [Warning] [MY-010897] [Repl] Storing MySQL user name or
password information in the master info repository is not secure and is therefore not
recommended. Please consider using the USER and PASSWORD connection options for START SLAVE;
see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2021-03-31T11:34:39.368161+08:00 12 [ERROR] [MY-010596] [Repl] Error reading relay log
event for channel '': binlog truncated in the middle of event; consider out of disk space
2021-03-31T11:34:39.368191+08:00 12 [ERROR] [MY-013121] [Repl] Slave SQL for channel '': Relay
log read failure: Could not parse relay log event entry. The possible reasons are: the master's
binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the
slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log),
a network problem, the server was unable to fetch a keyring key required to open an encrypted
relay log file, or a bug in the master's or slave's MySQL code. If you want to check the
master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW
SLAVE STATUS' on this slave. Error_code: MY-013121
2021-03-31T11:34:39.368205+08:00 12 [ERROR] [MY-010586] [Repl] Error running query, slave SQL
thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We
stopped at log 'mysql-bin.000446' position 9489626
설명 을 통 해 알 수 있 듯 이 error log 는 비교적 스마트 하고 디스크 문 제 를 발 견 했 으 며'consider'가 필요 하 다 고 알려 주 었 습 니 다. out of disk space"문 제 를 해결 하 다
서버 에 로그 인하 면 MySQL 이 있 는 서버 디스크 사용률 이 100%에 달 하 는 것 을 발견 할 수 있 습 니 다.문제 의 원인 은 error log 의 내용 과 일치 합 니 다.
지금 바로 이 문 제 를 해결 하 자.기본 적 인 사 고 는 디스크 파일 을 정리 한 다음 에 복사 관 계 를 다시 구축 하 는 것 이다.이 과정 은 비교적 간단 한 것 같 지만 실제 작업 에서 복사 관 계 를 구축 할 때 다음 과 같은 오류 가 발생 했다.
### gtid ,
localhost.(none)>reset slave;
ERROR 1371 (HY000): Failed purging old relay logs: Failed during log reset
localhost.(none)>reset slave all;
ERROR 1371 (HY000): Failed purging old relay logs: Failed during log reset
첫 번 째 단계:복 제 는 gtid 를 기반 으로 진행 되 기 때문에 show slave status 의 상 태 를 직접 기록 한 후 reset slave 를 다시 시작 하고 change master 문 구 를 이용 하여 복사 관 계 를 재 구축 할 수 있 습 니 다.그러나 위의 오류 가 발생 했 습 니 다.오류 메 시 지 를 보면 my sql 에서 Purge relay log 의 조작 을 완성 할 수 없습니다.이것 은 과학적 이지 않 습 니 다.그래,네가 Purge relay logs 의 조작 을 완성 할 수 없 으 니 내 가 도와 줄 게.
두 번 째 단계:수 동 rm-f 모든 relay log 를 삭제 하 였 습 니 다.오류 가 발생 했 습 니 다:
localhost.(none)>reset slave all;
ERROR 1374 (HY000): I/O error reading log index file
응,그래,문제 가 해결 되 지 않 았 어.그리고 생각 해 봤 어 요.수 동 reset slave 를 통 해 relay log 를 정리 할 수 없 으 니 그냥 stop.
slave 하고 change master 하면 안 돼 요?
세 번 째 단계:stop slave 를 직접 한 다음 change master 는 reset slave all 문 구 를 실행 하지 않 습 니 다.결 과 는 다음 과 같 습 니 다.
localhost.(none)>change master to master_host='10.13.224.31',
-> master_user='replica',
-> master_password='eHnNCaQE3ND',
-> master_port=5510,
-> master_auto_position=1;
ERROR 1371 (HY000): Failed purging old relay logs: Failed during log reset
그래,문 제 는 여전 하 다.STEP 4:어차피 복사 가 잘못 되 었 으 니 start slave 를 실행 해 보 세 요.그 결과 극적인 장면 이 나 타 났 습 니 다.
localhost.(none)>start slave;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 262
Current database: *** NONE ***
Query OK, 0 rows affected (0.01 sec)
localhost.(none)>
[root@ ~]#
start slave 를 실행 한 후 인 스 턴 스 가 바로 끊 겼 습 니 다.여기까지 복사 가 완전히 끊 겼 습 니 다.라 이브 러 리 인 스 턴 스 에서 끊 겼 습 니 다.
다섯 번 째 단계:인 스 턴 스 를 다시 시작 할 수 있 는 지 확인 하고 인 스 턴 스 를 다시 시작 해 보 세 요.인 스 턴 스 가 다시 일어 날 수 있 습 니 다.인 스 턴 스 를 다시 시작 하면 복사 관 계 를 볼 수 있 습 니 다.결 과 는 다음 과 같 습 니 다.
localhost.(none)>show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Queueing master event to the relay log
Master_Host: 10.xx.xx.xx
Master_User: replica
Master_Port: 5511
Connect_Retry: 60
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: relay-bin.001605
Relay_Log_Pos: 9489761
Relay_Master_Log_File:
Slave_IO_Running: Yes
Slave_SQL_Running: No
Last_Errno: 13121
Last_Error: Relay log read failure: Could not parse relay log event entry.
The possible reasons are: the master's binary log is corrupted (you can check this by running
'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by
running 'mysqlbinlog' on the relay log), a network problem, the server was unable to fetch a
keyring key required to open an encrypted relay log file, or a bug in the master's or slave's
MySQL code. If you want to check the master's binary log or slave's relay log, you will be able
to know their names by issuing 'SHOW SLAVE STATUS' on this slave.
Skip_Counter: 0
복제 관 계 는 여전히 잘못 보고 되 었 다.STEP 6:다시 reset slave all 을 보 니 성공 했다.
localhost.(none)>stop slave;
Query OK, 0 rows affected (0.00 sec)
localhost.(none)>reset slave all;
Query OK, 0 rows affected (0.03 sec)
STEP 7:복제 관 계 를 재 구축 하고 복 제 를 시작 합 니 다.
localhost.(none)>change master to master_host='10.xx.xx.xx',
-> master_user='replica',
-> master_password='xxxxx',
-> master_port=5511,
-> master_auto_position=1;
Query OK, 0 rows affected, 2 warnings (0.01 sec)
localhost.(none)>start slave;
Query OK, 0 rows affected (0.00 sec)
localhost.(none)>show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.xx.xx.xx
Master_User: replica
Master_Port: 5511
Connect_Retry: 60
...
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
실례 적 인 복제 관 계 를 발견 하면 세 울 수 있다.한 점 의 총결산.
디스크 가 가득 찬 상황 이 발생 한 후에 my sql 서 비 스 는 메타 정보 표 에 데 이 터 를 쓸 수 없습니다.relay log 도 이미 완전 하지 않 을 수 있 습 니 다.서버 에 있 는 디스크 데 이 터 를 직접 정리 한 다음 에 master 에서 메 인 복사 관 계 를 다시 변경 하면 오류 가 발생 할 수 있 습 니 다.직접 복구 할 수 없습니다.이것 은 정상 적 인 메 인 복사 관계 가 끊 어 진 장면 이 아니 기 때 문 입 니 다.
그래서 정확 한 방법 은:
1.서버 의 디스크 청소
2.복사 관계 가 끊 긴 라 이브 러 리 를 다시 시작 합 니 다.
3.다시 reset slave all,change master 를 통 해 주종 복사 관 계 를 구축 하면 됩 니 다.
더 좋 은 방법 이 있다 면 아낌없이 가르쳐 주 십시오.
이상 은 MySQL 복사 에 실패 한 솔 루 션 에 대한 자세 한 내용 입 니 다.MySQL 복사 에 실패 한 솔 루 션 에 대한 자 료 는 다른 글 을 주목 하 십시오!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Redash를 사용할 때 몰랐던 SQL을 쓰는 법을 배웠습니다.최근 redash에서 sql을 쓸 기회가 많고, 이런 쓰는 방법이 있었는지와 sql에 대해 공부를 다시하고 있기 때문에 배운 것을 여기에 씁니다. Redash란? 월별로 데이터를 표시하고 싶습니다 주별로 데이터를 표...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.