Chinaunix首页 | 论坛 | 博客
  • 博客访问: 706348
  • 博文数量: 147
  • 博客积分: 5347
  • 博客等级: 大校
  • 技术积分: 1453
  • 用 户 组: 普通用户
  • 注册时间: 2005-06-06 11:11
文章分类

全部博文(147)

文章存档

2014年(4)

2012年(9)

2011年(5)

2010年(28)

2009年(21)

2008年(29)

2007年(15)

2006年(17)

2005年(19)

我的朋友

分类:

2009-10-27 23:48:59

db2 list tablespace containers for 3
 
            Tablespace Containers for Tablespace 3
 Container ID                         = 0
 Name                                 = /archivelog/tbs/fangys_tbs.dbf
 Type                                 = File
 
恢复数据库后成
 
db2 list tablespace containers for 3
            Tablespace Containers for Tablespace 3
 Container ID                         = 0
 Name                                 = /fangys_db/fangys_tbs.dbf
 Type                                 = File
 
1、恢复数据库从原来的/db2目录下,恢复到/fangys_db;归档日志恢复到/archivelog/new目录下:
 [db2inst1@home tbs]$ db2 "restore database fangys from /archivelog taken at 20091027225833 to /fangys_db logtarget /archivelog/new redirect"
SQL1277N  Restore has detected that one or more table space containers are
inaccessible, or has set their state to 'storage must be defined'.
DB20000I  The RESTORE DATABASE command completed successfully.
 
2、检查恢复的表空间的情况:
   2-1)  db2 list tablespaces
           Tablespaces for Current Database
 Tablespace ID                        = 0
 Name                                 = SYSCATSPACE
 Type                                 = System managed space
 Contents                             = Any data
 State                                = 0x2001100
   Detailed explanation:
     Restore pending
     Storage must be defined
     Storage may be defined
 Tablespace ID                        = 1
 Name                                 = TEMPSPACE1
 Type                                 = System managed space
 Contents                             = System Temporary data
 State                                = 0x2001100
   Detailed explanation:
     Restore pending
     Storage must be defined
     Storage may be defined
 Tablespace ID                        = 2
 Name                                 = USERSPACE1
 Type                                 = System managed space
 Contents                             = Any data
 State                                = 0x2001100
   Detailed explanation:
     Restore pending
     Storage must be defined
     Storage may be defined
 Tablespace ID                        = 3
 Name                                 = FANGYS_TBS
 Type                                 = Database managed space
 Contents                             = Any data
 State                                = 0x2001100
   Detailed explanation:
     Restore pending
     Storage must be defined
     Storage may be defined
 
   2-2) db2 list tablespace containers for 0
            Tablespace Containers for Tablespace 0
 Container ID                         = 0
 Name                                 = /fangys_db/db2inst1/NODE0000/SQL00001/SQLT0000.0    ----已在新路径下
 Type                                 = Path

[db2inst1@home tbs]$ db2 list tablespace containers for 1
            Tablespace Containers for Tablespace 1
 Container ID                         = 0
 Name                                 = /fangys_db/db2inst1/NODE0000/SQL00001/SQLT0001.0   ----已在新路径下
 Type                                 = Path

[db2inst1@home tbs]$ db2 list tablespace containers for 2
            Tablespace Containers for Tablespace 2
 Container ID                         = 0
 Name                                 = /fangys_db/db2inst1/NODE0000/SQL00001/SQLT0002.0  ----已在新路径下
 Type                                 = Path

[db2inst1@home tbs]$ db2 list tablespace containers for 3 show detail
            Tablespace Containers for Tablespace 3
 Container ID                         = 0
 Name                                 = /archivelog/tbs/fangys_tbs.dbf
                                        ----需要重定向
 Type                                 = File
 Total pages                          = 10000  ----重定向后文件大小
 Useable pages                        = 9952
 Accessible                           = No
 
