为什么 mysql slave 同步慢

  1. show slave status\G

  2. 查看 Relay_Log_File 字段, 得到 relay log 的文件名

  3. cd /var/lib/mysql

  4. mysqlbinlog mysqld-relay-bin.005347 > /tmp/mysqld-relay-bin.005347.txt

  5. grep 'update ' /tmp/mysqld-relay-bin.005347.txt | perl -ane 'END {foreach ( sort {$seen{$b}<=>$seen{$a}} keys %seen ) {print $_, "=>", $seen{$_}, "\n"} } $seen{$F[1]}++' # 找出哪个表更新的多

    grep 'insert into ' /tmp/mysqld-relay-bin.005347.txt | perl -ane 'END {foreach ( sort {$seen{$b}<=>$seen{$a}} keys %seen ) {print $_, "=>", $seen{$_}, "\n"} } $seen{$F[2]}++' # 找出哪个表插入的多


这篇文章: 有用 无用