今天查看Mysql同步状态的时候发现同步出错。错误如下:
Slave_SQL_Running: No
看Err log发现如下错误,这条是数据库shutdown引起的。。。应该不是。
如果是这个错误的话可以用此条命令
set global sql_slave_skip_counter=1;
140226 14:49:47 [Note] Event Scheduler: Purging the queue. 0 events
140226 14:49:47 [Note] Error reading relay log event: slave SQL thread was killed
140226 14:49:47 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013)
140226 14:49:47 [Note] Slave I/O thread killed while reading event
140226 14:49:47 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.000002', position 338
140226 14:49:47 InnoDB: Starting shutdown...
140226 14:49:52 InnoDB: Shutdown completed; log sequence number 0 1713364200
140226 14:49:52 [Note] mysql: Shutdown complete
接下来是执行sql插入语句报错
140226 16:35:23 [Note] Plugin 'FEDERATED' is disabled.
140226 16:35:23 InnoDB: Initializing buffer pool, size = 8.0M
140226 16:35:23 InnoDB: Completed initialization of buffer pool
140226 16:35:23 InnoDB: Started; log sequence number 0 1713364200
140226 16:35:23 [Warning] Neither --relay-log nor --relay-log-index were used; so replication may break when this MySQL server acts as a slave and has his hostname changed!! Please use '--relay-log=administrator-relay-bin' to avoid this problem.
140226 16:35:23 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.000002' at position 338, relay log '.\
administrator-22-relay-bin.000007' position: 265
140226 16:35:23 [Note] Slave I/O thread: connected to master 'slave@192.168.111.111:3306',replication started in log 'mysql-bin.000002' at position 338140226 16:35:23 [Note] Event Scheduler: Loaded 0 events140226 16:35:23 [Note] mysql: ready for connections.Version: '5.1.56-community-log' socket: '' port: 3305 MySQL Community Server (GPL)140227 19:40:16 [ERROR] Slave SQL: Error 'Duplicate entry '8221' for key 'PRIMARY'' on query. Default database: 'dbname'. Query: 'insert into table (status, 'Valid')', Error_code: 1062
然后执行
start slave sql_thread;
然后再查看slave状态,SQL_thread已经起起来了,那么同步也就可以了。
有时间再看错误。