问题:MYSQL宕机,如何寻找主库binlog和pos点???

问题:主库宕机,从库如何同步主库的binlog???

 

步骤一:找到binlog日志,可以到/etc/my.cnf中查看binlog日志。
       
步骤二:查看mysql-bin.index文件,看看目前最新binlog日志是哪个。
        [root@localhost data]# cat  mysql-bin.index
          /application/mysql-5.5.32/data/mysql-bin.000001
         /application/mysql-5.5.32/data/mysql-bin.000002
        /application/mysql-5.5.32/data/mysql-bin.000003
步骤三 :通过mysql-bin.index文件了解,当前最新binlog文件是mysql-bin.000003,
         通过mysqlbinlog命令查看,mysql-bin.000003
          [root@localhost data]# mysqlbinlog mysql-bin.000003
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#160803 16:10:35 server id 1  end_log_pos 107   Start: binlog v 4, server v 5.5.32-log created 160803

16:10:35 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
BINLOG '
+6ahVw8BAAAAZwAAAGsAAAABAAQANS41LjMyLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAD7pqFXEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA==
'/*!*/;
# at 107
#160803 16:11:54 server id 1  end_log_pos 188   Query   thread_id=1     exec_time=0     error_code=0
SET TIMESTAMP=1470211914/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1,

@@session.autocommit=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
SET

@@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
drop database mama
/*!*/;
DELIMITER ;
# End of log file
总结:在从库中输入命令 CHANGE MASTER TO 用到该信息:mysql-bin.000003 ,POS点188