标题: backup and restore
eagle
LU小天使
Rank: 3Rank: 3



UID 39336
精华 0
积分 320
帖子 484
活跃指数 26
LU金币 412 个
LU金条 0 个
阅读权限 20
注册 2006-1-10
 
发表于 2007-5-23 17:06  资料  个人空间  短消息  加为好友 
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

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

顶部
beginner-bj
版主
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15


UID 9471
精华 15
积分 1369
帖子 2357
活跃指数 186
LU金币 4352 个
LU金条 0 个
阅读权限 210
注册 2004-1-16
 
发表于 2007-5-24 10:50  资料  个人空间  短消息  加为好友 
Tablespace ID  = 0,1,2的可能特殊一点吧





我的博客:http://blog.chinaunix.net/index.php?blogId=739欢迎访问,并请多多批评指正。
顶部
eagle
LU小天使
Rank: 3Rank: 3



UID 39336
精华 0
积分 320
帖子 484
活跃指数 26
LU金币 412 个
LU金条 0 个
阅读权限 20
注册 2006-1-10
 
发表于 2007-5-24 11:33  资料  个人空间  短消息  加为好友 
哦,那我再建几个tablespace试试看
谢谢

顶部
darkbug
超级版主
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17


UID 187
精华 12
积分 2224
帖子 4133
活跃指数 247
LU金币 3382 个
LU金条 161170 个
阅读权限 251
注册 2003-9-28
 
发表于 2007-5-28 12:51  资料  个人空间  短消息  加为好友  添加 darkbug 为MSN好友 通过MSN和 darkbug 交谈


QUOTE:
原帖由 eagle 于 2007-5-24 11:33 发表
哦,那我再建几个tablespace试试看
谢谢

有测试结果了吗





踏踏实实学习,认认真真干活
顶部
eagle
LU小天使
Rank: 3Rank: 3



UID 39336
精华 0
积分 320
帖子 484
活跃指数 26
LU金币 412 个
LU金条 0 个
阅读权限 20
注册 2006-1-10
 
发表于 2007-5-28 17:05  资料  个人空间  短消息  加为好友 
测试了一下,对于使用目录的还是可以恢复的,不会失败;
使用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

顶部
beginner-bj
版主
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15


UID 9471
精华 15
积分 1369
帖子 2357
活跃指数 186
LU金币 4352 个
LU金条 0 个
阅读权限 210
注册 2004-1-16
 
发表于 2007-5-28 17:44  资料  个人空间  短消息  加为好友 
对于使用目录的测试步骤,你的/db2_db应该是个文件系统,假如/db2_db不存在,估计RESTORE的时候也会报错。





我的博客:http://blog.chinaunix.net/index.php?blogId=739欢迎访问,并请多多批评指正。
顶部
 



当前时区 GMT+8, 现在时间是 2008-7-7 11:18
乐悠LoveUnix论坛-京ICP备05005823号

Thanks to Discuz!  © 2001-2007    Power by LoveUnix.net
Processed in 0.056261 second(s), 6 queries , Gzip enabled

清除 Cookies - 联系我们 - 乐悠LoveUnix - Archiver - WAP