使用 db2adutl 来恢复数据

您可以使用 db2adutl 命令, logarchopt1vendoropt 数据库配置参数来执行跨节点恢复。 在来自几个不同 Tivoli® Storage Manager (TSM) 环境的示例中演示了此恢复。

注: Tivoli Storage Manager (TSM) V 7.1.8+ 和 V 8.1.2+ 引入了显着增强功能,以提高客户机与服务器通信之间的安全性。 从 7.1.8 和 8.1.2 开始,可信通信代理程序 (TCA) 不再可用,用户必须以能够访问节点密码的授权用户身份来配置每个 Db2 实例。 下面所提供的示例假定正在使用旧的 TCA 认证方法,该认证方法需要在 LOGARCHOPT1 和 VENDOROPT 数据库配置选项中指定‘-fromowner=<owner>’选项或者 TSM OPTIONS 复原选项,以便执行跨节点恢复。 当使用授权用户方法时,应该省略‘-fromowner=<owner>’选项。 有关在授权用户访问模型中使用跨节点恢复技术的更多详细信息,请参阅 从 7.1.8 和 8.1.2开始的 IBM Spectrum Protect (以前称为 Tivoli Storage Manager) 客户机版本所需的配置更改。
对于以下示例,计算机 1 称为 bar ,并且正在运行 AIX® 操作系统。 此机器上的用户是 roeckenbar 上的数据库名为 zample。 计算机 2 名为 dps。 此计算机还在运行 AIX 操作系统,用户为 regress9

示例 1:TSM 服务器自动管理密码(PASSWORDACCESS 选项设置为 GENERATE)

此跨节点恢复示例显示如何设置两台计算机,以便当日志归档和备份都存储在 TSM 服务器上且在该服务器上使用 PASSWORDACCESS=GENERATE 选项管理密码时,您可以将数据从一台计算机恢复至另一台计算机。

