本篇内容介绍了“怎么理解从库的IO线程”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

一、流程解析

start_slave->start_slave_threads->if(!mi->inited||!mi->rli->inited)//如果没有初始化{interror=(!mi->inited?ER_SLAVE_MI_INIT_REPOSITORY:ER_SLAVE_RLI_INIT_REPOSITORY);ER_SLAVE_MI_INIT_REPOSITORYER_SLAVE_RLI_INIT_REPOSITORY->if(mi->is_auto_position()&&(thread_mask&SLAVE_IO)&&get_gtid_mode(GTID_MODE_LOCK_NONE)==GTID_MODE_OFF)ER_CANT_USE_AUTO_POSITION_WITH_GTID_MODE_OFFeng"Thereplicationreceiverthread%-.192scannotstartinAUTO_POSITIONmode:thisserveruses@@GLOBAL.GTID_MODE=OFF."->启动IO线程if(thread_mask&SLAVE_IO)is_error=start_slave_thread(#ifdefHAVE_PSI_INTERFACEkey_thread_slave_io,#endifhandle_slave_io,lock_io,lock_cond_io,cond_io,&mi->slave_running,&mi->slave_run_id,mi);->mysql_thread_create建立线程回调函数handle_slave_io->handle_slave_io->初始化IO线程属性init_slave_thread进入状态THD_STAGE_INFO(thd,stage_waiting_for_master_update);->safe_connect进行连接主库->connect_to_master->将参数slave_net_timeout设置为IO线程连接超时和IO线程读取Event超时caseMYSQL_OPT_CONNECT_TIMEOUT://MYSQL_OPT_CONNECT_TIMEOUTmysql->options.connect_timeout=*(uint*)arg;break;caseMYSQL_OPT_READ_TIMEOUT://MYSQL_OPT_READ_TIMEOUTmysql->options.read_timeout=*(uint*)arg;break;->循环实现连接和重新连接->根据用户名、密码、IP、端口建立连接mysql_real_connect(mysql,mi->host,user,password,0,mi->port,0,client_flag)->如果连接失败循环重连每次打印日志mi->report(ERROR_LEVEL,last_errno,"error%stomaster'%s@%s:%d'""-retry-time:%dretries:%lu",(reconnect?"reconnecting":"connecting"),mi->get_user(),mi->host,mi->port,mi->connect_retry,err_count+1);if(++err_count==mi->retry_count){slave_was_killed=1;break;}slave_sleep(thd,mi->connect_retry,io_slave_killed,mi);//睡眠时间每次睡眠时间为MASTER_CONNECT_RETRY设置的时间,默认60秒,循环次数由MASTER_RETRY_COUNT指定默认86400次->get_master_version_and_clock->比较版本->发起命令SELECTUNIX_TIMESTAMP()获取主库时间mysql_real_query(mysql,STRING_WITH_LEN("SELECTUNIX_TIMESTAMP()计算差值用于延迟计算mi->clock_diff_with_master=(long)(time((time_t*)0)-strtoul(master_row[0],0,10));也就是说差值计算是在startslave命令发起的时候进行计算的,后面如果修改slave的服务器时间那么延迟计算将出现问题->发起命令SELECT@@GLOBAL.SERVER_ID获取主库serverid比较主库的serverid和本从库是否相同,如果相同则报错TheslaveI/Othreadstopsbecausemasterandslavehaveequal\MySQLserverids;theseidsmustbedifferentforreplicationtowork(or\the--replicate-same-server-idoptionmustbeusedonslavebutthisdoes\notalwaysmakesense;pleasecheckthemanualbeforeusingit).->发起命令SELECT@@GLOBAL.COLLATION_SERVER如果主库的这个值和备库不一致将会报错TheslaveI/Othreadstopsbecausemasterandslavehave\differentvaluesfortheCOLLATION_SERVERglobalvariable.Thevaluesmust\beequalfortheStatement-formatreplicationtowork->发起命令SELECT@@GLOBAL.TIME_ZONE老版本检测比较主库和从库的时区,如果不一致TheslaveI/Othreadstopsbecausemasterandslavehave\differentvaluesfortheTIME_ZONEglobalvariable.Thevaluesmust\beequalfortheStatement-formatreplicationtowork->发起命令SELECT@@GLOBAL.GTID_MODE比较主库和从库的GTIDMODE是否兼容if((slave_gtid_mode==GTID_MODE_OFF&&master_gtid_mode>=GTID_MODE_ON_PERMISSIVE)||(slave_gtid_mode==GTID_MODE_ON&&master_gtid_mode<=GTID_MODE_OFF_PERMISSIVE)){mi->report(ERROR_LEVEL,ER_SLAVE_FATAL_ERROR,"Thereplicationreceiverthreadcannotstartbecause""themasterhasGTID_MODE=%.192sandthisserverhas""GTID_MODE=%.192s.",get_gtid_mode_string(master_gtid_mode),get_gtid_mode_string(slave_gtid_mode));DBUG_RETURN(1);}if(mi->is_auto_position()&&master_gtid_mode!=GTID_MODE_ON){mi->report(ERROR_LEVEL,ER_SLAVE_FATAL_ERROR,"Thereplicationreceiverthreadcannotstartin""AUTO_POSITIONmode:themasterhasGTID_MODE=%.192s""insteadofON.",get_gtid_mode_string(master_gtid_mode));DBUG_RETURN(1);}->回到handle_slave_io->get_master_uuid获取主句UUID比较UUID发起命令SELECT@@GLOBAL.SERVER_UUID比较主库和备库的UUID如果相同报错"TheslaveI/Othreadstopsbecausemasterandslavehaveequal""MySQLserverUUIDs;theseUUIDsmustbedifferentfor""replicationtowork."->io_thread_init_commandsSET@slave_uuid='%s'是什么意思->register_slave_on_master进行注册主库调用register_slave进行注册注册完成后showslavehosts就能查询到了主库showslave会调用show_slave_hosts函数->request_dump发送需要读取的GTID或者位点信息给主库。如果是AUTOcom_binlog_dump_gtid-restirve_gtid+execute_gtidif(gtid_executed.add_gtid_set(mi->rli->get_gtid_set())!=RETURN_STATUS_OK||gtid_executed.add_gtid_set(gtid_state->get_executed_gtids())!=RETURN_STATUS_OK)-server_id主库读取(gdb)pgtid_string$17=0x7ffee400ef20"010fde77-2075-11e9-ba07-5254009862c0:1,\ncb7ea36e-670f-11e9-b483-5254008138e4:1-16"(gdb)pname$18='\000'<repeats16times>,"\v\000\000\000\a\000\000\000\000\t\000\344\376\177\000\000\340\252U\354\377\177\000\000\242kL\001\000\000\000\000\002\000\000\000\000\000\000\000\346?\001\000\000\000\000\002\000\000\000\000\000\000\000\346?\001\000\000\000\000\300\252U\354\377\177\000\000L?\001\n\000\000\000ЪU\354\377\177\000\000L?\001\000\000\000\000\360\252U\354\377\177\000\000\240\343\221\001\000\000\000\000\000\253U\354\377\177\000\000\340\b\000\344\376\177\000\000\020\253U\354\377\177\000\000\"I\353\001\000\000\000\000\000\t\000\344\376\177\000\000\240\255U\354\377\177\000\000\060\253U\354\377\177\000\000\272~\356\000\000\000\000\000\v\000\000\000\005\000\000\000\240\255U\354\377\177\000\000\000\256U\354\377\177\000\000\246\323M\001\000\000\000\000\221\333/\002\000\000\000\000\030=\000\344\376\177",'\000'<repeats18times>,"\002\000\000\000\000\000\000\000\346?\001\000\000\000\000\016\202\036\002\000\000\000\000\250"...(gdb)ppos$19=4不是AUTO-server_id-MASTERINFO表的读取位点-MASTERINFO表的读取binlog文件名主库读取com_binlog_dump(gdb)ppos$1=3587(gdb)ppacket+10$3=0x7ffedc00a88b"binlog.000005"我们可以看到即便开启了GTID不开启AUTO也不会根据GTID来读取。->循环读取event进入状态stage_waiting_for_master_to_send_event->将读取的event写入到relaylog进入状态Queueingmastereventtotherelaylog->queue_event读取的event写入到relaylog检测GTIDevent的合法性CannotreplicateGTID-transactionwhen@@GLOBAL.GTID_MODE=OFF,atfile%.512s,position%lld.CannotreplicateanonymoustransactionwhenAUTO_POSITION=1,atfile%.512s,position%lld.Cannotreplicateanonymoustransactionwhen@@GLOBAL.GTID_MODE=ON,atfile%.512s,position%lld.->rli->relay_log.append_buffer进行relaylog写入->MYSQL_BIN_LOG::after_append_to_relay_log//进行写入后处理->flush_and_sync函数根据relaylogsync参数设置决定是否做sync操作单位是event个数->MYSQL_BIN_LOG::sync_binlog_file判断是否进行刷盘->can_rotate根据这个值决定是否计入Retrieved_Gtid_Set边界分析器->进行relaylog切换->更改相关被变量master位置/master文件增加容量log_space_totalmi->set_master_log_pos(mi->get_master_log_pos()+inc_pos);//增加master位置rli->relay_log.harvest_bytes_written(&rli->log_space_total);/*IfthiseventisGTID_LOG_EVENTwestoreitsGTIDtoaddtotheRetrieved_Gtid_Setlater,whenthelasteventofthetransactionbequeued.*/if(event_type==binary_log::GTID_LOG_EVENT){mi->set_last_gtid_queued(gtid);}->flush_master_info(mi,FALSE)->Rpl_info_table::do_flush_info通过参数sync_master设置决定多少个event进行写tablehandler->set_sync_period(sync_masterinfo_period);if(!(force||(sync_period&&++(sync_counter)>=sync_period)))//如果没有达到sync的次数(sync_master_info或者sync_relay_log_info次数不做flush不写表直接返回)DBUG_RETURN(0);//但是relay_log_info依赖于是否是table模式如果是table模式则会在commit的时候做相应的flushSlave_worker::flush_info二、证明sync_master_info单位是Event

