LoveUnix » DB2 & Informix » backup and restore
让LU留住您的每

一天 让LU博客留住您的每一天
2007-5-23 17:06 eagle
backup and restore

看书上写
During a backup of a database, a record is kept of all the table space containers in use by the table spaces being backed up. During a restore, all containers listed in the backup are checked to see if they currently exist and are accessible. If one or more of the containers is inaccessible for any other reason, the restore will fail.

sample数据库
1,先备份
2,drop table staff
3,mv SQLT0002.0 SQLT0002.0.bk
4,查看状态

Tablespace ID                        = 2
Name                                 = USERSPACE1
Type                                 = System managed space
Contents                             = Any data
State                                = 0x4000
5,restore
成功
怎么与上面的描述不一致,并没有失败啊,而是重建了这个container

不知道什么原因,请教各位,谢谢

2007-5-24 10:50 beginner-bj
Tablespace ID  = 0,1,2的可能特殊一点吧

2007-5-24 11:33 eagle
哦,那我再建几个tablespace试试看
谢谢

2007-5-28 12:51 darkbug
[quote]原帖由 [i]eagle[/i] 于 2007-5-24 11:33 发表 [url=http://bbs.loveunix.net/redirect.php?goto=findpost&pid=664260&ptid=72519][img]http://bbs.loveunix.net/images/common/back.gif[/img][/url]
哦,那我再建几个tablespace试试看
谢谢 [/quote]

有测试结果了吗

2007-5-28 17:05 eagle
测试了一下,对于使用目录的还是可以恢复的,不会失败;
使用device的,则会失败,失败的错误是:SQL0970N  The system attempted to write to a read-only file.  SQLSTATE=55009,不知道是不是测试的步骤有问题,要是错误提示one or more of the containers is inaccessible,则比较符合上文的描述。
$ db2level
DB21085I  Instance "db2inst1" uses "32" bits and DB2 code release "SQL08020"
with level identifier "03010106".
Informational tokens are "DB2 v8.1.1.64", "s040812", "U498350", and FixPak "7".
Product is installed at "/usr/opt/db2_08_01".

测试的过程
$ db2 list tablespace containers for 4 show detail

            Tablespace Containers for Tablespace 4

Container ID                         = 0
Name                                 = /db2_db/bill
Type                                 = Path
Total pages                          = 1
Useable pages                        = 1
Accessible                           = Yes

$ cd /db2_db
$ rm -r bill
$ db2 list tablespace containers for 4 show detail

            Tablespace Containers for Tablespace 4

Container ID                         = 0
Name                                 = /db2_db/bill
Type                                 = Path
Total pages                          = 1
Useable pages                        = 1
Accessible                           = No

$ cd /db2_db
$ ls
SAMPLE.0.db2inst1.NODE0000.CATN0000.20070528171046.001
db2inst1
lost+found
$ db2 restore db sample from /db2_db
SQL2539W  Warning!  Restoring to an existing database that is the same as the ba
ckup image database.  The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I  The RESTORE DATABASE command completed successfully.
$ pwd
/db2_db
$ ls -l
total 106096
-rw-r-----   1 db2inst1 db2grp1    54308864 May 28 17:11 SAMPLE.0.db2inst1.NODE0
000.CATN0000.20070528171046.001
drwxr-x---   2 db2inst1 db2grp1         512 May 28 17:42 bill
drwxrwxr-x   3 db2inst1 db2grp1         512 May 28 17:29 db2inst1
drwxrwx---   2 db2inst1 db2grp1         512 Apr 16 15:32 lost+found



$ db2 list tablespace containers for 4 show detail

            Tablespace Containers for Tablespace 4

Container ID                         = 0
Name                                 = /db2_db/bill
Type                                 = Path
Total pages                          = 1
Useable pages                        = 1
Accessible                           = Yes

以下使用裸设备情况
$ db2 list tablespace containers for 5 show detail

            Tablespace Containers for Tablespace 5

Container ID                         = 0
Name                                 = /dev/rdb2lv03
Type                                 = Disk
Total pages                          = 16384
Useable pages                        = 16352
Accessible                           = Yes

$ exit
# cd /dev
# mv rdb2lv03 rdb2lv03bk


$ db2 list tablespace containers for 5 show detail

            Tablespace Containers for Tablespace 5

Container ID                         = 0
Name                                 = /dev/rdb2lv03
Type                                 = Disk
Total pages                          = 16384
Useable pages                        = 16352
Accessible                           = No

$ db2 restore db sample from /db2_db
SQL2539W  Warning!  Restoring to an existing database that is the same as the ba
ckup image database.  The database files will be deleted.
Do you want to continue ? (y/n) y
SQL0970N  The system attempted to write to a read-only file.  SQLSTATE=55009

2007-5-28 17:44 beginner-bj
对于使用目录的测试步骤,你的/db2_db应该是个文件系统,假如/db2_db不存在,估计RESTORE的时候也会报错。

页: [1]
查看完整版本: backup and restore


Powered by Discuz! Archiver 5.5.0  © 2001-2006 Comsenz Inc.