主从不同步故障案例一

WBOY
풀어 주다: 2016-06-07 17:38:09
원래의
1092명이 탐색했습니다.

故障原因:开发人员在主库上修改了一张表的结构,加了一个字段,从库由于各种原因没有同步过去,导致主从同步失败。故障处理:1、查看在从库上查看同步状态:mys

故障原因:
开发人员在主库上修改了一张表的结构,加了一个字段,,从库由于各种原因没有同步过去,导致主从同步失败。

故障处理:
1、查看在从库上查看同步状态:

mysql> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 10.10.100.100 Master_User: slave Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000009 Read_Master_Log_Pos: 917648 Relay_Log_File: mysqld-relay-bin.000017 Relay_Log_Pos: 778406 Relay_Master_Log_File: mysql-bin.000009 Slave_IO_Running: Yes Slave_SQL_Running: No Replicate_Do_DB: Replicate_Ignore_DB: mysql,information_schema,performance_schema,test,mysql,information_schema,performance_schema,test Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 1054 Last_Error: Error 'Unknown column 'js_code' in 'field list'' on query. Default database: 'web_platform'. Query: 'update act_id set js_code='确保该页面的PV埋点已经上报;__tj(node,snode,cid,w,'''','''','''');说明:remark;' where act_id=11' Skip_Counter: 0 Exec_Master_Log_Pos: 906099 Relay_Log_Space: 790258 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: NULL Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 1054 Last_SQL_Error: Error 'Unknown column 'js_code' in 'field list'' on query. Default database: 'web_platform'. Query: 'update act_id set js_code='确保该页面的PV埋点已经上报;__tj(node,snode,cid,w,'''','''','''');说明:remark;' where act_id=11' Replicate_Ignore_Server_Ids: Master_Server_Id: 1 1 row in set (0.00 sec)

2、从上面可以看出表act_id的js_code字段在从库上没有,可以对比一下主库和从库这张表的结构:
查看主库:

mysql> desc act_id; +-----------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+------------------+------+-----+---------+----------------+ | act_id | int(10) unsigned | NO | PRI | NULL | auto_increment | | name | varchar(512) | NO | | NULL | | | fields | varchar(512) | NO | | NULL | | | js_code | text | NO | | NULL | | | remark | varchar(512) | NO | | NULL | | | create_user | varchar(256) | NO | | NULL | | | duty_user_name | varchar(256) | NO | | NULL | | | duty_user_email | varchar(256) | YES | | NULL | | | duty_user_phone | varchar(256) | YES | | NULL | | | create_time | bigint(20) | NO | | NULL | | | update_time | bigint(20) | NO | | NULL | | +-----------------+------------------+------+-----+---------+----------------+ 11 rows in set (0.00 sec)

查看从库:

mysql> desc act_id; +-----------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+------------------+------+-----+---------+----------------+ | act_id | int(10) unsigned | NO | PRI | NULL | auto_increment | | name | varchar(512) | NO | | NULL | | | fields | varchar(512) | NO | | NULL | | | remark | varchar(512) | NO | | NULL | | | create_user | varchar(256) | NO | | NULL | | | duty_user_name | varchar(256) | NO | | NULL | | | duty_user_email | varchar(256) | YES | | NULL | | | duty_user_phone | varchar(256) | YES | | NULL | | | create_time | bigint(20) | NO | | NULL | | | update_time | bigint(20) | NO | | NULL | | +-----------------+------------------+------+-----+---------+----------------+ 10 rows in set (0.00 sec)

3、在正式处理故障之前要停掉主库和从库的slave进程(我的环境是做了双向同步,即主主同步)

mysql> slave stop; Query OK, 0 rows affected (0.12 sec)

4、在从库上加缺少的字段:

alter table act_id add js_code text not Null AFTER fields;

5、启动从库的slave进程,查看主从状态:

mysql> slave start; Query OK, 0 rows affected (0.00 sec) mysql> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 10.10.100.100 Master_User: slave Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000009 Read_Master_Log_Pos: 917648 Relay_Log_File: mysqld-relay-bin.000117 Relay_Log_Pos: 253 Relay_Master_Log_File: mysql-bin.000009 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: mysql,information_schema,performance_schema,test,mysql,information_schema,performance_schema,test Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 917648 Relay_Log_Space: 556 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1 1 row in set (0.00 sec)
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