设置sync_master_info=1

主库做一个大事务,观察slave_master_info表如下:

mysql>select*fromslave_master_info\G;***************************1.row***************************Number_of_lines:25Master_log_name:binlog.000002Master_log_pos:1222540

主库执行:

/mysqldata/mysql3340/bin/mysqlbinlogbinlog.000002--base64-output='decode-rows'|grep-C10-E"BEGIN|COMMIT"

主库event 可以看到在中间

BEGIN/*!*/;#at992468#19051913:07:26serverid413340end_log_pos992520CRC320x5d85ea03Table_map:`testmts`.`testio`mappedtonumber111#at992520#19051913:07:26serverid413340end_log_pos1000735CRC320xfceb6697Write_rows:tableid111#at1000735#19051913:07:26serverid413340end_log_pos1008950CRC320x0ca6515cWrite_rows:tableid111#at1008950#19051913:07:26serverid413340end_log_pos1017165CRC320x21d7b17dWrite_rows:tableid111#at1017165--#at2939475#19051913:07:26serverid413340end_log_pos2947690CRC320xcb553fabWrite_rows:tableid111#at2947690#19051913:07:26serverid413340end_log_pos2955905CRC320xd42382c9Write_rows:tableid111#at2955905#19051913:07:26serverid413340end_log_pos2964120CRC320xe516b98aWrite_rows:tableid111#at2964120#19051913:07:26serverid413340end_log_pos2967035CRC320x9cbfbc0aWrite_rows:tableid111flags:STMT_END_F#at2967035#19051913:07:26serverid413340end_log_pos2967066CRC320xb907da17Xid=45COMMIT/*!*/;SET@@SESSION.GTID_NEXT='AUTOMATIC'/*addedbymysqlbinlog*//*!*/;DELIMITER;#Endoflogfile/*!50003SETCOMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;/*!50530SET@@SESSION.PSEUDO_SLAVE_MODE=0*/;Youhavemailin/var/spool/mail/root三、测试AUTO_POSITION=1和POSTION模式下MysqlD异常重启的恢复过程