注: 更新数据库配置后,可能必须对数据库进行脱机备份。
  1. 要为 bar 计算机到 TSM 服务器的日志归档启用数据库,请使用以下命令更新 zample 数据库的数据库配置参数 logarchmeth1 :
       bar:/home/roecken> db2 update db cfg for zample using LOGARCHMETH1 tsm
    将返回以下信息:
       DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
  2. 使用下列命令从数据库断开所有用户和应用程序的连接:
       db2 force applications all
  3. 使用下列命令验证是否已没有应用程序连接到数据库:
       db2 list applications
    您应该会接收到一条消息,说明未返回任何数据。
    注: 在分区数据库环境中,必须对所有数据库分区执行此步骤。
  4. 使用下列命令在 TSM 服务器上创建数据库备份:
       db2 backup db zample use tsm
    将返回类似以下的信息:
       Backup successful. The timestamp for this backup imagge is : 20090216151025
    注: 在分区数据库环境中,必须对所有数据库分区执行此步骤。 根据您正在执行联机备份还是脱机备份,在数据库分区上执行此步骤的顺序有所不同。 有关更多信息,请参阅 备份数据
  5. 使用下列命令连接至 zample 数据库:
       db2 connect to zample
  6. 通过使用下列命令创建一个表并将数据装入 TSM 服务器来生成数据库的新事务日志:
       bar:/home/roecken> db2 load from mr of del modified by noheader replace 
          into employee copy yes use tsm
    其中,在此示例中,表称为 employee,并且正在从名为 mr的定界 ASCII 文件装入数据。 指定了 COPY YES 选项以生成所装入数据的副本,而 USE TSM 选项指定数据的副本存储在 TSM 服务器上。
    注: 仅当为前滚恢复启用了数据库时,才能指定 COPY YES 选项; 即, logarchmeth1 数据库配置参数必须设置为 USEREXITLOGRETAINDISKTSM
    为了指示它的进度,LOAD 实用程序将返回一系列消息:
       SQL3109N  The utility is beginning to load data from file "/home/roecken/mr".
    
       SQL3500W  The utility is beginning the "LOAD" phase at time "02/16/2009 
       15:12:13.392633".
    
       SQL3519W  Begin Load Consistency Point. Input record count = "0".
    
       SQL3520W  Load Consistency Point was successful.
    
       SQL3110N  The utility has completed processing.  "1" rows were read from the 
       input file.
    
       SQL3519W  Begin Load Consistency Point. Input record count = "1".
    
       SQL3520W  Load Consistency Point was successful.
    
       SQL3515W  The utility has finished the "LOAD" phase at time "02/16/2009 
       15:12:13.445718".
    
    
       Number of rows read         = 1
       Number of rows skipped      = 0
       Number of rows loaded       = 1
       Number of rows rejected     = 0
       Number of rows deleted      = 0
       Number of rows committed    = 1
  7. 将数据装入表中后,请通过在 zample 数据库中运行下列查询来确认在 TSM 服务器上存在一个备份映像、一个装入副本映像和一个日志文件:
      bar:/home/roecken/sqllib/adsm> db2adutl query db zample
    将返回以下信息:
       Retrieving FULL DATABASE BACKUP information.
           1 Time: 20090216151025  Oldest log: S0000000.LOG  Log stream: 0    
           Sessions: 1  
    
       Retrieving INCREMENTAL DATABASE BACKUP information.
         No INCREMENTAL DATABASE BACKUP images found for ZAMPLE
    
       Retrieving DELTA DATABASE BACKUP information.
         No DELTA DATABASE BACKUP images found for ZAMPLE
    
       Retrieving TABLESPACE BACKUP information.
         No TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving INCREMENTAL TABLESPACE BACKUP information.
         No INCREMENTAL TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving DELTA TABLESPACE BACKUP information.
         No DELTA TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving LOAD COPY information.
           1 Time: 20090216151213
    
       Retrieving LOG ARCHIVE information.
          Log file: S0000000.LOG, Chain Num: 0, Log stream: 0, 
          Taken at: 2009-02-16-15.10.38
  8. 要启用跨节点恢复,必须允许另一台计算机和帐户访问与 bar 计算机相关联的对象。 在此示例中,使用下列命令允许计算机 dps 和用户 regress9 进行访问:
       bar:/home/roecken/sqllib/adsm> db2adutl grant user regress9 
          on nodename dps for db zample
    将返回以下信息:
       Successfully added permissions for regress9 to access ZAMPLE on node dps.
    注: 您可以通过发出以下命令来确认 db2adutl 授权操作的结果,以检索当前节点的当前访问列表:
       bar:/home/roecken/sqllib/adsm> db2adutl queryaccess
    将返回以下信息:
       Node                 Username             Database Name   Type
       --------------------------------------------------------------
       DPS                  regress9             ZAMPLE          A
       --------------------------------------------------------------
        Access Types:  B - backup images   L - logs   A - both
  9. 在此示例中,尚未设置计算机 2 dps 以用于 zample 数据库的跨节点恢复。 使用下列命令验证在 TSM 服务器上是否已没有数据与此用户和计算机相关联:
       dps:/home/regress9/sqllib/adsm> db2adutl query db zample      
    将返回以下信息:
         --- Database directory is empty ---
       Warning: There are no file spaces created by Db2 on the ADSM server
       Warning: No Db2 backup images found in ADSM for any alias.
    
  10. 使用下列命令查询 TSM 服务器以获得与用户 roecken 和计算机 bar 相关联的 zample 数据库的对象列表:
      dps:/home/regress9/sqllib/adsm> db2adutl query db zample nodename 
           bar owner roecken
    
    将返回以下信息:
       --- Database directory is empty ---
    
       Query for database ZAMPLE
    
       Retrieving FULL DATABASE BACKUP information.
           1 Time: 20090216151025  Oldest log: S0000000.LOG  Log stream: 0    
           Sessions: 1  
    
       Retrieving INCREMENTAL DATABASE BACKUP information.
         No INCREMENTAL DATABASE BACKUP images found for ZAMPLE
    
       Retrieving DELTA DATABASE BACKUP information.
         No DELTA DATABASE BACKUP images found for ZAMPLE
    
       Retrieving TABLESPACE BACKUP information.
         No TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving INCREMENTAL TABLESPACE BACKUP information.
         No INCREMENTAL TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving DELTA TABLESPACE BACKUP information.
         No DELTA TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving LOAD COPY information.
           1 Time: 20090216151213
    
       Retrieving LOG ARCHIVE information.
          Log file: S0000000.LOG, Chain Num: 0, Log stream: 0, 
          Taken at: 2009-02-16-15.10.38
    
    此信息与先前生成的 TSM 信息匹配,并确认可以将此映像复原到 dps 计算机上。
  11. 使用下列命令将 zample 数据库从 TSM 服务器复原到 dps 计算机:
       dps:/home/regress9> db2 restore db zample use tsm options 
       "'-fromnode=bar -fromowner=roecken'" without prompting
    
    将返回以下信息:
       DB20000I  The RESTORE DATABASE command completed successfully.
    注: 如果 dps上已存在 zample 数据库,那么将省略 OPTIONS 参数,并且将使用数据库配置参数 vendoropt 。 此配置参数将覆盖备份或复原操作的 OPTIONS 参数。
  12. 执行前滚操作以应用在创建新表并装入新数据时记录在 zample 数据库日志文件中的事务。 在此示例中,因为未指定用户和计算机信息而导致 ROLLFORWARD 实用程序找不到日志文件,所以前滚操作的下列尝试将失败:
       dps:/home/regress9> db2 rollforward db zample to end of logs and stop
    该命令会返回下列错误:
       SQL4970N  Roll-forward recovery on database "ZAMPLE" cannot reach the 
       specified stop point (end-of-log or point-in-time) because of missing log 
       file(s) on node(s) "0".
    使用适当的 logarchopt 值强制 ROLLFORWARD 实用程序查找与另一台计算机相关联的日志文件。 在此示例中,使用下列命令设置 logarchopt1 数据库配置参数并搜索与用户 roecken 和计算机 bar 相关联的日志文件:
       dps:/home/regress9> db2 update db cfg for zample using logarchopt1 
       "'-fromnode=bar -fromowner=roecken'"
  13. 通过使用下列命令来设置 vendoropt 数据库配置参数,使 ROLLFORWARD 实用程序能够使用备份和装入副本映像:
       dps:/home/regress9> db2 update db cfg for zample using VENDOROPT 
       "'-fromnode=bar -fromowner=roecken'"
  14. 使用下列命令通过应用记录在 zample 数据库日志文件中的事务来完成跨节点数据恢复:
       dps:/home/regress9> db2 rollforward db zample to end of logs and stop
    将返回以下信息:
                                        Rollforward Status
    
     Input database alias                   = zample
     Number of members have returned status = 1
    
    
     Member number  Rollforward  Next log to  Log files processed        Last committed transaction
                    status       be read                                 
     -------------  -----------  -----------  -------------------------  ------------------------------
             0      not pending               S0000000.LOG-S0000000.LOG  2009-05-06-15.28.11.000000 UTC
    
    
    DB20000I  The ROLLFORWARD command completed successfully.
    已将计算机 dps 上用户 regress9 下的数据库 zample 恢复到计算机 bar 上用户 roecken 下数据库的同一位置。

