Surprisingly, that's not gibberish.
That indeed appears at the top of binlogs whenever you do mysqlbinlog to a binary log generated using MySQL 5.1 and MySQL 5.5. You will not see that gibberish in binary logs for MySQL 5.0 and back.
This is why the start point for replication from an empty binary log is
- 107 for MySQL 5.5
- 106 for MySQL 5.1
- 98 for MySQL 5.0 and back
This is good to remember if you do MySQL Replication where the Master if MySQL 5.1 and the slave is MySQL 5.0. This could present a really big headache.
Replication from Master using 5.0 and Slave using 5.1 works fine, not the other way around.(According to MySQL Documentation, it is generally not supported for 3 reasons: 1) Binary Log Format, 2) Row-based Replication, 3) SQL Incompatibility).
Anyway, do a mysqlbinlog on the offending binary log on the master. If the resulting dump produces gibberish in the middle of the dump (which I have seen a couple of times in my DBA career) you may have to skip to position 98 (MySQL 5.0) or 106 (MySQL 5.1) or 107 (MySQL 5.5) of the master's next binary log and start replicating from there (SOB :( you may need to use MAATKIT tools mk-table-checksum and mk-table-sync to reload master changes not on the slave [if you want to be a hero]; even worse, mysqldump the master and reload the slave and start replication totally over [if you don't want to be a hero])
If the mysqlbinlog of the master is completely readable after the top gibberish you saw, it is possible the master's binary log is fine but the relay log on the slave is corrupt (due to transmission/CRC errors). If that's the case, just reload the relay logs by issuing the CHANGE MASTER TO command as follows:
STOP SLAVE;
CHANGE MASTER TO
MASTER_HOST='< master-host ip or DNS >',
MASTER_PORT=3306,
MASTER_USER='< usernmae >',
MASTER_PASSWORD='< password >',
MASTER_LOG_FILE='< MMMM >',
MASTER_LOG_POS=< PPPP >;
START SLAVE;
Where
- MMMM is the last file used from the Master that was last processed on the Slave
- PPPP is the last position used from the Master that was last processed on the Slave
You can get MMMM and PPPP by doing SHOW SLAVE STATUS\G
and using
- Relay_Master_Log_File for MMMM
- Exec_Master_Log_Pos for PPPP
Try it out and let me know !!!
BTW running CHANGE MASTER TO command erases the slave's current relay logs and starts fresh.
The simple answer is No.
In Mysql replication, Master copies the bin log files to slaves, and after that, it's work is over. Now the Slave will run the bin files and execute them, but there won't be any performance on Master.
There might be scenario where you are using full synchronous replication, in which master will wait for the slave to execute the query, but again it won't impact the performance in terms of memory or CPU, but the master will wait for the query to be executed.
Also, for your second question, Phil already answered it, that ssh sends data through encryption which uses a lot of CPU, hence if you want other ways, use the other methods which are described by Phil.
Best Answer
Whenever a Slave loses network connectivity, the IO thread simply dies and tries to reconnect every 60 seconds. You did the right thing in pointing the Slave back but let's clarify what to use to point back with.
For the give
SHOW SLAVE STATUS\G
WHAT YOU SHOULD NOT PICK
Master_Log_File
represents the log file containing the last successfully executed SQL statement on the Master that was recorded in the Slave's Relay Logs.Read_Master_Log_Pos
represents the position withinMaster_Log_File
of the last successfully executed SQL statement on the Master that was recorded in the Slave's Relay Logs.WHAT YOU SHOULD PICK
Relay_Master_Log_File
represents the log file containing the last successfully executed SQL statement on the Master that was executed on the Slave.Exec_Master_Log_Pos
represents the position withinRelay_Master_Log_File
of the last successfully executed SQL statement on the Master that was executed on the Slave.In most cases, when caught early enough,
Master_Log_File
andRelay_Master_Log_File
are the same. When there is significant replication lag or if the SQL thread breaks and the IO Thread keeps collecting,Master_Log_File
andRelay_Master_Log_File
will be different.CONCLUSION
ALWAYS PICK
Relay_Master_Log_File
andExec_Master_Log_Pos
as a restart point.Here are my other posts that reemphasize this paradigm:
Dec 05, 2011
: Does `Seconds_Behind_Master` show exact Slave Lag from Master?Jan 04, 2012
: MySQL Slave replication: Need to determine where replication left off to start slave in correct locationJan 24, 2012
: Mysql master-master replication auto flush old logs (Under Reason #3)Apr 04, 2012
: Seconds Behind Master in Cloud ServiceCAVEAT #1
Please do not be concerned with binlog rotation on the Master when it comes to Replication's status. The Slave's IO Thread is very sensitive to the Master's change. Here is how you can verify this:
STEP 01 : On the Slave, run
SHOW SLAVE STATUS\G
STEP 02 : On the Master
FLUSH LOGS;
orFLUSH BINARY LOGS;
FLUSH LOGS;
STEP 03 : On the Slave, run
SHOW SLAVE STATUS\G
You will see the
Master_Log_File
andRead_Master_Log_Pos
change immedaitely.CAVEAT #2
Since
Relay_Master_Log_File
has the most recent binary from the Master to be executed on the Slave, that's the log you keep on the Master. From the aboveSHOW SLAVE STATUS\G
, you would run