下面是 recover_relay_log=0 的情况 POS和GTID AUTO_POSITION=1不同的处理。

断点

Master_info::set_master_log_pos设置masterinfoiothread读取主库的binlogposRelay_log_info::set_group_relay_log_pos设置relayinfosqlthread从库读取relaypos的位置

GTID
AUTO_POSITION binlog recover_relay_log=0的情况下:
DUMP线程会重新发送最后一个事务给从库,从库使用Crash前的Relay_Log_Pos进行读取。relay log可能出现不完整的事务。这种情况会触发回滚机制。单线程会在GTID event 中回滚,MTS会由协调线程调用coord_handle_partial_binlogged_transaction回滚

changemastertomaster_host='192.168.99.41',master_user='repl',master_password='gelc123',master_port=3340,AUTO_POSITION=1;startslave;

主库:

#at912#19051921:22:16serverid413340end_log_pos977CRC320x5840ca71GTIDlast_committed=1sequence_number=2rbr_only=yes/*!50718SETTRANSACTIONISOLATIONLEVELREADCOMMITTED*//*!*/;SET@@SESSION.GTID_NEXT='cb7ea36e-670f-11e9-b483-5254008138e4:2'/*!*/;#at977#19051921:22:16serverid413340end_log_pos1052CRC320xcd8345deQuerythread_id=3exec_time=13error_code=0SETTIMESTAMP=1558272136/*!*/;BEGIN/*!*/;#at1052#19051921:22:16serverid413340end_log_pos1104CRC320x782391ddTable_map:`testmts`.`testgp`mappedtonumber108#at1104#19051921:22:16serverid413340end_log_pos9319CRC320x8de0fbddWrite_rows:tableid108#at9319#19051921:22:16serverid413340end_log_pos17534CRC320xae798162Write_rows:tableid108#at17534#19051921:22:16serverid413340end_log_pos25749CRC320x683b9e95Write_rows:tableid108#at25749--#at477574#19051921:22:16serverid413340end_log_pos485789CRC320x44e99850Write_rows:tableid108#at485789#19051921:22:16serverid413340end_log_pos494004CRC320x280300fdWrite_rows:tableid108#at494004#19051921:22:16serverid413340end_log_pos502219CRC320x075c8ff8Write_rows:tableid108#at502219#19051921:22:16serverid413340end_log_pos503274CRC320x08c3f96cWrite_rows:tableid108flags:STMT_END_F#at503274#19051921:22:16serverid413340end_log_pos503305CRC320x3b6dd31cXid=26COMMIT/*!*/;SET@@SESSION.GTID_NEXT='AUTOMATIC'/*addedbymysqlbinlog*//*!*/;DELIMITER;

