使用 db2adutl 回復資料

您可以搭配使用 db2adutl 指令及 logarchopt1vendoropt 資料庫配置參數,來執行跨節點回復。 此回復示範於來自少數不同 Tivoli® Storage Manager (TSM) 環境的範例中。

附註: Tivoli Storage Manager (TSM) 7.1.8+ 及 8.1.2+ 引進重要加強功能,以改善用戶端與伺服器通訊之間的安全。 從 7.1.8 和 8.1.2 版開始,授信通訊代理程式 (TCA) 不再可用,使用者必須將每一個 Db2 實例配置為有權存取節點密碼的授權使用者。 下面提供的範例假設使用舊式 TCA 鑑別方法,這需要在 LOGARCHOPT1 和 VENDOROPT 資料庫配置選項,或 TSM OPTIONS 還原選項中指定 ‘-fromowner=<owner>’ 選項,以執行跨節點回復。 如果使用授權使用者方法,則應該省略 ‘-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 伺服器上。
    附註: 只有在資料庫已啟用 Roll-Forward 回復時,您才能指定 COPY YES 選項; 也就是說, logarchmeth1 資料庫配置參數必須設為 USEREXITLOGRETAINDISKTSM
    為了指出其進度,載入公用程式會傳回一系列訊息:
       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.
    附註: 如果 zample 資料庫已存在於 dps上,則會省略 OPTIONS 參數,並使用資料庫配置參數 vendoropt 。 此配置參數會置換備份或還原作業的 OPTIONS 參數。
  12. 執行向前復原作業,以在建立新表格並載入新資料時套用記錄在 zample 資料庫日誌檔中的交易。 在此範例中,向前復原作業的下列嘗試將失敗,原因是向前復原公用程式因未指定使用者及電腦資訊而找不到日誌檔:
       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 值來尋找與另一台電腦相關聯的日誌檔。 在此範例中,請使用下列指令來設定 logarchopt1 資料庫配置參數,並搜尋與使用者 roecken 及電腦 bar 相關聯的日誌檔:
       dps:/home/regress9> db2 update db cfg for zample using logarchopt1 
       "'-fromnode=bar -fromowner=roecken'"
  13. 使用下列指令來設定 vendoropt 資料庫配置參數,以啟用向前復原公用程式來使用備份及載入副本映像檔:
       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.
    使用者 regress9 下電腦 dps 上的資料庫 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  
    在此範例中,因為還原作業已取代資料庫配置檔,所以向前復原公用程式找不到正確的日誌檔,並傳回下列錯誤訊息:
       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 資料庫配置參數,以便向前復原公用程式可以使用下列指令找到正確的日誌檔:
         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.
使用者 regress9 下電腦 dps 上的資料庫 zample 已回復至與使用者 roecken 下電腦bar 上資料庫相同的點

範例 3:TSM 伺服器配置為使用用戶端 Proxy 節點

這個跨節點回復範例顯示如何設定兩台電腦作為 Proxy 節點,以便在日誌保存和備份儲存在 TSM 伺服器上,且使用 PASSWORDACCESS=GENERATE 選項來管理密碼時,您可以將資料從一台電腦回復至另一台電腦。

附註: 更新資料庫配置之後,您可能必須進行資料庫的離線備份。

在此範例中,電腦 bardps 登錄在 Proxy 名稱 clusternode 下。 電腦已設定為 Proxy 節點。

  1. 使用下列指令,將 TSM 伺服器上的電腦 bardps 登錄為 Proxy 節點:
    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 伺服器上。
    附註: 只有在資料庫已啟用 Roll-Forward 回復時,您才能指定 COPY YES 選項; 也就是說, logarchmeth1 資料庫配置參數必須設為 USEREXITLOGRETAINDISKTSM
    為了指出其進度,載入公用程式會傳回一系列訊息:
       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 伺服器,以取得與 Proxy 節點 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.
    附註: 如果 zample 資料庫已存在於 dps上,則會省略 OPTIONS 參數,並使用資料庫配置參數 vendoropt 。 此配置參數會置換備份或還原作業的 OPTIONS 參數。
  12. 執行向前復原作業,以在建立新表格並載入新資料時套用記錄在 zample 資料庫日誌檔中的交易。 在此範例中,向前復原作業的下列嘗試將失敗,原因是向前復原公用程式因未指定使用者及電腦資訊而找不到日誌檔:
       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 值來在另一台電腦上尋找日誌檔。 在此範例中,請使用下列指令來設定 logarchopt1 資料庫配置參數,並搜尋與使用者 roecken 及電腦 bar 相關聯的日誌檔:
       dps:/home/regress9> db2 update db cfg for zample using logarchopt1 
          "'-asnodename=clusternode'"
  13. 使用下列指令來設定 vendoropt 資料庫配置參數,以啟用向前復原公用程式來使用備份及載入副本映像檔:
       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.
    使用者 regress9 下電腦 dps 上的資料庫 zample 已回復至 bar 使用者 roecken下電腦上資料庫的相同點。

範例 4: TSM 伺服器配置為在 Db2 pureScale 環境中使用用戶端 Proxy 節點

此範例顯示如何將兩個成員設定為 Proxy 節點,以便在日誌保存及備份儲存在 TSM 伺服器上,且使用 PASSWORDACCESS=GENERATE 選項管理密碼時,您可以將資料從一個成員回復至另一個成員。

附註: 更新資料庫配置之後,您可能必須進行資料庫的離線備份。

在此範例中,成員 member1member2 在 Proxy 名稱 clusternode 下登錄。 在 Db2® pureScale® 環境中,您可以從任何成員執行備份或資料回復作業。 在此範例中,將從 member2 回復資料

  1. 使用下列指令,在 TSM 伺服器上登錄成員 member1member2 作為 Proxy 節點:
    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 伺服器上。
    附註: 只有在資料庫已啟用 Roll-Forward 回復時,您才能指定 COPY YES 選項; 也就是說, logarchmeth1 資料庫配置參數必須設為 USEREXITLOGRETAINDISKTSM
    為了指出其進度,載入公用程式會傳回一系列訊息:
       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 伺服器,以取得與 Proxy 節點 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.
    附註: 如果 zample 資料庫已存在於 member2上,則會省略 OPTIONS 參數,並使用資料庫配置參數 vendoropt 。 此配置參數會置換備份或還原作業的 OPTIONS 參數。
  11. 使用下列指令來設定 vendoropt 資料庫配置參數,以啟用向前復原公用程式來使用備份及載入副本映像檔:
       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.
    使用者 regress9 下成員 member2 上的資料庫 zample 已回復至與使用者 roecken下成員 member1 上的資料庫相同的點。