标签:mysql
change_master->global_init_info->Master_info::mi_init_info->Rpl_info_handler::init_info->Rpl_info_file::do_init_info ->mi->rli->rli_init_info()->初始化./relay-bin.000001,4如果relay-log.info不存在的话,否则读取
//初始化master_info结构 int Master_info::mi_init_info() { if (inited) DBUG_RETURN(0);//如果已经创建master_info文件,直接退出 handler->init_info();//创建/打开master_info文件 if (check_return == REPOSITORY_DOES_NOT_EXIST){//如果master_info文件是刚创建的,设置需读取的log位置是4 init_master_log_pos(); |--master_log_name[0]= 0; |--master_log_pos= BIN_LOG_HEADER_SIZE; |--ssl_verify_server_cert= 0; |-- heartbeat_period= min<float>(SLAVE_MAX_HEARTBEAT_PERIOD,(slave_net_timeout/2.0)); }else{ read_info(handler);//读取文件 } inited= 1; flush_info(TRUE); |--handler->set_sync_period(sync_masterinfo_period);//默认10000 |--flush_io_cache(&info_file); |--my_sync(info_fd, MYF(MY_WME)); DBUG_RETURN(0);
int Rpl_info_file::do_init_info() { if (ret_check == REPOSITORY_DOES_NOT_EXIST){ info_fd = my_open(info_fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME)); init_io_cache(&info_file, info_fd, IO_SIZE*2, READ_CACHE, 0L,0,MYF(MY_WME)); }else if (ret_check == REPOSITORY_EXISTS){ info_fd = my_open(info_fname, O_RDWR|O_BINARY, MYF(MY_WME)); init_io_cache(&info_file, info_fd, IO_SIZE*2, READ_CACHE, 0L,0, MYF(MY_WME)) } }
如果master.info不存在,就创建并初始化对应的IO_CACHE
如果存在,就打开,并初始化对应的IO_CACHE
本文出自 “yanzongshuai的专栏” 博客,请务必保留此出处http://yanzongshuai.blog.51cto.com/3057928/1970302
标签:mysql
原文地址:http://yanzongshuai.blog.51cto.com/3057928/1970302