手机版
你好,游客 登录 注册
背景:
阅读新闻

PostgreSQL启动恢复期间,恢复到的时间线的确定

[日期:2019-02-25] 来源:Linux社区  作者:yanzongshuai [字体: ]

1、启动恢复时,确定恢复到的时间线recoveryTargetTLI

 1)归档恢复点比checkpoint中记录的时间线大,那么选择归档恢复点作为目标时间线

 2)否则,checkpoint记录中的时间线作为目标时间线

StartupXLOG->
 if (ControlFile->minRecoveryPointTLI >
  ControlFile->checkPointCopy.ThisTimeLineID)
  recoveryTargetTLI = ControlFile->minRecoveryPointTLI;
 else
  recoveryTargetTLI = ControlFile->checkPointCopy.ThisTimeLineID;
 ...

2、接着从recovery.conf文件中读取

 1)若设置了recovery_target_timeline值,并且设为latest,那么history列表最大的时间线即为目标时间线

 2)否则是recovery.conf文件中设置的时间线值

 3)若没有设置recovery_target_timeline值,则目标时间线为第一步中的值

StartupXLOG->readRecoveryCommandFile()->
 for (item = head; item; item = item->next){
  if (strcmp(item->name, "restore_command") == 0){
   ...
  }else if ...
  else if(strcmp(item->name, "recovery_target_timeline") == 0){
   rtliGiven = true;
   if (strcmp(item->value, "latest") == 0)
    rtli = 0;
   else
    rtli = (TimeLineID) strtoul(item->value, NULL, 0);
  }else if...
 }
 if (rtliGiven){
  if (rtli){
   recoveryTargetTLI = rtli;
   recoveryTargetIsLatest = false;
  }else{
   /* We start the "latest" search from pg_control's timeline */
   recoveryTargetTLI = findNewestTimeLine(recoveryTargetTLI);
   recoveryTargetIsLatest = true;
  }
 }

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

本文永久更新链接地址https://www.linuxidc.com/Linux/2019-02/157096.htm

linux
相关资讯       PostgreSQL启动 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款