實現DB2 多分區(qū)備份要用到哪些操作項目?
以下的文章主要向大家描述的是DB2 多分區(qū)備份的實際操作步驟,以及對實現DB2 多分區(qū)備份的實際操作過程中我們大家要用到的相關實際操作代碼的描述,以下就是文章的主要內容的詳細解析。
數據庫, 分區(qū)數據庫, 分區(qū)
編目分區(qū):
- Catalog database partition number = 0
這個就是編目分區(qū)。
斷掉所有的連接。
- DB2 force applications all
- DB2_all "<<+0<DB2 backup database sample to d:\data compress"
- DB2_all "<<-0<DB2 backup database sample to d:\data compress"
- DB2_all "<<+0< DB2 restore db sample from d:\data taken at 20090212141538 replace existing "
- DB2_all "<<-0< DB2 restore db sample from d:\data taken at 20090212141630 replace existing"
- -----replace existing
- If a database with the same alias as the target database alias already exists,
- this parameter specifies that the restore utility is to replace the existing database with the restored database.
- This is useful for scripts that invoke the restore utility,
- because the command line processor will not prompt the user to verify deletion of an existing database.
- If the WITHOUT PROMPTING parameter is specified, it is not necessary to specify REPLACE EXISTING,
- but in this case, the operation will fail if events occur that normally require user intervention.
為對分區(qū)數據庫的所有分區(qū)進行DB2 多分區(qū)備份操作,我們可利用 DB2_all 的作用。在語句前加上 DB2_all,并將語句引用在 "" 中,可令該語句在一個實例中的每個分區(qū)上被執(zhí)行,而無需分別對每個分區(qū)重復發(fā)出相同的命令。
BACKUP 便可通過這種方式實現對分區(qū)數據庫的操作,但是對于編目分區(qū)例外。由于 DB2 多分區(qū)備份或恢復時要求獨占編目分區(qū),因此在對其它分區(qū)進行備份操作之前,首先必須先完成該分區(qū)的備份操作。
另外,在 DB2_all 之后的 "" 語句中,我們還可以以下述方式作開頭,以指定命令所作用的分區(qū):
<<+分區(qū)號< :表示后續(xù)命令作用于該分區(qū)。
<<-分區(qū)號< :表示后續(xù)命令作用于除該分區(qū)之外的其它分區(qū)。
||<<-分區(qū)號< 或 <<-分區(qū)號; :表示后續(xù)命令作用于除該分區(qū)之外的其它分區(qū),
并且是以并行方式進行的。
綜上所述,對于分區(qū)數據庫的數據進行備份操作的命令為(以編目分區(qū)號為 0 舉例):
1. 無需并行操作的方式:
當備份操作不需要使用并行方式時,則不存在先對編目分區(qū)進行操作的問題,此時可通過一條命令實現備份操作。
DB2_all "DB2 BACKUP DATABASE <數據庫別名> TO <路徑/設備名>"
2. 使用并行操作的方式:
DB2_all "<<+0< DB2 BACKUP DATABASE <數據庫別名> TO <路徑/設備名>" (windows下)
DB2_all "||<<-0< DB2 BACKUP DATABASE <數據庫別名> TO <路徑/設備名>"
或
DB2_all "<<-0<; DB2 BACKUP DATABASE <數據庫別名> TO <路徑/設備名>"
即首先對編目分區(qū) - 0 號分區(qū)進行DB2 多分區(qū)備份操作,然后再對除編目分區(qū)之外的其它分區(qū)同時并行操作,以縮短操作的時間,這一點體現了分區(qū)數據庫的優(yōu)越性。
- DB2 force applications all
- DB2_all "<<+0<DB2 connect to churndb;DB2 backup database churndb to /DB2log/DB2buckup compress;DB2 terminate"
- DB2_all "<<-0<DB2 connect to churndb;DB2 backup database churndb to /DB2log/DB2buckup compress;DB2 terminate"
linux下這么寫,以上的相關內容就是對DB2 多分區(qū)數據庫備份的介紹,望你能有所收獲。
【編輯推薦】