mysql>showslavestatus\G***************************1.row***************************Slave_IO_State:QueueingmastereventtotherelaylogMaster_Host:192.168.99.41Master_User:replMaster_Port:3340Connect_Retry:60Master_Log_File:binlog.000001Read_Master_Log_Pos:165404Relay_Log_File:relay.000002Relay_Log_Pos:1119Relay_Master_Log_File:binlog.000001Slave_IO_Running:YesSlave_SQL_Running:Yes

crash 后

mysql>showslavestatus\G***************************1.row***************************Slave_IO_State:Master_Host:192.168.99.41Master_User:replMaster_Port:3340Connect_Retry:60Master_Log_File:binlog.000001Read_Master_Log_Pos:190049Relay_Log_File:relay.000002Relay_Log_Pos:1119Relay_Master_Log_File:binlog.000001

不完整的事物日志如下:

#at1119#19051921:22:16serverid413340end_log_pos977CRC320x5840ca71GTIDlast_committed=1sequence_number=2rbr_only=yes/*!50718SETTRANSACTIONISOLATIONLEVELREADCOMMITTED*//*!*/;SET@@SESSION.GTID_NEXT='cb7ea36e-670f-11e9-b483-5254008138e4:2'/*!*/;#at1184#19051921:22:16serverid413340end_log_pos1052CRC320xcd8345deQuerythread_id=3exec_time=13error_code=0SETTIMESTAMP=1558272136/*!*/;BEGIN/*!*/;#at1259#19051921:22:16serverid413340end_log_pos1104CRC320x782391ddTable_map:`testmts`.`testgp`mappedtonumber108#at1311#19051921:22:16serverid413340end_log_pos9319CRC320x8de0fbddWrite_rows:tableid108#at9526#19051921:22:16serverid413340end_log_pos17534CRC320xae798162Write_rows:tableid108#at17741#19051921:22:16serverid413340end_log_pos25749CRC320x683b9e95Write_rows:tableid108#at25956WARNING:TherangeofprintedeventsendswitharoweventoratablemapeventthatdoesnothavetheSTMT_END_Fflagset.Thismightbebecausethelaststatementwasnotfullywrittentothelog,orbecauseyouareusinga--stop-positionor--stop-datetimethatreferstoaneventinthemiddleofastatement.Theevent(s)fromthepartialstatementhavenotbeenwrittentooutput.

