免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1036 | 回复: 0
打印 上一主题 下一主题

mysql模拟复制出错(简单测试) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-23 01:51 |只看该作者 |倒序浏览

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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP