MySQL複製--slave設定讀取binlog的位置

來源:互聯網
上載者:User

標籤: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複製--slave設定讀取binlog的位置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.