启动后 IO_THREAD

mysql>showslavestatus\G***************************1.row***************************Slave_IO_State:WaitingformastertosendeventMaster_Host:192.168.99.41Master_User:replMaster_Port:3340Connect_Retry:60Master_Log_File:binlog.000001Read_Master_Log_Pos:503305Relay_Log_File:relay.000002Relay_Log_Pos:1119Relay_Master_Log_File:binlog.000001Slave_IO_Running:YesSlave_SQL_Running:No

启动IO TRHEAD后 重新传输了,但是老的没有完全传输完成的日志还在relay log
新的日志已经有了 ,老的也还在。

#at445#19051921:22:16serverid413340end_log_pos977CRC320x5840ca71GTIDlast_committed=1sequence_number=2rbr_only=yes/*!50718SETTRANSACTIONISOLATIONLEVELREADCOMMITTED*//*!*/;SET@@SESSION.GTID_NEXT='cb7ea36e-670f-11e9-b483-5254008138e4:2'/*!*/;#at510#19051921:22:16serverid413340end_log_pos1052CRC320xcd8345deQuerythread_id=3exec_time=13error_code=0SETTIMESTAMP=1558272136/*!*/;SET@@session.pseudo_thread_id=3/*!*/;SET@@session.foreign_key_checks=1,@@session.sql_auto_is_null=0,@@session.unique_checks=1,@@session.autocommit=1/*!*/;SET@@session.sql_mode=1075838976/*!*/;SET@@session.auto_increment_increment=1,@@session.auto_increment_offset=1/*!*/;/*!\Cutf8*//*!*/;SET@@session.character_set_client=83,@@session.collation_connection=83,@@session.collation_server=33/*!*/;SET@@session.lc_time_names=0/*!*/;SET@@session.collation_database=DEFAULT/*!*/;BEGIN/*!*/;#at585#19051921:22:16serverid413340end_log_pos1104CRC320x782391ddTable_map:`testmts`.`testgp`mappedtonumber108#at637#19051921:22:16serverid413340end_log_pos9319CRC320x8de0fbddWrite_rows:tableid108#at8852#19051921:22:16serverid413340end_log_pos17534CRC320xae798162Write_rows:tableid108#at17067#19051921:22:16serverid413340end_log_pos25749CRC320x683b9e95Write_rows:tableid108(以上本来已经传输了)#at25282--#at477107#19051921:22:16serverid413340end_log_pos485789CRC320x44e99850Write_rows:tableid108#at485322#19051921:22:16serverid413340end_log_pos494004CRC320x280300fdWrite_rows:tableid108#at493537#19051921:22:16serverid413340end_log_pos502219CRC320x075c8ff8Write_rows:tableid108#at501752#19051921:22:16serverid413340end_log_pos503274CRC320x08c3f96cWrite_rows:tableid108flags:STMT_END_F#at502807#19051921:22:16serverid413340end_log_pos503305CRC320x3b6dd31cXid=26COMMIT/*!*/;

POSITION
在 recover_relay_log=0的情况下从库会从Read_Master_Log_Pos的位置接着拉取replay log,一旦Read_Master_Log_Pos和replay log出现问题那么将会导致从库异常。主库只需要从Relay_Log_Pos的位置应用即可。因此参数

sync_relay_log=1

sync_master_info=1
是必须的。

changemastertomaster_host='192.168.99.41',master_user='repl',master_password='gelc123',master_port=3340,MASTER_LOG_FILE='binlog.000001',MASTER_LOG_POS=154;startslave;

mysql>showslavestatus\G;***************************1.row***************************Slave_IO_State:WaitingformastertosendeventMaster_Host:192.168.99.41Master_User:replMaster_Port:3340Connect_Retry:60Master_Log_File:binlog.000001Read_Master_Log_Pos:912Relay_Log_File:relay.000002Relay_Log_Pos:1075Relay_Master_Log_File:binlog.000001Slave_IO_Running:YesSlave_SQL_Running:Yes

