经常能够遇到类似的需求,使用生产环境的一个备份,到测试server上面进行测试环境的搭建。
这种需求的解决,通常有三种做法:
1、利用数据库的重建恢复
(1)在数据库1上面新建数据库:
db2 "create database tpcd automatic storage no on /db2home"
(2)创建schema,并创建一些表:
db2 "create schema tpcd"
db2tpcd@NODE1:/home/db2tpcd> db2 list tables for schema tpcd
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
CUSTOMER TPCD T 2014-03-24-15.18.58.375173
LINEITEM TPCD T 2014-03-24-15.18.58.445625
NATION TPCD T 2014-03-24-15.18.58.220159
ORDERS TPCD T 2014-03-24-15.18.58.397073
PART TPCD T 2014-03-24-15.18.58.303957
PARTSUPP TPCD T 2014-03-24-15.18.58.352340
REGION TPCD T 2014-03-24-15.18.58.253664
SUPPLIER TPCD T 2014-03-24-15.18.58.328894
db2tpcd@NODE1:/home/db2tpcd> db2 "create table leotest ( id int)"
DB20000I The SQL command completed successfully.
db2tpcd@NODE1:/home/db2tpcd> db2 "insert into leotest values(2)"
DB20000I The SQL command completed successfully.
db2tpcd@NODE1:/home/db2tpcd> db2 commit
DB20000I The SQL command completed successfully.
db2tpcd@NODE1:/home/db2tpcd> db2 "select * from leotest"
ID
-----------
2
1 record(s) selected.
db2tpcd@NODE1:/home/db2tpcd> db2 "select TABSCHEMA,TABNAME,TBSPACEID from syscat.tables where TABSCHEMA='TPCD'"
TABSCHEMA TABNAME TBSPACEID
-------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- ---------
TPCD CUSTOMER 2
TPCD LEOTEST 2
TPCD LINEITEM 2
TPCD NATION 2
TPCD ORDERS 2
TPCD PART 2
TPCD PARTSUPP 2
TPCD REGION 2
TPCD SUPPLIER 2
db2tpcd@NODE1:/home/db2tpcd> db2 list tablespaces
Tablespaces for Current Database
Tablespace ID = 0
Name = SYSCATSPACE
Type = System managed space
Contents = All permanent data. Regular table space.
State = 0x0000
Detailed explanation:
Normal
Tablespace ID = 1
Name = TEMPSPACE1
Type = System managed space
Contents = System Temporary data
State = 0x0000
Detailed explanation:
Normal
Tablespace ID = 2
Name = USERSPACE1
Type = System managed space
Contents = All permanent data. Regular table space.
State = 0x0000
Detailed explanation:
Normal
(3)对当前数据库进行离线备份:
b2tpcd@NODE1:/home/db2tpcd/temp_backup> db2 backup db tpcd
Backup successful. The timestamp for this backup image is : 20140325150157
db2tpcd@NODE1:/home/db2tpcd/temp_backup>
NODE1:/home/db2tpcd/temp_backup # ls
TPCD.0.db2tpcd.NODE0000.CATN0000.20140324153537.001 TPCD.0.db2tpcd.NODE0000.CATN0000.20140325150157.001
(4)将备份传送到另一台机器,首先查看是否有和node1中一样的文件系统;然后,使用db2 restore rebuild命令进行数据库重建:
查看node2的文件系统:
db2tpcd@NODE2:/home/db2tpcd> ls /db2home
/bin/ls: /db2home: No such file or directory
db2tpcd@NODE2:/home/db2tpcd>
可以看到,并没有和NODE1中一样的文件系统来保存数据库;
使用db2 restore rebuild进行数据库重建:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 restore db tpcd rebuild taken at 20140324153537
SQL0104N An unexpected token "taken" was found following "REBUILD". Expected
tokens may include: "WITH". SQLSTATE=42601
发现,没有指定表空间,不能进行重建,即,使用此种方式进行数据库的重建恢复,必须指定表空间:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 "restore db tpcd rebuild with tablespace (SYSCATSPACE,SYSTOOLSPACE) taken at 20140325150157"
DB20000I The RESTORE DATABASE command completed successfully.
重建成功后,再次查看文件系统:
db2tpcd@NODE2:/home/db2tpcd> ls /db2home
/bin/ls: /db2home: No such file or directory
db2tpcd@NODE2:/home/db2tpcd>
还是没有和NODE1一样的文件系统,查看数据库的位置:
db2tpcd@NODE2:/home/db2tpcd> db2 list db directory
System Database Directory
Number of entries in the directory = 1
Database 1 entry:
Database alias = TPCD
Database name = TPCD
Local database directory = /home/db2tpcd
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
db2tpcd@NODE2:/home/db2tpcd>
发现数据库被重建到了实例用户的根目录下面;查看NODE1和NODE2的表空间的文件系统状况:
NODE1:
db2tpcd@NODE1:/db2home/db2tpcd> db2pd -d tpcd -tablespaces
Database Partition 0 -- Database TPCD -- Active -- Up 0 days 00:00:13
Tablespace Configuration:
Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name
0x00002ABE18224D20 0 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 SYSCATSPACE
0x00002ABE189590A0 1 SMS SysTmp 4096 32 Yes 32 1 1 On 1 0 31 TEMPSPACE1
0x00002ABE1895E5A0 2 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 USERSPACE1
0x00002ABE18961A80 3 DMS Large 4096 4 Yes 4 1 1 Off 1 0 3 SYSTOOLSPACE
Tablespace Statistics:
Address Id TotalPgs UsablePgs UsedPgs PndFreePgs FreePgs HWM Max HWM State MinRecTime NQuiescers PathsDropped
0x00002ABE18224D20 0 14844 14844 14844 0 0 0 0 0x00000000 0 0 No
0x00002ABE189590A0 1 1 1 1 0 0 0 0 0x00000000 0 0 No
0x00002ABE1895E5A0 2 10 10 10 0 0 0 0 0x00000000 0 0 No
0x00002ABE18961A80 3 8192 8188 144 0 8044 144 144 0x00000000 0 0 No
Tablespace Autoresize Statistics:
Address Id AS AR InitSize IncSize IIP MaxSize LastResize LRF
0x00002ABE18224D20 0 No No 0 0 No 0 None No
0x00002ABE189590A0 1 No No 0 0 No 0 None No
0x00002ABE1895E5A0 2 No No 0 0 No 0 None No
0x00002ABE18961A80 3 No Yes 0 -1 No None None No
Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0x00002ABE182261E0 0 0 Path 14844 14844 - 0 /db2home/db2tpcd/NODE0000/SQL00001/SQLT0000.0
0x00002ABE18226420 1 0 Path 1 1 - 0 /db2home/db2tpcd/NODE0000/SQL00001/SQLT0001.0
0x00002ABE18226660 2 0 Path 10 10 - 0 /db2home/db2tpcd/NODE0000/SQL00001/SQLT0002.0
0x00002ABE18226900 3 0 File 8192 8188 - 0 /db2home/db2tpcd/NODE0000/SQL00001/SYSTOOLSPACE
db2tpcd@NODE1:/db2home/db2tpcd>
NODE2:
db2tpcd@NODE2:/home/db2tpcd> db2pd -d tpcd -tablespaces
Database Partition 0 -- Database TPCD -- Active -- Up 0 days 00:07:27
Tablespace Configuration:
Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name
0x00002B4B432C6D20 0 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 SYSCATSPACE
0x00002B4B439FB0A0 1 SMS SysTmp 4096 32 Yes 32 1 1 On 1 0 31 TEMPSPACE1
0x00002B4B43A005A0 2 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 USERSPACE1
0x00002B4B43A03A80 3 DMS Large 4096 4 Yes 4 1 1 Off 1 0 3 SYSTOOLSPACE
Tablespace Statistics:
Address Id TotalPgs UsablePgs UsedPgs PndFreePgs FreePgs HWM Max HWM State MinRecTime NQuiescers PathsDropped
0x00002B4B432C6D20 0 14968 14968 14968 0 0 0 0 0x00000000 0 0 No
0x00002B4B439FB0A0 1 1 1 1 0 0 0 0 0x00000000 0 0 No
0x00002B4B43A005A0 2 0 0 0 0 0 0 0 0x0000C000 0 0 No
0x00002B4B43A03A80 3 8192 8188 144 0 8044 144 144 0x00000000 0 0 No
Tablespace Autoresize Statistics:
Address Id AS AR InitSize IncSize IIP MaxSize LastResize LRF
0x00002B4B432C6D20 0 No No 0 0 No 0 None No
0x00002B4B439FB0A0 1 No No 0 0 No 0 None No
0x00002B4B43A005A0 2 No No 0 0 No 0 None No
0x00002B4B43A03A80 3 No Yes 0 -1 No None None No
Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0x00002B4B432C81E0 0 0 Path 14968 14968 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SQLT0000.0
0x00002B4B432C8420 1 0 Path 1 1 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SQLT0001.0
0x00002B4B432C8660 2 0 Path 0 0 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SQLT0002.0
0x00002B4B432C8900 3 0 File 8192 8188 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SYSTOOLSPACE
db2tpcd@NODE2:/home/db2tpcd>
(5)激活数据库并进行连接:
db2tpcd@NODE2:/home/db2tpcd> db2 connect to tpcd
Database Connection Information
Database server = DB2/LINUXX8664 9.7.0
SQL authorization ID = DB2TPCD
Local database alias = TPCD
(6)查看数据库的表空间的状况:
db2tpcd@NODE2:/home/db2tpcd> db2 list tablespaces show detail
Tablespaces for Current Database
Tablespace ID = 0
Name = SYSCATSPACE
Type = System managed space
Contents = All permanent data. Regular table space.
State = 0x0000
Detailed explanation:
Normal
Total pages = 14844
Useable pages = 14844
Used pages = 14844
Free pages = Not applicable
High water mark (pages) = Not applicable
Page size (bytes) = 4096
Extent size (pages) = 32
Prefetch size (pages) = 32
Number of containers = 1
Tablespace ID = 1
Name = TEMPSPACE1
Type = System managed space
Contents = System Temporary data
State = 0x0000
Detailed explanation:
Normal
Total pages = 1
Useable pages = 1
Used pages = 1
Free pages = Not applicable
High water mark (pages) = Not applicable
Page size (bytes) = 4096
Extent size (pages) = 32
Prefetch size (pages) = 32
Number of containers = 1
Tablespace ID = 2
Name = USERSPACE1
Type = System managed space
Contents = All permanent data. Regular table space.
State = 0xc000
Detailed explanation:
Offline
Drop Pending
Tablespace ID = 3
Name = SYSTOOLSPACE
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x0000
Detailed explanation:
Normal
Total pages = 8192
Useable pages = 8188
Used pages = 144
Free pages = 8044
High water mark (pages) = 144
Page size (bytes) = 4096
Extent size (pages) = 4
Prefetch size (pages) = 4
Number of containers = 1
db2tpcd@NODE2:/home/db2tpcd>
能够看到,在进行resotre rebuild的过程中,由于没有对USERSPACE1进行restore rebuild,这个表空间的状态是Drop pending;
但,如果此时尝试进行数据库备份,则会报错:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 backup db tpcd
SQL2048N An error occurred while accessing object "2". Reason code: "6".
6 The object being accessed is a table space and either the table
space is in such a state that the operation is not allowed or
one or more containers of the table space is not available.
6
The table space may be offline. Attempt to determine the
underlying problem and correct it. Some examples of problems
are: the filesystem is not mounted, which you can fix by
mounting the filesystem then altering the table space switch to
online, or table space files have been deleted, which you can
fix by performing a restore operation.
The table space may be quiesced. Use LIST TABLESPACES to check
the table space state. Use QUIESCE RESET OR QUIESCE TERMINATE
to make the table space available. Note that the userid holding
the quiesce may be needed to perform the QUIESCE REST OR
TERMINATE operation.
(7) 尝试查询表空间2中的表leotest中的数据:
db2tpcd@NODE2:/home/db2tpcd> db2 "select * from tpcd.leotest"
ID
-----------
SQL0290N Table space access is not allowed. SQLSTATE=55039
不能够访问表中的数据,因为表空间状态不正确;
但是可以查看schema下面的表,因为这些信息都是在编目表空间的;
db2tpcd@NODE2:/home/db2tpcd> db2 list tables for schema tpcd
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
CUSTOMER TPCD T 2014-03-25-14.57.00.623279
LEOTEST TPCD T 2014-03-25-15.00.21.055254
LINEITEM TPCD T 2014-03-25-14.57.00.648033
NATION TPCD T 2014-03-25-14.57.00.188197
ORDERS TPCD T 2014-03-25-14.57.00.639085
PART TPCD T 2014-03-25-14.57.00.559978
PARTSUPP TPCD T 2014-03-25-14.57.00.603382
REGION TPCD T 2014-03-25-14.57.00.548104
SUPPLIER TPCD T 2014-03-25-14.57.00.573877
9 record(s) selected.
db2tpcd@NODE2:/home/db2tpcd>
(8)删除NODE2重建的数据库,指定所有的表空间进行数据库的restore rebuild
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 "restore db tpcd rebuild with tablespace (SYSCATSPACE,SYSTOOLSPACE,USERSPACE1) taken at 20140325150157"
DB20000I The RESTORE DATABASE command completed successfully.
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 connect to tpcd
Database Connection Information
Database server = DB2/LINUXX8664 9.7.0
SQL authorization ID = DB2TPCD
Local database alias = TPCD
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 list db directory
System Database Directory
Number of entries in the directory = 1
Database 1 entry:
Database alias = TPCD
Database name = TPCD
Local database directory = /home/db2tpcd
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2pd -d tpcd -tablespaces
Database Partition 0 -- Database TPCD -- Active -- Up 0 days 00:01:10
Tablespace Configuration:
Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name
0x00002B4B432C6D20 0 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 SYSCATSPACE
0x00002B4B439FB0A0 1 SMS SysTmp 4096 32 Yes 32 1 1 On 1 0 31 TEMPSPACE1
0x00002B4B43A005A0 2 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 USERSPACE1
0x00002B4B43A03A80 3 DMS Large 4096 4 Yes 4 1 1 Off 1 0 3 SYSTOOLSPACE
Tablespace Statistics:
Address Id TotalPgs UsablePgs UsedPgs PndFreePgs FreePgs HWM Max HWM State MinRecTime NQuiescers PathsDropped
0x00002B4B432C6D20 0 14844 14844 14844 0 0 0 0 0x00000000 0 0 No
0x00002B4B439FB0A0 1 1 1 1 0 0 0 0 0x00000000 0 0 No
0x00002B4B43A005A0 2 10 10 10 0 0 0 0 0x00000000 0 0 No
0x00002B4B43A03A80 3 8192 8188 144 0 8044 144 144 0x00000000 0 0 No
Tablespace Autoresize Statistics:
Address Id AS AR InitSize IncSize IIP MaxSize LastResize LRF
0x00002B4B432C6D20 0 No No 0 0 No 0 None No
0x00002B4B439FB0A0 1 No No 0 0 No 0 None No
0x00002B4B43A005A0 2 No No 0 0 No 0 None No
0x00002B4B43A03A80 3 No Yes 0 -1 No None None No
Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0x00002B4B432C81E0 0 0 Path 14844 14844 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SQLT0000.0
0x00002B4B432C8420 1 0 Path 1 1 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SQLT0001.0
0x00002B4B432C8660 2 0 Path 10 10 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SQLT0002.0
0x00002B4B432C8900 3 0 File 8192 8188 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SYSTOOLSPACE
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
表空间的位置都是默认放到了实例用户的home目录里面;
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 "select * from tpcd.leotest"
ID
-----------
2
1 record(s) selected.
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
也能够正常查询。
结论1:
通过以上的resotre rebulid,
能够重建指定的表空间,但是未被指定的表空间将不会被重建;且未被指定的表空间将会被置为Drop pending的状态;
用offline的备份进行的restore rebuild能够立刻被连接;
在有表空间处于非noraml的状态时,数据库将无法进行备份;
使用restore rebuild的方法重建的数据库,可以不要求存在文件系统,但是使用此方式,文件系统会由restore rebuild过程中进行自动重建,默认位置在数据库实例用户的home目录下面;
使用此方法进行数据库环境的重新建立时,需要指定所有的表空间来进行,否则,将会有表空间处于Drop pending的状态;
没有被rebuild的表空间将无法被访问;
2、利用数据库的重定向选项进行数据库的重建
在上面一种方法中,有一个很大的缺点,就是数据库重建的时候,文件系统并不会被重建,而是直接默认建立到了实例用户的home目录下,这个往往不是我们想看到的;而且,需要一个一个的指定表空间的,也是一个麻烦的事情;(事实上,也可以有办法指定,可以通过指定dbpath on的选项来指定数据库的位置,后文会有演示)
于是,有了另一个选择,就是使用数据库重建的重定向选项,在这种情况下,能够提够一个指定文件系统的机会;
继续以node2上面的tpcd数据库为例子:
(1)使用带重定向选项进行数据库重建
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 restore database tpcd rebuild with all tablespaces in database taken at 20140325150157 redirect
SQL1277W A redirected restore operation is being performed. Table space
configuration can now be viewed and table spaces that do not use automatic
storage can have their containers reconfigured.
DB20000I The RESTORE DATABASE command completed successfully.
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
提示可以设置表空间的容器;
这个时候,当前会话已经自动连接到数据库中:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 connect to tpcd
SQL0752N Connecting to a database is not permitted within a logical unit of
work when the CONNECT type 1 setting is in use. SQLSTATE=0A001
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
所以,此时,千万不要使用db2 terminate,否则,在进行表空间容器设置的时候,会提示没有数据库连接,而目前状态下,数据库是无法被连接的,只能终止此次恢复,重新进行操作:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 terminate
SQL1350N The application is not in the correct state to process this request.
Reason code="3".
03 A Restore request is in progress. A warning was received from
the initial utility call indicating that further requests are
required before Restore can complete.
已经给出了警告,忽略,再次进行terminate
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 terminate
DB20000I The TERMINATE command completed successfully.
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
然后,尝试进行表空间容器的设置:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 "set tablespace containers for 3 using (file '/home/db2tpcd/db2home/tbs3' 1000)"
SQL1024N A database connection does not exist. SQLSTATE=08003
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
提示没有数据库连接,如果连接数据库:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 connect to tpcd
SQL1119N A connection to or activation of database "TPCD" cannot be made
because a previous restore is incomplete or still in progress. SQLSTATE=57019
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
尴尬的发现,没法操作了……只能终止本次restore rebuild
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 drop db tpcd
DB20000I The DROP DATABASE command completed successfully.
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 list db directory
SQL1057W The system database directory is empty. SQLSTATE=01606
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
再次使用带重定向选项的restore rebuild:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 restore database tpcd rebuild with all tablespaces in database taken at 20140325150157 redirect
SQL1277W A redirected restore operation is being performed. Table space
configuration can now be viewed and table spaces that do not use automatic
storage can have their containers reconfigured.
DB20000I The RESTORE DATABASE command completed successfully.
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
然后,查看当前数据库的状态:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 list db directory
System Database Directory
Number of entries in the directory = 1
Database 1 entry:
Database alias = TPCD
Database name = TPCD
Local database directory = /home/db2tpcd
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
发现,数据库的路径被自动指定到了实例目录下,这是因为:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 get dbm cfg | grep -i DFTDBPATH
Default database path (DFTDBPATH) = /home/db2tpcd
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
这也就是在方法1中为什么数据库会被自动重建到实例目录下的原因。这个是可在进行resotre rebuild过程中通过dbpath on选项进行指定的(下文将会演示)。暂时搁置此问题,继续向下,指定表空间容器:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 "set tablespace containers for 2 using (file '/db2home/tbs2' 1000)"
SQL0298N Bad container path. SQLSTATE=428B2
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
发现,提示“Bad container path”
仔细查看NODE1中的tablespace的属性(源库的表空间的属性)
Tablespace Configuration:
Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name
0x00002B4B432C6D20 0 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 SYSCATSPACE
0x00002B4B439FB0A0 1 SMS SysTmp 4096 32 Yes 32 1 1 On 1 0 31 TEMPSPACE1
0x00002B4B43A005A0 2 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 USERSPACE1
0x00002B4B43A03A80 3 DMS Large 4096 4 Yes 4 1 1 Off 1 0 3 SYSTOOLSPACE
发现,tablespace 2的表空间容器的类型是SMS;而
SMS类型的表空间在使用retore rebuild的redirect选项时,是不需要指定新的表空间容器的位置的,它将会自动被重建到DFTDBPATH所指定的路径下;
所以,为tablespace 2进行表空间容器的指定是失败的;
因此,对tablespace 3进行表空间容器的指定:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 "set tablespace containers for 3 using (file '/db2home/tbs3' 1000)"
DB20000I The SET TABLESPACE CONTAINERS command completed successfully.
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
可以看到对tablespace 3 (DMS)进行表空间容器的指定是会成功的;
继续restore continue:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 restore db tpcd continue
DB20000I The RESTORE DATABASE command completed successfully.
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
可以看到,restore成功;
查看表空间的位置:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2pd -d tpcd -tablespaces
Database Partition 0 -- Database TPCD -- Active -- Up 0 days 00:01:03
Tablespace Configuration:
Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name
0x00002B4B432C6D20 0 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 SYSCATSPACE
0x00002B4B439FB0A0 1 SMS SysTmp 4096 32 Yes 32 1 1 On 1 0 31 TEMPSPACE1
0x00002B4B43A005A0 2 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 USERSPACE1
0x00002B4B43A03A80 3 DMS Large 4096 4 Yes 4 1 1 Off 1 0 3 SYSTOOLSPACE
Tablespace Statistics:
Address Id TotalPgs UsablePgs UsedPgs PndFreePgs FreePgs HWM Max HWM State MinRecTime NQuiescers PathsDropped
0x00002B4B432C6D20 0 14844 14844 14844 0 0 0 0 0x00000000 0 0 No
0x00002B4B439FB0A0 1 1 1 1 0 0 0 0 0x00000000 0 0 No
0x00002B4B43A005A0 2 10 10 10 0 0 0 0 0x00000000 0 0 No
0x00002B4B43A03A80 3 1000 996 144 0 852 144 144 0x00000000 0 0 No
Tablespace Autoresize Statistics:
Address Id AS AR InitSize IncSize IIP MaxSize LastResize LRF
0x00002B4B432C6D20 0 No No 0 0 No 0 None No
0x00002B4B439FB0A0 1 No No 0 0 No 0 None No
0x00002B4B43A005A0 2 No No 0 0 No 0 None No
0x00002B4B43A03A80 3 No Yes 0 -1 No None None No
Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0x00002B4B432C81E0 0 0 Path 14844 14844 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SQLT0000.0
0x00002B4B432C8420 1 0 Path 1 1 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SQLT0001.0
0x00002B4B432C8660 2 0 Path 10 10 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SQLT0002.0
0x00002B4B432C8900 3 0 File 1000 996 - 0 /db2home/tbs3
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
对于SMS类型的表空间容器,都放置到了 (DFTDBPATH) = /home/db2tpcd下面;
对于DMS类型的表空间容器,放置到了redirect过程中指定的路径下(/db2home/tbs3)
数据库中的表数据也是正常的:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 list tables for schema tpcd
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
CUSTOMER TPCD T 2014-03-25-14.57.00.623279
LEOTEST TPCD T 2014-03-25-15.00.21.055254
LINEITEM TPCD T 2014-03-25-14.57.00.648033
NATION TPCD T 2014-03-25-14.57.00.188197
ORDERS TPCD T 2014-03-25-14.57.00.639085
PART TPCD T 2014-03-25-14.57.00.559978
PARTSUPP TPCD T 2014-03-25-14.57.00.603382
REGION TPCD T 2014-03-25-14.57.00.548104
SUPPLIER TPCD T 2014-03-25-14.57.00.573877
9 record(s) selected.
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 "select * from tpcd.leotest
> "
ID
-----------
2
1 record(s) selected.
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
结论2:
通过以上的带redirect选项的restore rebuild,可以得知:
对SMS表空间不需要设置表空间容器的新路径,会自动默认创建到DFTDBPATH指定的路径下(如果不是用on进行显示指定的话);
对DMS类型的表空间可以指定表空间的新路径;
在进行带redirect选项的restore rebuild时,一旦执行完restore rebuild命令,默认此时会已经连接到数据库中,提供一个设置表空间容器的机会,此时一定不要执行db2 terminate(断开连接),否则,将无法进行表空间容器的设置;
(2)在进行restore rebuild的过程中,使用on选项指定数据库重建的位置
上面展示的,数据库在restore rebuild的过程中,会自动建立到DFTDBPATH的路径下,但这往往不是我们想要的结果,因此,提供dbpath on选项能够让我们在进行数据库restore rebuild的时候,重新指定数据库的位置,进行验证测试如下:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 " restore database tpcd rebuild with all tablespaces in database taken at 20140325150157 dbpath on /db2home/tpcd/ redirect"
SQL1277W A redirected restore operation is being performed. Table space
configuration can now be viewed and table spaces that do not use automatic
storage can have their containers reconfigured.
DB20000I The RESTORE DATABASE command completed successfully.
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 list db directory
System Database Directory
Number of entries in the directory = 1
Database 1 entry:
Database alias = TPCD
Database name = TPCD
Local database directory = /db2home/tpcd
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
可以看到,数据库的路径已经改变;
继续设置DMS类型数据库的表空间容器位置:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 "set tablespace containers for 3 using (file '/db2home/tbs3' 1000)"
DB20000I The SET TABLESPACE CONTAINERS command completed successfully.
查看此时数据库的文件系统状况:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> ls /db2home/tpcd/
db2tpcd
db2tpcd@NODE2:/home/db2tpcd/temp_backup> ls /db2home/tpcd/db2tpcd/NODE0000/
1) SQL00001/
2) sqldbdir/
db2tpcd@NODE2:/home/db2tpcd/temp_backup> ls /db2home/tpcd/db2tpcd/NODE0000/SQL00001/
1) SQLBP.1
2) SQLBP.2
3) SQLDBCON
4) SQLDBCONF
5) SQLINSLK
6) SQLOGCTL.LFH.1
7) SQLOGCTL.LFH.2
8) SQLOGDIR/
9) SQLOGMIR.LFH
10) SQLSPCS.1
11) SQLSPCS.2
12) SQLTMPLK
13) db2event/
14) db2newdb.ske
15) db2rhist.asc
16) db2rhist.bak
db2tpcd@NODE2:/home/db2tpcd/temp_backup> ls /db2home/tpcd/db2tpcd/NODE0000/SQL00001/
db2event db2rhist.asc SQLBP.1 SQLDBCON SQLINSLK SQLOGCTL.LFH.2 SQLOGMIR.LFH SQLSPCS.2
db2newdb.ske db2rhist.bak SQLBP.2 SQLDBCONF SQLOGCTL.LFH.1 SQLOGDIR SQLSPCS.1 SQLTMPLK
继续执行restore:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 restore db tpcd continue
DB20000I The RESTORE DATABASE command completed successfully.
此时再查看数据库的文件系统状况:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> ls /db2home/tpcd/db2tpcd/NODE0000/SQL00001/
db2event db2rhist.bak SQLBP.2 SQLDBCONF SQLOGCTL.LFH.1 SQLOGDIR SQLSPCS.1 SQLT0000.0 SQLT0002.0
db2rhist.asc SQLBP.1 SQLDBCON SQLINSLK SQLOGCTL.LFH.2 SQLOGMIR.LFH SQLSPCS.2 SQLT0001.0 SQLTMPLK
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
能够看到新增的表空间的容器文件;
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2pd -d tpcd -tablespaces
Database Partition 0 -- Database TPCD -- Active -- Up 0 days 00:00:11
Tablespace Configuration:
Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name
0x00002B4B432C6D20 0 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 SYSCATSPACE
0x00002B4B439FB0A0 1 SMS SysTmp 4096 32 Yes 32 1 1 On 1 0 31 TEMPSPACE1
0x00002B4B43A005A0 2 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 USERSPACE1
0x00002B4B43A03A80 3 DMS Large 4096 4 Yes 4 1 1 Off 1 0 3 SYSTOOLSPACE
Tablespace Statistics:
Address Id TotalPgs UsablePgs UsedPgs PndFreePgs FreePgs HWM Max HWM State MinRecTime NQuiescers PathsDropped
0x00002B4B432C6D20 0 14844 14844 14844 0 0 0 0 0x00000000 0 0 No
0x00002B4B439FB0A0 1 1 1 1 0 0 0 0 0x00000000 0 0 No
0x00002B4B43A005A0 2 10 10 10 0 0 0 0 0x00000000 0 0 No
0x00002B4B43A03A80 3 1000 996 144 0 852 144 144 0x00000000 0 0 No
Tablespace Autoresize Statistics:
Address Id AS AR InitSize IncSize IIP MaxSize LastResize LRF
0x00002B4B432C6D20 0 No No 0 0 No 0 None No
0x00002B4B439FB0A0 1 No No 0 0 No 0 None No
0x00002B4B43A005A0 2 No No 0 0 No 0 None No
0x00002B4B43A03A80 3 No Yes 0 -1 No None None No
Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0x00002B4B432C81E0 0 0 Path 14844 14844 - 0 /db2home/tpcd/db2tpcd/NODE0000/SQL00001/SQLT0000.0
0x00002B4B432C8420 1 0 Path 1 1 - 0 /db2home/tpcd/db2tpcd/NODE0000/SQL00001/SQLT0001.0
0x00002B4B432C8660 2 0 Path 10 10 - 0 /db2home/tpcd/db2tpcd/NODE0000/SQL00001/SQLT0002.0
0x00002B4B432C8900 3 0 File 1000 996 - 0 /db2home/tbs3
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
结论3:
在使用restore rebuild的redirect选项过程中,可以使用dbpath on选项来指定数据库的位置;
3、使用重定向恢复:
上面的两种方法,都能够完成用一个离线备份在其他server建立类似测试环境的需求。但是,如果有大量的DMS类型的表空间,在进行上述操作时,进行手动设置,实在是一个太痛苦的事情,所以,DB2提供给我们重定向恢复的方法,来简化这个操作。测试操作如下:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 "restore db tpcd from /home/db2tpcd/temp_backup taken at 20140325150157 into tpcd2 redirect generate script tpcd.sql without >
DB20000I The RESTORE DATABASE command completed successfully.
db2tpcd@NODE2:/home/db2tpcd/temp_backup> ls -rtl
total 165185
-rw------- 1 db2tpcd tpcdiadm 90521600 2014-03-24 15:37 TPCD.0.db2tpcd.NODE0000.CATN0000.20140324153537.001
-rw-r--r-- 1 db2tpcd tpcdiadm 0 2014-03-25 11:14 db2
-rw------- 1 db2tpcd tpcdiadm 78454784 2014-03-25 15:03 TPCD.0.db2tpcd.NODE0000.CATN0000.20140325150157.001
-rw-r--r-- 1 db2tpcd tpcdiadm 4998 2014-03-26 14:06 tpcd.sql
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
脚本内容如下:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> more tpcd.sql
-- *****************************************************************************
-- ** automatically created redirect restore script
-- *****************************************************************************
UPDATE COMMAND OPTIONS USING S ON Z ON TPCD_NODE0000.out V ON;
SET CLIENT ATTACH_DBPARTITIONNUM 0;
SET CLIENT CONNECT_DBPARTITIONNUM 0;
-- *****************************************************************************
-- ** automatically created redirect restore script
-- *****************************************************************************
RESTORE DATABASE TPCD
-- USER
FROM '/home/db2tpcd/temp_backup'
TAKEN AT 20140325150157
-- DBPATH ON '' --此处可以修改为需要的位置,否则,执行此脚本恢复时,数据库,以及SMS类型的表空间将被放置到dbm cfg ---DFTDBPATH配置的路径下;
INTO TPCD2
-- NEWLOGPATH '/db2home/db2tpcd/NODE0000/SQL00001/SQLOGDIR/' --此处可以修改为需要的存放活动日志的位置
-- WITH BUFFERS
-- BUFFER
-- REPLACE HISTORY FILE
-- REPLACE EXISTING
REDIRECT
-- PARALLELISM
WITHOUT ROLLING FORWARD
-- WITHOUT PROMPTING
;
-- *****************************************************************************
-- ** table space definition
-- *****************************************************************************
-- *****************************************************************************
-- ** Tablespace name = SYSCATSPACE
-- ** Tablespace ID = 0
-- ** Tablespace Type = System managed space
-- ** Tablespace Content Type = All permanent data. Regular table space.
-- ** Tablespace Page size (bytes) = 4096
-- ** Tablespace Extent size (pages) = 32
-- ** Using automatic storage = No
-- ** Total number of pages = 14844
-- *****************************************************************************
SET TABLESPACE CONTAINERS FOR 0
-- IGNORE ROLLFORWARD CONTAINER OPERATIONS
USING (
PATH 'SQLT0000.0'
);
-- *****************************************************************************
-- ** Tablespace name = TEMPSPACE1
-- ** Tablespace ID = 1
-- ** Tablespace Type = System managed space
-- ** Tablespace Content Type = System Temporary data
-- ** Tablespace Page size (bytes) = 4096
-- ** Tablespace Extent size (pages) = 32
-- ** Using automatic storage = No
-- ** Total number of pages = 1
-- *****************************************************************************
SET TABLESPACE CONTAINERS FOR 1
-- IGNORE ROLLFORWARD CONTAINER OPERATIONS
USING (
PATH 'SQLT0001.0'
);
-- *****************************************************************************
-- ** Tablespace name = USERSPACE1
-- ** Tablespace ID = 2
-- ** Tablespace Type = System managed space --此类的表空间不用处理
-- ** Tablespace Content Type = All permanent data. Regular table space.
-- ** Tablespace Page size (bytes) = 4096
-- ** Tablespace Extent size (pages) = 32
-- ** Using automatic storage = No
-- ** Total number of pages = 10
-- *****************************************************************************
SET TABLESPACE CONTAINERS FOR 2
-- IGNORE ROLLFORWARD CONTAINER OPERATIONS
USING (
PATH 'SQLT0002.0'
);
-- *****************************************************************************
-- ** Tablespace name = SYSTOOLSPACE
-- ** Tablespace ID = 3
-- ** Tablespace Type = Database managed space
-- ** Tablespace Content Type = All permanent data. Large table space.
-- ** Tablespace Page size (bytes) = 4096
-- ** Tablespace Extent size (pages) = 4
-- ** Using automatic storage = No
-- ** Auto-resize enabled = Yes
-- ** Total number of pages = 8192
-- ** Number of usable pages = 8188
-- ** High water mark (pages) = 144
-- *****************************************************************************
SET TABLESPACE CONTAINERS FOR 3
-- IGNORE ROLLFORWARD CONTAINER OPERATIONS
USING (
FILE 'SYSTOOLSPACE' 8192
);
-- *****************************************************************************
-- ** start redirected restore
-- *****************************************************************************
RESTORE DATABASE TPCD CONTINUE;
-- *****************************************************************************
-- ** end of file
-- *****************************************************************************
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
生成脚本后,
对于其中的System managed space类型的表空间,不用修改;
对于其中的Database managed space类型的表空间,修改其位置到需要的位置,本次将其修改到/db2home/tpcd/tbs3下面;
SET TABLESPACE CONTAINERS FOR 3
-- IGNORE ROLLFORWARD CONTAINER OPERATIONS
USING (
FILE '/db2home/tpcd/tbs3' 8192
);
在执行脚本前,注意保证文件系统的大小应该大于表空间的高水位线,否则会失败;
执行:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 -tvf tpcd.sql
UPDATE COMMAND OPTIONS USING S ON Z ON TPCD_NODE0000.out V ON
DB20000I The UPDATE COMMAND OPTIONS command completed successfully.
SET CLIENT ATTACH_DBPARTITIONNUM 0
DB20000I The SET CLIENT command completed successfully.
SET CLIENT CONNECT_DBPARTITIONNUM 0
DB20000I The SET CLIENT command completed successfully.
RESTORE DATABASE TPCD FROM '/home/db2tpcd/temp_backup' TAKEN AT 20140325150157 INTO TPCD2 REDIRECT WITHOUT ROLLING FORWARD
SQL1277W A redirected restore operation is being performed. Table space
configuration can now be viewed and table spaces that do not use automatic
storage can have their containers reconfigured.
DB20000I The RESTORE DATABASE command completed successfully.
SET TABLESPACE CONTAINERS FOR 0 USING ( PATH 'SQLT0000.0' )
DB20000I The SET TABLESPACE CONTAINERS command completed successfully.
SET TABLESPACE CONTAINERS FOR 1 USING ( PATH 'SQLT0001.0' )
DB20000I The SET TABLESPACE CONTAINERS command completed successfully.
SET TABLESPACE CONTAINERS FOR 2 USING ( PATH 'SQLT0002.0' )
DB20000I The SET TABLESPACE CONTAINERS command completed successfully.
SET TABLESPACE CONTAINERS FOR 3 USING ( FILE '/db2home/tpcd/tbs3' 8192 )
DB20000I The SET TABLESPACE CONTAINERS command completed successfully.
RESTORE DATABASE TPCD CONTINUE
DB20000I The RESTORE DATABASE command completed successfully.
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
查看执行结果:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 list db directory
System Database Directory
Number of entries in the directory = 1
Database 1 entry:
Database alias = TPCD2
Database name = TPCD2 ---数据库名称已经被修改
Local database directory = /home/db2tpcd
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 connect to tpcd2
Database Connection Information
Database server = DB2/LINUXX8664 9.7.0
SQL authorization ID = DB2TPCD
Local database alias = TPCD2
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2pd -d tpcd2 -tablespaces
Database Partition 0 -- Database TPCD2 -- Active -- Up 0 days 00:00:12
Tablespace Configuration:
Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name
0x00002B4B432C6D20 0 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 SYSCATSPACE
0x00002B4B439FB0A0 1 SMS SysTmp 4096 32 Yes 32 1 1 On 1 0 31 TEMPSPACE1
0x00002B4B43A005A0 2 SMS Regular 4096 32 Yes 32 1 1 Off 1 0 31 USERSPACE1
0x00002B4B43A03A80 3 DMS Large 4096 4 Yes 4 1 1 Off 1 0 3 SYSTOOLSPACE
Tablespace Statistics:
Address Id TotalPgs UsablePgs UsedPgs PndFreePgs FreePgs HWM Max HWM State MinRecTime NQuiescers PathsDropped
0x00002B4B432C6D20 0 14844 14844 14844 0 0 0 0 0x00000000 0 0 No
0x00002B4B439FB0A0 1 1 1 1 0 0 0 0 0x00000000 0 0 No
0x00002B4B43A005A0 2 10 10 10 0 0 0 0 0x00000000 0 0 No
0x00002B4B43A03A80 3 8192 8188 144 0 8044 144 144 0x00000000 0 0 No
Tablespace Autoresize Statistics:
Address Id AS AR InitSize IncSize IIP MaxSize LastResize LRF
0x00002B4B432C6D20 0 No No 0 0 No 0 None No
0x00002B4B439FB0A0 1 No No 0 0 No 0 None No
0x00002B4B43A005A0 2 No No 0 0 No 0 None No
0x00002B4B43A03A80 3 No Yes 0 -1 No None None No
Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0x00002B4B432C81E0 0 0 Path 14844 14844 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SQLT0000.0
0x00002B4B432C8420 1 0 Path 1 1 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SQLT0001.0
0x00002B4B432C8660 2 0 Path 10 10 - 0 /home/db2tpcd/db2tpcd/NODE0000/SQL00001/SQLT0002.0
0x00002B4B432C8900 3 0 File 8192 8188 - 0 /db2home/tpcd/tbs3
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
除了DMS表空间被手动设置之后,其他的SMS类型的表空间都保存到了DFTDBPATH之下;
尝试查询:
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 list tables for schema tpcd
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
CUSTOMER TPCD T 2014-03-25-14.57.00.623279
LEOTEST TPCD T 2014-03-25-15.00.21.055254
LINEITEM TPCD T 2014-03-25-14.57.00.648033
NATION TPCD T 2014-03-25-14.57.00.188197
ORDERS TPCD T 2014-03-25-14.57.00.639085
PART TPCD T 2014-03-25-14.57.00.559978
PARTSUPP TPCD T 2014-03-25-14.57.00.603382
REGION TPCD T 2014-03-25-14.57.00.548104
SUPPLIER TPCD T 2014-03-25-14.57.00.573877
9 record(s) selected.
db2tpcd@NODE2:/home/db2tpcd/temp_backup> db2 "select * from tpcd.leotest"
ID
-----------
2
1 record(s) selected.
db2tpcd@NODE2:/home/db2tpcd/temp_backup>
结论3:
使用生成重定向恢复脚本的重定向恢复,
需要手动修改DMS类型的表空间的文件系统位置,同时需要保证文件系统的容量应该大于表空间的高水位线;
可以修改数据库名字和数据库的位置;
相对省事一些(除了有大量的DMS类型的表空间需要进行手动设置位置)。
以上讨论了使用离线备份在其他server上面进行数据库搭建的方法。以上方法的前提假设都是其他的server没有和数据库备份所要求的文件系统。因此,如果其他server上面能够建立和备份要求的一样的文件系统,进行建立的时候,可能会更加省事(直接restore)。