示例 2:密码由用户管理(PASSWORDACCESS 选项设置为 PROMPT)

此跨节点恢复示例显示如何设置两台计算机,以便当日志归档和备份都存储在 TSM 服务器上且在该服务器上由用户管理密码时,您可以将数据从一台计算机恢复至另一台计算机。 在这些环境中,需要额外的信息,特别是用于创建对象的计算机的 TSM 节点名和密码。

  1. 通过添加下列行来更新客户机 dsm.sys 文件,因为计算机 bar 是源计算机的名称
    NODENAME bar
    注: 在 Windows 操作系统上,此文件称为 dsm.opt 文件。 更新此文件时,必需重新引导系统才能使更改生效。
  2. 使用下列命令查询 TSM 服务器以获得与用户 roecken 和计算机 bar 相关联的对象列表:
       dps:/home/regress9/sqllib/adsm> db2adutl query db zample nodename bar 
       owner roecken password *******
    将返回以下信息:
       Query for database ZAMPLE
    
       Retrieving FULL DATABASE BACKUP information.
           1 Time: 20090216151025  Oldest log: S0000000.LOG  Log stream: 0    
           Sessions: 1  
    
       Retrieving INCREMENTAL DATABASE BACKUP information.
         No INCREMENTAL DATABASE BACKUP images found for ZAMPLE
    
       Retrieving DELTA DATABASE BACKUP information.
         No DELTA DATABASE BACKUP images found for ZAMPLE
    
       Retrieving TABLESPACE BACKUP information.
         No TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving INCREMENTAL TABLESPACE BACKUP information.
         No INCREMENTAL TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving DELTA TABLESPACE BACKUP information.
         No DELTA TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving LOAD COPY information.
           1 Time: 20090216151213
    
       Retrieving LOG ARCHIVE information.
          Log file: S0000000.LOG, Chain Num: 0, Log stream: 0, 
          Taken at: 2009-02-16-15.10.38
  3. 如果在计算机 dps 上不存在 zample 数据库,那么请执行下列步骤:
    1. 使用下列命令创建空数据库 zample
         dps:/home/regress9> db2 create db zample
    2. 使用下列命令来更新数据库配置参数 tsm_nodename
         dps:/home/regress9> db2 update db cfg for zample using tsm_nodename bar
    3. 使用下列命令来更新数据库配置参数 tsm_password
         dps:/home/regress9> db2 update db cfg for zample using 
         tsm_password ********
  4. 尝试使用下列命令复原 zample 数据库:
       dps:/home/regress9> db2 restore db zample use tsm options 
       "'-fromnode=bar -fromowner=roecken'" without prompting
    
    成功完成复原操作,但是发出了一条警告:
       SQL2540W  Restore is successful, however a warning "2523" was 
       encountered during Database Restore while processing in No 
       Interrupt mode.
  5. 使用下列命令来执行前滚操作:
       dps:/home/regress9> db2 rollforward db zample to end of logs and stop  
    在此示例中,由于复原操作替换了数据库配置文件,因此 ROLLFORWARD 实用程序找不到正确的日志文件并且将返回下列错误消息:
       SQL1268N  Roll-forward recovery stopped due to error "-2112880618" 
       while retrieving log file "S0000000.LOG" for database "ZAMPLE" on node "0".
    请将下列 TSM 数据库配置值重置为正确的值:
    1. 使用下列命令来设置 tsm_nodename 配置参数:
         dps:/home/regress9> db2 update db cfg for zample using tsm_nodename bar
    2. 使用下列命令来设置 tsm_password 数据库配置参数:
         dps:/home/regress9> db2 update db cfg for zample using tsm_password *******
    3. 使用下列命令来设置 logarchopt1 数据库配置参数,以便 ROLLFORWARD 实用程序可以找到正确的日志文件:
         dps:/home/regress9> db2 update db cfg for zample using logarchopt1 
         "'-fromnode=bar -fromowner=roecken'"
    4. 使用下列命令来设置 vendoropt 数据库配置参数,以便在前滚操作期间也可以使用装入恢复文件:
         dps:/home/regress9> db2 update db cfg for zample using VENDOROPT  
         "'-fromnode=bar -fromowner=roecken'"
  6. 通过使用下列命令来执行前滚操作,可以完成跨节点恢复:
       dps:/home/regress9> db2 rollforward db zample to end of logs and stop
    将返回以下信息:
                                        Rollforward Status
    
     Input database alias                   = zample
     Number of members have returned status = 1
    
    
     Member number  Rollforward  Next log to  Log files processed        Last committed transaction
                    status       be read                                 
     -------------  -----------  -----------  -------------------------  ------------------------------
             0      not pending               S0000000.LOG-S0000000.LOG  2009-05-06-15.28.11.000000 UTC
    
    
    DB20000I  The ROLLFORWARD command completed successfully.