写入途中:

mysql>showslavestatus\G;***************************1.row***************************Slave_IO_State:QueueingmastereventtotherelaylogMaster_Host:192.168.99.41Master_User:replMaster_Port:3340Connect_Retry:60Master_Log_File:binlog.000001Read_Master_Log_Pos:124329Relay_Log_File:relay.000002Relay_Log_Pos:1075Relay_Master_Log_File:binlog.000001Slave_IO_Running:YesSlave_SQL_Running:Yes

主库binlog:

BEGIN/*!*/;#at1052#19051916:43:43serverid413340end_log_pos1104CRC320x1b959719Table_map:`testmts`.`testgp`mappedtonumber108#at1104#19051916:43:43serverid413340end_log_pos9319CRC320x98ff5e73Write_rows:tableid108#at9319#19051916:43:43serverid413340end_log_pos17534CRC320xbb6624ccWrite_rows:tableid108#at17534#19051916:43:43serverid413340end_log_pos25749CRC320x7d243b3bWrite_rows:tableid108#at25749--#at477574#19051916:43:43serverid413340end_log_pos485789CRC320x51f63dfeWrite_rows:tableid108#at485789#19051916:43:43serverid413340end_log_pos494004CRC320x3d1ca553Write_rows:tableid108#at494004#19051916:43:43serverid413340end_log_pos502219CRC320x12432a56Write_rows:tableid108#at502219#19051916:43:43serverid413340end_log_pos503274CRC320x4373f461Write_rows:tableid108flags:STMT_END_F#at503274#19051916:43:43serverid413340end_log_pos503305CRC320xe33a6266Xid=60COMMIT/*!*/;

Crash启动后日志如下:

