一、备份数据库
[db2inst2@localhost ~]$ db2 backup db ghan to /db2inst2/
备份成功。此备份映像的时间戳记是:20151102072618
二、生成数据库定向还原脚本
[db2inst2@localhost ~]$ db2 restore db ghan from /db2inst2/ taken at 20151102072618 redirect generate script redirect123.ddl
DB20000I RESTORE DATABASE 命令成功完成。
三、自定义还原数据库及容器目录
[db2inst2@localhost ~]$vi redirect123.ddl //修改用户名及容器路径
1、修改:inot 重定向用户名:
2、修改:TABLESPACE CONTAINERS 路径
3、注意 自动存储管理不能重定向、且 RESTORE DATABASE 原数据库名 CONTINUE。
四、执行自定还原脚本
[db2inst2@localhost ~]$ db2 -tvsf redirect123.ddl
UPDATE COMMAND OPTIONS USING S ON Z ON GHAN_NODE0000.out V ON
DB20000I UPDATE COMMAND OPTIONS 命令成功完成。
SET CLIENT ATTACH_DBPARTITIONNUM 0
DB20000I SET CLIENT 命令成功完成。
SET CLIENT CONNECT_DBPARTITIONNUM 0
DB20000I SET CLIENT 命令成功完成。
RESTORE DATABASE GHAN FROM '/db2inst2/' TAKEN AT 20151102072618 INTO TANK123 REDIRECT
SQL2529W 警告!复原到与备份映像数据库不同的现有数据库中
,现有数据库的别名 "TANK123" 与备份映像的别名 "GHAN"
不匹配,现有数据库的数据库名称 "TANK123"
与备份映像的数据库名称 "GHAN"
不匹配。目标数据库将被备份版本覆盖。将删除与目标数据库
相关联的前滚恢复日志。
想要继续吗?(y/n) y
SQL1277W 正在执行重定向复原操作。现在,可以查看表空间配
置,并且不使用自动存储器的表空间可以重新配置它们的容器
。
DB20000I RESTORE DATABASE 命令成功完成。
SET TABLESPACE CONTAINERS FOR 4 USING ( FILE '/db2inst2/data_tb/cont0_123' 6400 , FILE '/db2inst2/data_tb/cont1_123' 19200 )
DB20000I SET TABLESPACE CONTAINERS 命令成功完成。
SET TABLESPACE CONTAINERS FOR 5 USING ( PATH '/db2inst2/data_tb/tab_temp_123' )
DB20000I SET TABLESPACE CONTAINERS 命令成功完成。
SET TABLESPACE CONTAINERS FOR 6 USING ( PATH '/db2inst2/data_tb/tab_usertemp_123' )
DB20000I SET TABLESPACE CONTAINERS 命令成功完成。
db2 "RESTORE DATABASE GHAN CONTINUE"
DB20000I RESTORE DATABASE 命令成功完成。。
五、前滚数据库
[db2inst2@localhost ~]$ db2 rollforward db tank123 to end of logs and stop
前滚状态
输入数据库别名 = tank123
节点数已返回状态 = 1
节点号 = 0
前滚状态 = 未暂挂
下一个要读取的日志文件 =
已处理的日志文件 = -
上次落实的事务 = 2015-11-01-23.29.36.000000 UTC
DB20000I ROLLFORWARD 命令成功完成。
六、查看还原结果
[db2inst2@localhost ~]$ db2 "select count(*) from empl"
1
-----------
4660010
1 条记录已选择。
七、查看目录数据库表空间信息
[db2inst2@localhost ~]$ db2pd -d tank123 -tablespace
Database Partition 0 -- Database TANK123 -- Active -- Up 0 days 00:02:51 -- Date 11/02/2015 08:42:20
Tablespace Configuration:
Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name
0x00002AE083E62500 0 DMS Regular 4096 4 Yes 8 1 1 Off 2 0 3 SYSCATSPACE
0x00002AE083E63E80 1 SMS SysTmp 4096 32 Yes 64 1 1 On 2 0 31 TEMPSPACE1
0x00002AE083E677C0 2 DMS Large 4096 32 Yes 64 1 1 Off 2 0 31 USERSPACE1
0x00002AE083E69140 3 DMS Large 4096 4 Yes 8 1 1 Off 2 0 3 SYSTOOLSPACE
0x00002AE083E6AAC0 4 DMS Large 32768 32 Yes 64 2 2 Off 2 0 31 TBS_DATA
0x00002AE083E6C480 5 SMS SysTmp 32768 32 Yes 32 2 2 On 1 0 31 TBS_TEMP
0x00002AE083E6FBC0 6 SMS UsrTmp 32768 32 Yes 32 2 2 On 1 0 31 TBS_USERTEMP
0x00002AE083E73300 7 DMS Large 4096 32 Yes 64 1 1 Off 2 0 31 TAB_DATA2
0x00002AE083E74C80 8 DMS Large 32768 32 Yes 64 2 2 Off 2 0 31 TAB_DATA3
0x00002AE083E76600 9 DMS Large 4096 32 Yes 64 1 1 Off 2 0 31 TAB_SP4
0x00002AE083E77F80 10 SMS UsrTmp 4096 4 Yes 8 1 1 On 2 0 3 SYSTOOLSTMPSPACE
Tablespace Statistics:
Address Id TotalPgs UsablePgs UsedPgs PndFreePgs FreePgs HWM Max HWM State MinRecTime NQuiescers PathsDropped
0x00002AE083E62500 0 24584 24576 23644 0 932 23644 23644 0x00000000 0 0 No
0x00002AE083E63E80 1 2 2 2 0 0 0 0 0x00000000 0 0 No
0x00002AE083E677C0 2 8256 8192 3136 0 5056 3136 3136 0x00000000 0 0 No
0x00002AE083E69140 3 8200 8192 152 0 8040 152 152 0x00000000 0 0 No
0x00002AE083E6AAC0 4 25600 25536 8544 0 16992 8544 8544 0x00000000 0 0 No
0x00002AE083E6C480 5 1 1 1 0 0 0 0 0x00000000 0 0 No
0x00002AE083E6FBC0 6 1 1 1 0 0 0 0 0x00000000 0 0 No
0x00002AE083E73300 7 51200 51136 800 0 50336 800 800 0x00000000 0 0 No
0x00002AE083E74C80 8 2048 1984 96 0 1888 96 96 0x00000000 0 0 No
0x00002AE083E76600 9 8448 8384 352 0 8032 352 352 0x00000000 0 0 No
0x00002AE083E77F80 10 2 2 2 0 0 0 0 0x00000000 0 0 No
Tablespace Autoresize Statistics:
Address Id AS AR InitSize IncSize IIP MaxSize LastResize LRF
0x00002AE083E62500 0 Yes Yes 33554432 -1 No None None No
0x00002AE083E63E80 1 Yes No 0 0 No 0 None No
0x00002AE083E677C0 2 Yes Yes 33554432 -1 No None None No
0x00002AE083E69140 3 Yes Yes 33554432 -1 No None None No
0x00002AE083E6AAC0 4 No No 0 0 No 0 None No
0x00002AE083E6C480 5 No No 0 0 No 0 None No
0x00002AE083E6FBC0 6 No No 0 0 No 0 None No
0x00002AE083E73300 7 Yes Yes 104857600 104857600 No 10737418240 None No
0x00002AE083E74C80 8 Yes Yes 33554432 -1 No None None No
0x00002AE083E76600 9 Yes Yes 786432 -1 No None None No
0x00002AE083E77F80 10 Yes No 0 0 No 0 None No
Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0x00002AE083E63A40 0 0 File 12292 12288 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/TANK123/T0000000/C0000000.CAT
0x00002AE083E63C50 0 1 File 12292 12288 1 0 /db2inst2/autodb/db2inst2/NODE0000/TANK123/T0000000/C0000001.CAT
0x00002AE083E65360 1 0 Path 1 1 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/TANK123/T0000001/C0000000.TMP
0x00002AE083E65570 1 1 Path 1 1 1 0 /db2inst2/autodb/db2inst2/NODE0000/TANK123/T0000001/C0000001.TMP
0x00002AE083E68D00 2 0 File 4128 4096 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/TANK123/T0000002/C0000000.LRG
0x00002AE083E68F10 2 1 File 4128 4096 1 0 /db2inst2/autodb/db2inst2/NODE0000/TANK123/T0000002/C0000001.LRG
0x00002AE083E6A680 3 0 File 4100 4096 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/TANK123/T0000003/C0000000.LRG
0x00002AE083E6A890 3 1 File 4100 4096 1 0 /db2inst2/autodb/db2inst2/NODE0000/TANK123/T0000003/C0000001.LRG
0x00002AE083E6C040 4 0 File 6400 6368 - 0 /db2inst2/data_tb/cont0_123
0x00002AE083E6C250 4 1 File 19200 19168 - 0 /db2inst2/data_tb/cont1_123
0x00002AE083E6D960 5 0 Path 1 1 - 0 /db2inst2/data_tb/tab_temp_123
0x00002AE083E710A0 6 0 Path 1 1 - 0 /db2inst2/data_tb/tab_usertemp_123
0x00002AE083E74840 7 0 File 25600 25568 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/TANK123/T0000007/C0000000.LRG
0x00002AE083E74A50 7 1 File 25600 25568 1 0 /db2inst2/autodb/db2inst2/NODE0000/TANK123/T0000007/C0000001.LRG
0x00002AE083E761C0 8 0 File 1024 992 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/TANK123/T0000008/C0000000.LRG
0x00002AE083E763D0 8 1 File 1024 992 1 0 /db2inst2/autodb/db2inst2/NODE0000/TANK123/T0000008/C0000001.LRG
0x00002AE083E77B40 9 0 File 4224 4192 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/TANK123/T0000009/C0000000.LRG
0x00002AE083E77D50 9 1 File 4224 4192 1 0 /db2inst2/autodb/db2inst2/NODE0000/TANK123/T0000009/C0000001.LRG
0x00002AE083E79460 10 0 Path 1 1 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/TANK123/T0000010/C0000000.UTM
0x00002AE083E79670 10 1 Path 1 1 1 0 /db2inst2/autodb/db2inst2/NODE0000/TANK123/T0000010/C0000001.UTM
[db2inst2@localhost ~]$
阅读(3247) | 评论(0) | 转发(0) |