已将计算机 dps 上用户 regress9 下的数据库 zample 恢复到计算机 bar 上用户 roecken 下数据库的同一位置

示例 3:TSM 服务器已配置为使用客户机代理节点

此跨节点恢复示例显示如何将两台计算机设置为代理节点,以便当日志归档和备份都存储在 TSM 服务器上且在该服务器上使用 PASSWORDACCESS=GENERATE 选项管理密码时,您可以将数据从一台计算机恢复至另一台计算机。

注: 更新数据库配置后,可能必须对数据库进行脱机备份。

在此示例中,计算机 bardps 注册在 clusternode 代理名称下。 这些计算机已经设置为代理节点。

  1. 使用下列命令将计算机 bardps 在 TSM 服务器上注册为代理节点:
    REGISTER NODE clusternode mypassword
    GRANT PROXYNODE TARGET=clusternode AGENT=bar,dps 
  2. 要启用数据库以将日志归档到 TSM 服务器,请使用以下命令更新 zample 数据库的数据库配置参数 logarchmeth1 :
       bar:/home/roecken> db2 update db cfg for zample using 
          LOGARCHMETH1 tsm logarchopt1 "'-asnodename=clusternode'"
    将返回以下信息:
       DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
  3. 使用下列命令从数据库断开所有用户和应用程序的连接:
       db2 force applications all
  4. 使用下列命令验证是否已没有应用程序连接到数据库:
       db2 list applications
    您应该会接收到一条消息,说明未返回任何数据。
    注: 在分区数据库环境中,必须对所有数据库分区执行此步骤。
  5. 使用下列命令在 TSM 服务器上创建数据库备份:
       db2 backup db zample use tsm options "'-asnodename=clusternode'"
    将返回类似以下的信息:
       Backup successful. The timestamp for this backup image is : 20090216151025
    您可以改为更新 vendoropt 数据库配置参数,而不是在 BACKUP DATABASE 命令上指定 -asnodename 选项。
    注: 在分区数据库环境中,必须对所有数据库分区执行此步骤。 根据您正在执行联机备份还是脱机备份,在数据库分区上执行此步骤的顺序有所不同。 有关更多信息,请参阅 备份数据
  6. 使用下列命令连接至 zample 数据库:
       db2 connect to zample
  7. 通过使用下列命令创建一个表并将数据装入 TSM 服务器来生成数据库的新事务日志:
    bar:/home/roecken> db2 load from mr of del modified by noheader 
    	replace into employee copy yes use tsm
    其中,在此示例中,表称为 employee,并且正在从名为 mr的定界 ASCII 文件装入数据。 指定了 COPY YES 选项以生成所装入数据的副本,而 USE TSM 选项指定数据的副本存储在 TSM 服务器上。
    注: 仅当为前滚恢复启用了数据库时,才能指定 COPY YES 选项; 即, logarchmeth1 数据库配置参数必须设置为 USEREXITLOGRETAINDISKTSM
    为了指示它的进度,LOAD 实用程序将返回一系列消息:
       SQL3109N  The utility is beginning to load data from file "/home/roecken/mr".
    
       SQL3500W  The utility is beginning the "LOAD" phase at time "02/16/2009 
       15:12:13.392633".
    
       SQL3519W  Begin Load Consistency Point. Input record count = "0".
    
       SQL3520W  Load Consistency Point was successful.
    
       SQL3110N  The utility has completed processing.  "1" rows were read from the 
       input file.
    
       SQL3519W  Begin Load Consistency Point. Input record count = "1".
    
       SQL3520W  Load Consistency Point was successful.
    
       SQL3515W  The utility has finished the "LOAD" phase at time "02/16/2009 
       15:12:13.445718".
    
    
       Number of rows read         = 1
       Number of rows skipped      = 0
       Number of rows loaded       = 1
       Number of rows rejected     = 0
       Number of rows deleted      = 0
       Number of rows committed    = 1
  8. 将数据装入表中后,请通过在 zample 数据库中运行下列查询来确认在 TSM 服务器上存在一个备份映像、一个装入副本映像和一个日志文件:
       bar:/home/roecken/sqllib/adsm> db2adutl query db zample 
          options "-asnodename=clusternode"
    将返回以下信息:
       Retrieving FULL DATABASE BACKUP information.
           1 Time: 20090216151025  Oldest log: S0000000.LOG  Log stream: 0    
           Sessions: 1  
    
       Retrieving INCREMENTAL DATABASE BACKUP information.
         No INCREMENTAL DATABASE BACKUP images found for ZAMPLE
    
       Retrieving DELTA DATABASE BACKUP information.
         No DELTA DATABASE BACKUP images found for ZAMPLE
    
       Retrieving TABLESPACE BACKUP information.
         No TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving INCREMENTAL TABLESPACE BACKUP information.
         No INCREMENTAL TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving DELTA TABLESPACE BACKUP information.
         No DELTA TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving LOAD COPY information.
           1 Time: 20090216151213
    
       Retrieving LOG ARCHIVE information.
          Log file: S0000000.LOG, Chain Num: 0, Log stream: 0, 
          Taken at: 2009-02-16-15.10.38
  9. 在此示例中,尚未设置计算机 2 dps 以用于 zample 数据库的跨节点恢复。 使用下列命令验证是否已没有数据与此用户和计算机相关联:
       dps:/home/regress9/sqllib/adsm> db2adutl query db zample      
    将返回以下信息:
         --- Database directory is empty ---
       Warning: There are no file spaces created by Db2 on the ADSM server
       Warning: No Db2 backup images found in ADSM for any alias.
    
  10. 使用下列命令查询 TSM 服务器以获得与代理节点 clusternode 相关联的 zample 数据库的对象列表:
      dps:/home/regress9/sqllib/adsm> db2adutl query db zample 
         options="-asnodename=clusternode"    
    将返回以下信息:
       --- Database directory is empty ---
    
       Query for database ZAMPLE
    
       Retrieving FULL DATABASE BACKUP information.
           1 Time: 20090216151025  Oldest log: S0000000.LOG  Log stream: 0    
           Sessions: 1  
    
       Retrieving INCREMENTAL DATABASE BACKUP information.
         No INCREMENTAL DATABASE BACKUP images found for ZAMPLE
    
       Retrieving DELTA DATABASE BACKUP information.
         No DELTA DATABASE BACKUP images found for ZAMPLE
    
       Retrieving TABLESPACE BACKUP information.
         No TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving INCREMENTAL TABLESPACE BACKUP information.
         No INCREMENTAL TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving DELTA TABLESPACE BACKUP information.
         No DELTA TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving LOAD COPY information.
           1 Time: 20090216151213
    
       Retrieving LOG ARCHIVE information.
          Log file: S0000000.LOG, Chain Num: 0, Log stream: 0, 
          Taken at: 2009-02-16-15.10.38
    
    此信息与先前生成的 TSM 信息匹配,并确认可以将此映像复原到 dps 计算机上。
  11. 使用下列命令将 zample 数据库从 TSM 服务器复原到 dps 计算机:
       dps:/home/regress9> db2 restore db zample use tsm options 
          "'-asnodename=clusternode'" without prompting
    
    将返回以下信息:
       DB20000I  The RESTORE DATABASE command completed successfully.
    注: 如果 dps上已存在 zample 数据库,那么将省略 OPTIONS 参数,并且将使用数据库配置参数 vendoropt 。 此配置参数将覆盖备份或复原操作的 OPTIONS 参数。
  12. 执行前滚操作以应用在创建新表并装入新数据时记录在 zample 数据库日志文件中的事务。 在此示例中,因为未指定用户和计算机信息而导致 ROLLFORWARD 实用程序找不到日志文件,所以前滚操作的下列尝试将失败:
       dps:/home/regress9> db2 rollforward db zample to end of logs and stop
    该命令会返回下列错误:
       SQL4970N  Roll-forward recovery on database "ZAMPLE" cannot reach the 
       specified stop point (end-of-log or point-in-time) because of missing log 
       file(s) on node(s) "0".
    使用适当的 logarchopt 值强制 ROLLFORWARD 实用程序查找另一台计算机上的日志文件。 在此示例中,使用下列命令设置 logarchopt1 数据库配置参数并搜索与用户 roecken 和计算机 bar 相关联的日志文件:
       dps:/home/regress9> db2 update db cfg for zample using logarchopt1 
          "'-asnodename=clusternode'"
  13. 通过使用下列命令来设置 vendoropt 数据库配置参数,使 ROLLFORWARD 实用程序能够使用备份和装入副本映像:
       dps:/home/regress9> db2 update db cfg for zample using VENDOROPT 
          "'-asnodename=clusternode'"
  14. 使用下列命令通过应用记录在 zample 数据库日志文件中的事务来完成跨节点数据恢复:
       dps:/home/regress9> db2 rollforward db zample to end of logs and stop
    将返回以下信息:
                                        Rollforward Status
    
     Input database alias                   = zample
     Number of members have returned status = 1
    
    
     Member number  Rollforward  Next log to  Log files processed        Last committed transaction
                    status       be read                                 
     -------------  -----------  -----------  -------------------------  ------------------------------
             0      not pending               S0000000.LOG-S0000000.LOG  2009-05-06-15.28.11.000000 UTC
    
    
    DB20000I  The ROLLFORWARD command completed successfully.
    已将计算机 dps 上用户 regress9 下的数据库 zample 恢复到计算机 bar 上用户 roecken 下数据库的同一位置。