#at321652#19051916:43:43serverid413340end_log_pos329704CRC320xbf87ced1Write_rows:tableid108#at329867#19051916:43:43serverid413340end_log_pos337919CRC320x2f3bd840Write_rows:tableid108#at338082#19051916:43:43serverid413340end_log_pos346134CRC320xe317c093Write_rows:tableid108#at346297#19051916:43:43serverid413340end_log_pos354349CRC320x81e3ea0dWrite_rows:tableid108#at354512#19051916:43:43serverid413340end_log_pos362564CRC320x7f51fc3aWrite_rows:tableid108#at362727#19051916:25:17serverid953340end_log_pos362770CRC320xb6611a85Rotatetorelay.000003pos:4WARNING:TherangeofprintedeventsendswitharoweventoratablemapeventthatdoesnothavetheSTMT_END_Fflagset.Thismightbebecausethelaststatementwasnotfullywrittentothelog,orbecauseyouareusinga--stop-positionor--stop-datetimethatreferstoaneventinthemiddleofastatement.Theevent(s)fromthepartialstatementhavenotbeenwrittentooutput.ROLLBACK/*addedbymysqlbinlog*//*!*/;SET@@SESSION.GTID_NEXT='AUTOMATIC'/*addedbymysqlbinlog*//*!*/;DELIMITER;#Endoflogfile/*!50003SETCOMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;/*!50530SET@@SESSION.PSEUDO_SLAVE_MODE=0*/;[root@gp1log]#/mysqldata/mysql3340/bin/mysqlbinlog--base64-output='decode-rows'relay.000003/*!50530SET@@SESSION.PSEUDO_SLAVE_MODE=1*/;/*!50003SET@OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;DELIMITER/*!*/;#at4#19051916:25:17serverid953340end_log_pos123CRC320xe6fd01bfStart:binlogv4,serverv5.7.22-22-debug-logcreated19051916:25:17#ThisFormat_description_eventappearsinarelaylogandwasgeneratedbytheslavethread.#at123#19051916:25:17serverid953340end_log_pos154CRC320xde5482b5Previous-GTIDs#[empty]#at154#7001018:00:00serverid413340end_log_pos0CRC320x86e86060Rotatetobinlog.000001pos:362564#at198#19051916:42:31serverid413340end_log_pos0CRC320x5361aca0Start:binlogv4,serverv5.7.22-22-debug-logcreated19051916:42:31#at317#19051916:43:43serverid413340end_log_pos370779CRC320x8b7abae8Write_rows:tableid108#at8532#19051916:43:43serverid413340end_log_pos378994CRC320x28e1279cWrite_rows:tableid108#at16747#19051916:43:43serverid413340end_log_pos387209CRC320x278d98edWrite_rows:tableid108#at24962#19051916:43:43serverid413340end_log_pos395424CRC320x85d21655Write_rows:tableid108#at33177#19051916:43:43serverid413340end_log_pos403639CRC320x156e00c4Write_rows:tableid108#at41392#19051916:43:43serverid413340end_log_pos411854CRC320xed83b3acWrite_rows:tableid108#at49607#19051916:43:43serverid413340end_log_pos420069CRC320x465939b4Write_rows:tableid108#at57822#19051916:43:43serverid413340end_log_pos428284CRC320xaab146d2Write_rows:tableid108#at66037#19051916:43:43serverid413340end_log_pos436499CRC320x97f1428fWrite_rows:tableid108WARNING:TherangeofprintedeventsendswitharoweventoratablemapeventthatdoesnothavetheSTMT_END_Fflagset.Thismightbebecausethelaststatementwasnotfullywrittentothelog,orbecauseyouareusinga--stop-positionor--stop-datetimethatreferstoaneventinthemiddleofastatement.Theevent(s)fromthepartialstatementhavenotbeenwrittentooutput.SET@@SESSION.GTID_NEXT='AUTOMATIC'/*addedbymysqlbinlog*//*!*/;DELIMITER;#Endoflogfile/*!50003SETCOMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;/*!50530SET@@SESSION.PSEUDO_SLAVE_MODE=0*/;[root@gp1log]#/mysqldata/mysql3340/bin/mysqlbinlog--base64-output='decode-rows'relay.000005/*!50530SET@@SESSION.PSEUDO_SLAVE_MODE=1*/;/*!50003SET@OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;DELIMITER/*!*/;#at4#19051916:31:57serverid953340end_log_pos123CRC320xecc598acStart:binlogv4,serverv5.7.22-22-debug-logcreated19051916:31:57#ThisFormat_description_eventappearsinarelaylogandwasgeneratedbytheslavethread.#at123#19051916:31:57serverid953340end_log_pos154CRC320x21c8a43aPrevious-GTIDs#[empty]#at154#7001018:00:00serverid413340end_log_pos0CRC320xeed34528Rotatetobinlog.000001pos:428284#at198#19051916:42:31serverid413340end_log_pos0CRC320x5361aca0Start:binlogv4,serverv5.7.22-22-debug-logcreated19051916:42:31#at317#19051916:43:43serverid413340end_log_pos436499CRC320x97f1428fWrite_rows:tableid108#at8532#19051916:43:43serverid413340end_log_pos444714CRC320xfd447f7dWrite_rows:tableid108#at16747#19051916:43:43serverid413340end_log_pos452929CRC320xc4c67bffWrite_rows:tableid108#at24962#19051916:43:43serverid413340end_log_pos461144CRC320x6dbd096aWrite_rows:tableid108#at33177#19051916:43:43serverid413340end_log_pos469359CRC320xb42d58b6Write_rows:tableid108#at41392#19051916:43:43serverid413340end_log_pos477574CRC320x7a2e502dWrite_rows:tableid108#at49607#19051916:43:43serverid413340end_log_pos485789CRC320x51f63dfeWrite_rows:tableid108#at57822#19051916:43:43serverid413340end_log_pos494004CRC320x3d1ca553Write_rows:tableid108#at66037#19051916:43:43serverid413340end_log_pos502219CRC320x12432a56Write_rows:tableid108#at74252#19051916:43:43serverid413340end_log_pos503274CRC320x4373f461Write_rows:tableid108flags:STMT_END_F#at75307#19051916:43:43serverid413340end_log_pos503305CRC320xe33a6266Xid=60COMMIT/*!*/;SET@@SESSION.GTID_NEXT='AUTOMATIC'/*addedbymysqlbinlog*//*!*/;

从 end_log_pos 可以看到他们凑成了一个完整的事务日志。

“怎么理解从库的IO线程”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!