主从同步错误一例

mysql> show slavestatus\G;

***************************1. row ***************************

              Slave_IO_State:

                 Master_Host: 10.0.10.114

                 Master_User: rep

                 Master_Port: 3306

               Connect_Retry: 60

             Master_Log_File: mysql-bin.000024

         Read_Master_Log_Pos: 264

              Relay_Log_File: relay-bin.000001

               Relay_Log_Pos: 4

       Relay_Master_Log_File: mysql-bin.000024

Slave_IO_Running: No

           Slave_SQL_Running: Yes

             Replicate_Do_DB:

。。。。。。。。。。(省略)。。。。。。

Master_SSL_Verify_Server_Cert:No

Last_IO_Errno: 1593

               Last_IO_Error: Fatal error: Theslave I/O thread stops becausemaster and slave have equal MySQL server ids; these ids must bedifferent for replication to work (or the --replicate-same-server-id optionmust be used on slave but this does not always make sense; please check themanual before using it).

解决:

[root@MySQL_web ~]# grep"server-id" /data/3306/my.cnf                #####主库

server-id = 1

[root@MySQL_web ~]#

[root@MySQL_slave_web2 ~]# grep"server-id" /data/3306/my.cnf         #####从库

server-id = 1                                                     #####更改为3

[root@MySQL_slave_web2 ~]#

[root@MySQL_slave_web2 ~]# /data/3306/mysql restart

Restarting MySQL...

Stoping MySQL...

Enter password:

Starting MySQL...

mysql> stop slave;

Query OK, 0 rows affected (0.27 sec)

mysql> CHANGE MASTER TO MASTER_HOST='10.0.10.114', MASTER_PORT=3306, MASTER_USER='rep',MASTER_PASSWORD='802352', MASTER_LOG_FILE='mysql-bin.000024',MASTER_LOG_POS=264;

Query OK, 0 rows affected (0.01 sec)

mysql> start slave;

Query OK, 0 rows affected (0.01 sec)

mysql> show slavestatus\G;

***************************1. row ***************************

              Slave_IO_State: Queueing masterevent to the relay log

                 Master_Host: 10.0.10.114

                 Master_User: rep

                 Master_Port: 3306

               Connect_Retry: 60

             Master_Log_File: mysql-bin.000028

         Read_Master_Log_Pos: 106

              Relay_Log_File: relay-bin.000043

               Relay_Log_Pos: 251

       Relay_Master_Log_File: mysql-bin.000028

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

。。。。。。。。。(省略)。。。。。。。。。。。。。。

               Last_IO_Errno: 0

               Last_IO_Error:

              Last_SQL_Errno: 0

              Last_SQL_Error:

1 row in set (0.02sec)

ERROR:

No query specified

mysql>