示例 4: TSM 服务器配置为在 Db2 pureScale 环境中使用客户机代理节点

此示例显示如何将两个成员设置为代理节点,以便当日志归档和备份都存储在 TSM 服务器上且在该服务器上使用 PASSWORDACCESS=GENERATE 选项来管理密码时,您可以将数据从一个成员恢复至另一个成员。

注: 更新数据库配置后,可能必须对数据库进行脱机备份。

在此示例中,成员 member1member2 注册在 clusternode 代理名称下。 在 Db2® pureScale® 环境中,可以从任何成员执行备份或数据恢复操作。 在此示例中,会将数据从 member2 恢复

  1. 使用下列命令将成员 member1member2 在 TSM 服务器上注册为代理节点:
    REGISTER NODE clusternode mypassword
    GRANT PROXYNODE TARGET=clusternode AGENT=member1,member2 
  2. 要启用数据库以将日志归档到 TSM 服务器,请使用以下命令更新 zample 数据库的数据库配置参数 logarchmeth1 :
       member1:/home/roecken> db2 update db cfg for zample using 
          LOGARCHMETH1 tsm logarchopt1 "'-asnodename=clusternode'"
    注:Db2 pureScale 环境中,您可以从任何 成员设置一次全局 logarchmeth1 数据库配置参数。
    将返回以下信息:
       DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
  3. 使用下列命令从数据库断开所有用户和应用程序的连接:
       db2 force applications all
  4. 使用下列命令验证是否已没有应用程序连接到数据库:
       db2 list applications global
    您应该会接收到一条消息,说明未返回任何数据。
  5. 使用下列命令在 TSM 服务器上创建数据库备份:
       db2 backup db zample use tsm options '-asnodename=clusternode'
    将返回类似以下的信息:
       Backup successful. The timestamp for this backup image is : 20090216151025
    您可以改为更新 vendoropt 数据库配置参数,而不是在 BACKUP DATABASE 命令上指定 -asnodename 选项。
    注:Db2 pureScale 环境中,可以从任何 成员 运行此命令以备份数据库的所有数据。
  6. 使用下列命令连接至 zample 数据库:
       db2 connect to zample
  7. 通过使用下列命令创建一个表并将数据装入 TSM 服务器来生成数据库的新事务日志:
    member1:/home/roecken> db2 load from mr of del modified by noheader replace
          into employee copy yes use tsmwhere
    其中,在此示例中,表称为 employee,并且正在从名为 mr的定界 ASCII 文件装入数据。 指定了 COPY YES 选项以生成所装入数据的副本,而 USE TSM 选项指定数据的副本存储在 TSM 服务器上。
    注: 仅当为前滚恢复启用了数据库时,才能指定 COPY YES 选项; 即, logarchmeth1 数据库配置参数必须设置为 USEREXITLOGRETAINDISKTSM
    为了指示它的进度,LOAD 实用程序将返回一系列消息:
       SQL3109N  The utility is beginning to load data from file "/home/roecken/mr".
    
       SQL3500W  The utility is beginning the "LOAD" phase at time "02/16/2009 
       15:12:13.392633".
    
       SQL3519W  Begin Load Consistency Point. Input record count = "0".
    
       SQL3520W  Load Consistency Point was successful.
    
       SQL3110N  The utility has completed processing.  "1" rows were read from the 
       input file.
    
       SQL3519W  Begin Load Consistency Point. Input record count = "1".
    
       SQL3520W  Load Consistency Point was successful.
    
       SQL3515W  The utility has finished the "LOAD" phase at time "02/16/2009 
       15:12:13.445718".
    
    
       Number of rows read         = 1
       Number of rows skipped      = 0
       Number of rows loaded       = 1
       Number of rows rejected     = 0
       Number of rows deleted      = 0
       Number of rows committed    = 1
  8. 将数据装入表中后,请通过在 zample 数据库中运行下列查询来确认在 TSM 服务器上存在一个备份映像、一个装入副本映像和一个日志文件:
       member1:/home/roecken/sqllib/adsm> db2adutl query db zample 
          options "-asnodename=clusternode"
    将返回以下信息:
       Retrieving FULL DATABASE BACKUP information.
           1 Time: 20090216151025  Oldest log: S0000000.LOG  Log stream: 0    
           Sessions: 1  
    
       Retrieving INCREMENTAL DATABASE BACKUP information.
         No INCREMENTAL DATABASE BACKUP images found for ZAMPLE
    
       Retrieving DELTA DATABASE BACKUP information.
         No DELTA DATABASE BACKUP images found for ZAMPLE
    
       Retrieving TABLESPACE BACKUP information.
         No TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving INCREMENTAL TABLESPACE BACKUP information.
         No INCREMENTAL TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving DELTA TABLESPACE BACKUP information.
         No DELTA TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving LOAD COPY information.
           1 Time: 20090216151213
    
    Retrieving LOG ARCHIVE information.
    
       Log file: S0000000.LOG, Chain Num: 1, Log stream: 1, Taken at: 2009-02-16-13.01.10
    
       Log file: S0000000.LOG, Chain Num: 1, Log stream: 0, Taken at: 2009-02-16-13.01.11
    
       Log file: S0000000.LOG, Chain Num: 1, Log stream: 2, Taken at: 2009-02-16-13.01.19
    
       Log file: S0000001.LOG, Chain Num: 1, Log stream: 0, Taken at: 2009-02-16-13.02.49
    
       Log file: S0000001.LOG, Chain Num: 1, Log stream: 1, Taken at: 2009-02-16-13.02.49
    
       Log file: S0000001.LOG, Chain Num: 1, Log stream: 2, Taken at: 2009-02-16-13.02.49
    
       Log file: S0000002.LOG, Chain Num: 1, Log stream: 1, Taken at: 2009-02-16-13.03.15
    
       Log file: S0000002.LOG, Chain Num: 1, Log stream: 2, Taken at: 2009-02-16-13.03.15
    
       Log file: S0000002.LOG, Chain Num: 1, Log stream: 0, Taken at: 2009-02-16-13.03.16
  9. 使用下列命令查询 TSM 服务器以获得与代理节点 clusternode 相关联的 zample 数据库的对象列表:
      member2:/home/regress9/sqllib/adsm> db2adutl query db zample 
         options="-asnodename=clusternode"    
    将返回以下信息:
       --- Database directory is empty ---
    
       Query for database ZAMPLE
    
       Retrieving FULL DATABASE BACKUP information.
           1 Time: 20090216151025  Oldest log: S0000000.LOG  Log stream: 0    
           Sessions: 1  
    
       Retrieving INCREMENTAL DATABASE BACKUP information.
         No INCREMENTAL DATABASE BACKUP images found for ZAMPLE
    
       Retrieving DELTA DATABASE BACKUP information.
         No DELTA DATABASE BACKUP images found for ZAMPLE
    
       Retrieving TABLESPACE BACKUP information.
         No TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving INCREMENTAL TABLESPACE BACKUP information.
         No INCREMENTAL TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving DELTA TABLESPACE BACKUP information.
         No DELTA TABLESPACE BACKUP images found for ZAMPLE
    
       Retrieving LOAD COPY information.
           1 Time: 20090216151213
    
    Retrieving LOG ARCHIVE information.
    
       Log file: S0000000.LOG, Chain Num: 1, Log stream: 1, Taken at: 2009-02-16-13.01.10
    
       Log file: S0000000.LOG, Chain Num: 1, Log stream: 0, Taken at: 2009-02-16-13.01.11
    
       Log file: S0000000.LOG, Chain Num: 1, Log stream: 2, Taken at: 2009-02-16-13.01.19
    
       Log file: S0000001.LOG, Chain Num: 1, Log stream: 0, Taken at: 2009-02-16-13.02.49
    
       Log file: S0000001.LOG, Chain Num: 1, Log stream: 1, Taken at: 2009-02-16-13.02.49
    
       Log file: S0000001.LOG, Chain Num: 1, Log stream: 2, Taken at: 2009-02-16-13.02.49
    
       Log file: S0000002.LOG, Chain Num: 1, Log stream: 1, Taken at: 2009-02-16-13.03.15
    
       Log file: S0000002.LOG, Chain Num: 1, Log stream: 2, Taken at: 2009-02-16-13.03.15
    
       Log file: S0000002.LOG, Chain Num: 1, Log stream: 0, Taken at: 2009-02-16-13.03.16
    此信息与先前生成的 TSM 信息匹配,并确认可以将此映像复原到 member2 成员上。
  10. 使用下列命令从 member2 成员复原 TSM 服务器上的 zample 数据库:
       member2:/home/regress9> db2 restore db zample use tsm options 
          '-asnodename=clusternode' without prompting
    
    将返回以下信息:
       DB20000I  The RESTORE DATABASE command completed successfully.
    注: 如果 member2上已存在 zample 数据库,那么将省略 OPTIONS 参数,并且将使用数据库配置参数 vendoropt 。 此配置参数将覆盖备份或复原操作的 OPTIONS 参数。
  11. 通过使用下列命令来设置 vendoropt 数据库配置参数,使 ROLLFORWARD 实用程序能够使用备份和装入副本映像:
       member2:/home/regress9> db2 update db cfg for zample using VENDOROPT 
          "'-asnodename=clusternode'"
    注:Db2 pureScale 环境中,您可以从任何 成员设置一次全局 vendoropt 数据库配置参数。
  12. 使用下列命令通过应用记录在 zample 数据库日志文件中的事务来完成跨成员数据恢复:
       member2:/home/regress9> db2 rollforward db zample to end of logs and stop
    将返回以下信息:
                                        Rollforward Status
    
     Input database alias                   = zample
     Number of members have returned status = 3
    
    
     Member number  Rollforward  Next log to  Log files processed        Last committed transaction
                    status       be read                                 
     -------------  -----------  -----------  -------------------------  ------------------------------
                 0  not pending               S0000001.LOG-S0000012.LOG  2009-05-06-15.28.11.000000 UTC
                 1  not pending               S0000001.LOG-S0000012.LOG  2009-05-06-15.28.11.000000 UTC
                 2  not pending               S0000001.LOG-S0000012.LOG  2009-05-06-15.28.11.000000 UTC
    
    DB20000I  The ROLLFORWARD command completed successfully.
    已将成员 member2 上用户 regress9 下的数据库 zample 恢复到成员 member1 上用户 roecken 下数据库的同一位置。