3、将表空间3更改到新目的地:
 [db2inst1@home tbs]$ db2 "set tablespace containers for 3 using (file '/fangys_db/fangys_tbs.dbf' 10000)"
DB20000I  The SET TABLESPACE CONTAINERS command completed successfully.
 
4、继续恢复数据库:
   [db2inst1@home tbs]$ db2 "restore database fangys continue"
DB20000I  The RESTORE DATABASE command completed successfully.
 
   db2 get db cfg for fangys
   
   Database is consistent                                  = YES
    Rollforward pending                                     = DATABASE
    Restore pending                                         = NO 
 
5、前滚日志:
   [db2inst1@home tbs]$ db2 "rollforward database fangys to end of logs and complete overflow log path (/archivelog/new)"
                                 Rollforward Status
 Input database alias                   = fangys
 Number of nodes have returned status   = 1
 Node number                            = 0
 Rollforward status                     = not pending
 Next log file to be read               =
 Log files processed                    = S0000012.LOG - S0000012.LOG
 Last committed transaction             = 2009-10-27-14.58.43.000000
DB20000I  The ROLLFORWARD command completed successfully.
 
6、查看数据库配置及连接数据库:\
   db2 get db cfg for fangys
   
    Database is consistent                                  = YES
    Rollforward pending                                     = NO
    Restore pending                                         = NO
 
   db2 connect to fangys
    Database Connection Information
    Database server        = DB2/LINUX 8.2.9
    SQL authorization ID   = DB2INST1
    Local database alias   = FANGYS
 
7、查看数据库位置:
    db2 list tablespace containers for /01/2/3
   
       Tablespace Containers for Tablespace 3
 Container ID                         = 0
 Name                                 = /fangys_db/fangys_tbs.dbf
 Type                                 = File
 Total pages                          = 10000
 Useable pages                        = 9952
 Accessible                           = Yes
[db2inst1@home tbs]$ db2  list tablespace containers for 1 show detail
            Tablespace Containers for Tablespace 1
 Container ID                         = 0
 Name                                 = /fangys_db/db2inst1/NODE0000/SQL00001/SQLT0001.0
 Type                                 = Path
 Total pages                          = 1
 Useable pages                        = 1
 Accessible                           = Yes
[db2inst1@home tbs]$ db2  list tablespace containers for 2 show detail
            Tablespace Containers for Tablespace 2
 Container ID                         = 0
 Name                                 = /fangys_db/db2inst1/NODE0000/SQL00001/SQLT0002.0
 Type                                 = Path
 Total pages                          = 354
 Useable pages                        = 354
 Accessible                           = Yes
[db2inst1@home tbs]$ db2  list tablespace containers for 0 show detail
            Tablespace Containers for Tablespace 0
 Container ID                         = 0
 Name                                 = /fangys_db/db2inst1/NODE0000/SQL00001/SQLT0000.0
 Type                                 = Path
 Total pages                          = 4594
 Useable pages                        = 4594
 Accessible                           = Yes
 
 
注:
原有数据库表空间存放路径:
db2 list tablespace containers for 0
            Tablespace Containers for Tablespace 0
 Container ID                         = 0
 Name                                 = /db2/db2inst1/NODE0000/SQL00002/SQLT0000.0
 
Type                                 = Path

[db2inst1@home new]$ db2 list tablespace containers for 1
            Tablespace Containers for Tablespace 1
 Container ID                         = 0
 Name                                 = /db2/db2inst1/NODE0000/SQL00002/SQLT0001.0
 
Type                                 = Path

[db2inst1@home new]$ db2 list tablespace containers for 2
            Tablespace Containers for Tablespace 2
 Container ID                         = 0
 Name                                 = /db2/db2inst1/NODE0000/SQL00002/SQLT0002.0
 
Type                                 = Path

[db2inst1@home new]$ db2 list tablespace containers for 3
            Tablespace Containers for Tablespace 3
 Container ID                         = 0
 Name                                 = /archivelog/tbs/fangys_tbs.dbf
 Type                                 = File
阅读(3621) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~