1.设置wjlcn下的a表的主键
mysql> alter table a add constraint pk_a primary key(id);
2.先在slave上插入一条记录
mysql> insert into a values (15,'2011-08-08');
Query OK, 1 row affected (0.00 sec)
mysql> select * from a;
+----+------------+
| id | date |
+----+------------+
| 15 | 2011-08-08 |
+----+------------+
3.在master上插入同样的记录
mysql> insert into a values (15,'2011-08-08');
4.查看slave的状态
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.159.132
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000010
Read_Master_Log_Pos: 4302
Relay_Log_File: relay-bin.000005
Relay_Log_Pos: 635
Relay_Master_Log_File: mysql-bin.000010
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB: wjlcn
Replicate_Ignore_DB: mysql
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1068
Last_Error: Error 'Multiple primary key defined' on query. Default database: 'wjlcn'.
Query: 'alter table a add constraint pk_a primary key(id)'
Skip_Counter: 0
Exec_Master_Log_Pos: 3821
Relay_Log_Space: 1806
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: 1068
Last_SQL_Error: Error 'Multiple primary key defined' on query. Default database: 'wjlcn'.
Query: 'alter table a add constraint pk_a primary key(id)'
1 row in set (0.00 sec)
ERROR:
No query specified
5. 在slave上跳过这条sql语句
mysql> set global sql_slave_skip_counter=1;
6.启动slave
mysql> start slave;
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: 192.168.159.132
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000010
Read_Master_Log_Pos: 4896
Relay_Log_File: relay-bin.000005
Relay_Log_Pos: 1710
Relay_Master_Log_File: mysql-bin.000010
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: wjlcn
Replicate_Ignore_DB: mysql
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: 4896
Relay_Log_Space: 2400
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:
1 row in set (0.00 sec)
ERROR:
No query specified
wjlcn 2011-09
阅读(1807) | 评论(0) | 转发(0) |