分类目录归档:DB2

DB2数据迁移之load

一.load原理性知识
1.为什么要使用LOAD
load不需要写日志(或很少日志),不做检查约束和参照完整性约束,不触发Trigger,锁的时间比较短,因此特别适合大数据量的导入.

2.load过程分为4个阶段
load/build/delete/index copy.
load阶段是将源文件parser成物理数据存储的格式,直接装入到页中,而不通过db2引擎,load阶段会检查表定义,违背定义的数据不会装入到表中.
build阶段建议索引(如果装入表有索引的话),会检查唯一性约束,违背了唯一性的数据会在delete阶段删除.
index copy阶段将index数据从指定的临时表空间拷贝到初始的表空间里.
index copy只适应于allow read access场景.load的4个阶段会记录在messages文件里.

3.load的offline和online
缺省情况下,load过程不允许其他应用访问表,即allow no access,或叫offline load(离线加载).Allow read access,或叫online load(在线加载),只有在load …insert into的时候才允许使用,其他应用读到的数据是加载前的数据,load … replace into会将数据先删除,再load,只能是离线加载.

4.load表的状态
load可能出现的几种状态,某一时刻可能会同时处于几种状态.只有当表是normal状态时,表才能进行正常的增删改查操作.
normal: 正常状态
set integrity pending: 如果目标表有check约束或reference约束,那么Load后此表处于set integrity pending,表明表有约束还未检查,稍后解释.
load in progress:load正在数据加载过程中.
load pending:数据提交前出现了故障,需要通过load..terminate,load..replace或load..restart解除暂挂状态
read access only:目标表数据是可以读的,当load时指定了allow read access,那表就会处于read access only状态
unavailable:表可能被删除了或从backup中恢复了.
unknown:通过load..query命令无法得知表的状态.

二.load试验测试
需要导入数据

[db2inst2@xifenfei ~]$ more /tmp/xifenfei.data 
10,"MANAGE","MANAGE/ADVISE"
20,"ECOST ","ESTIMATE COST"
30,,"DEFINE SPECS"
40,"LEADPR","LEAD PROGRAM/DESIGN"
50,"SPECS ",
60,"LOGIC ","DESCRIBE LOGIC"
70,"CODE  ","CODE PROGRAMS"
80,"TEST  ","TEST PROGRAMS"
90,"ADMQS ","ADM QUERY SYSTEM"
100,"TEACH ","TEACH CLASSES"
110,"COURSE","DEVELOP COURSES"
60,"STAFF ","PERS AND STAFFING"
130,"OPERAT","OPER COMPUTER SYS"
140,"MAINT ","MAINT SOFTWARE SYS"
150,"ADMSYS","ADM OPERATING SYS"
160,"ADMDB ","ADM DATA BASES"
170,"ADMDC ","ADM DATA COMM"
80,"DOC   ","DOCUMENT"

一共18条记录

创建目标表

[db2inst2@xifenfei ~]$ db2 "CREATE TABLE XIFENFEI_LOAD(ACTNO SMALLINT NOT NULL primary key,
> ACTKWD CHAR(6) NOT NULL,ACTDESC VARCHAR(20) NOT NULL)"
DB20000I  The SQL command completed successfully.
[db2inst2@xifenfei ~]$ db2 list tables

Table/View                      Schema          Type  Creation time             
------------------------------- --------------- ----- --------------------------
XIFENFEI_LOAD                   DB2INST2        T     2012-04-05-18.53.42.296503

  1 record(s) selected.

[db2inst2@xifenfei ~]$ db2 describe table xifenfei_load

                                Data type                     Column
Column name                     schema    Data type name      Length     Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
ACTNO                           SYSIBM    SMALLINT                     2     0 No    
ACTKWD                          SYSIBM    CHARACTER                    6     0 No    
ACTDESC                         SYSIBM    VARCHAR                     20     0 No    

  3 record(s) selected.

创建异常表

[db2inst2@xifenfei ~]$ db2 "create table xifenfei_exp like xifenfei_load"
DB20000I  The SQL command completed successfully.

[db2inst2@xifenfei ~]$ db2 "alter table xifenfei_exp add column ts timestamp
> add column msg clob(32k)"
DB20000I  The SQL command completed successfully.
[db2inst2@xifenfei ~]$ db2 describe table xifenfei_exp

                                Data type                     Column
Column name                     schema    Data type name      Length     Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
ACTNO                           SYSIBM    SMALLINT                     2     0 No    
ACTKWD                          SYSIBM    CHARACTER                    6     0 No    
ACTDESC                         SYSIBM    VARCHAR                     20     0 No    
TS                              SYSIBM    TIMESTAMP                   10     0 Yes   
MSG                             SYSIBM    CLOB                     32768     0 Yes   

  5 record(s) selected.

load导入数据

[db2inst2@xifenfei ~]$ db2 "load from /tmp/xifenfei.data of del modified by dumpfile=/tmp/xifenfei.dmp
messages xifenfei.msg insert into xifenfei_load for exception xifenfei_exp"

Number of rows read         = 18
Number of rows skipped      = 0
Number of rows loaded       = 16
Number of rows rejected     = 2
Number of rows deleted      = 2
Number of rows committed    = 18

SQL3107W  There is at least one warning message in the message file.

提示一共18条记录,成功了14条,拒绝2条,删除2条

查看表中记录

[db2inst2@xifenfei ~]$ db2 "select * from xifenfei_load"

ACTNO  ACTKWD ACTDESC             
------ ------ --------------------
    10 MANAGE MANAGE/ADVISE       
    20 ECOST  ESTIMATE COST       
    40 LEADPR LEAD PROGRAM/DESIGN 
    60 LOGIC  DESCRIBE LOGIC      
    70 CODE   CODE PROGRAMS       
    80 TEST   TEST PROGRAMS       
    90 ADMQS  ADM QUERY SYSTEM    
   100 TEACH  TEACH CLASSES       
   110 COURSE DEVELOP COURSES     
   130 OPERAT OPER COMPUTER SYS   
   140 MAINT  MAINT SOFTWARE SYS  
   150 ADMSYS ADM OPERATING SYS   
   160 ADMDB  ADM DATA BASES      
   170 ADMDC  ADM DATA COMM       

  14 record(s) selected.

果真14条记录,和文件相比缺少4条记录

查看dump file

[db2inst2@xifenfei ~]$ more /tmp/xienfei.dmp.load.000 
30,,"DEFINE SPECS"
50,"SPECS ",

发现两条违背表定义记录,导入过程中,直接被拒绝的两条

查看异常表

[db2inst2@xifenfei ~]$ db2 "select * from xifenfei_exp"

ACTNO  ACTKWD ACTDESC              TS                         MSG  
------ ------ --------------------  
    60 STAFF  PERS AND STAFFING    2012-04-05-19.02.19.984440 00001I0000500001 
    80 DOC    DOCUMENT             2012-04-05-19.02.19.984440 00001I0000500001

发现两条违背唯一性约束记录,构建index的过程中删除

发表在 DB2 | 一条评论

DB2数据迁移之export/import

export导出数据

[db2inst1@xifenfei ~]$ db2 connect to sample

   Database Connection Information

 Database server        = DB2/LINUX 9.5.9
 SQL authorization ID   = DB2INST1
 Local database alias   = SAMPLE

[db2inst1@xifenfei ~]$ db2 "SELECT * FROM DB2INST1.ACT"

ACTNO  ACTKWD ACTDESC             
------ ------ --------------------
    10 MANAGE MANAGE/ADVISE       
    20 ECOST  ESTIMATE COST       
    30 DEFINE DEFINE SPECS        
    40 LEADPR LEAD PROGRAM/DESIGN 
    50 SPECS  WRITE SPECS         
    60 LOGIC  DESCRIBE LOGIC      
    70 CODE   CODE PROGRAMS       
    80 TEST   TEST PROGRAMS       
    90 ADMQS  ADM QUERY SYSTEM    
   100 TEACH  TEACH CLASSES       
   110 COURSE DEVELOP COURSES     
   120 STAFF  PERS AND STAFFING   
   130 OPERAT OPER COMPUTER SYS   
   140 MAINT  MAINT SOFTWARE SYS  
   150 ADMSYS ADM OPERATING SYS   
   160 ADMDB  ADM DATA BASES      
   170 ADMDC  ADM DATA COMM       
   180 DOC    DOCUMENT            

  18 record(s) selected.

[db2inst1@xifenfei ~]$ db2 "export to sample.act of del messages xifenfei.log 
select * from DB2INST1.ACT"

Number of rows exported: 18

[db2inst1@xifenfei ~]$ more sample.act 
10,"MANAGE","MANAGE/ADVISE"
20,"ECOST ","ESTIMATE COST"
30,"DEFINE","DEFINE SPECS"
40,"LEADPR","LEAD PROGRAM/DESIGN"
50,"SPECS ","WRITE SPECS"
60,"LOGIC ","DESCRIBE LOGIC"
70,"CODE  ","CODE PROGRAMS"
80,"TEST  ","TEST PROGRAMS"
90,"ADMQS ","ADM QUERY SYSTEM"
100,"TEACH ","TEACH CLASSES"
110,"COURSE","DEVELOP COURSES"
120,"STAFF ","PERS AND STAFFING"
130,"OPERAT","OPER COMPUTER SYS"
140,"MAINT ","MAINT SOFTWARE SYS"
150,"ADMSYS","ADM OPERATING SYS"
160,"ADMDB ","ADM DATA BASES"
170,"ADMDC ","ADM DATA COMM"
180,"DOC   ","DOCUMENT"

import导入数据

[db2inst2@xifenfei ~]$ more create.act 
CREATE TABLE ACT_COPY  (
ACTNO SMALLINT NOT NULL , 
ACTKWD CHAR(6) NOT NULL , 
ACTDESC VARCHAR(20) NOT NULL )   
IN USERSPACE1; 

[db2inst2@xifenfei ~]$ db2  -tvf create.act
CREATE TABLE ACT_COPY  ( ACTNO SMALLINT NOT NULL , ACTKWD CHAR(6) NOT NULL , ACTDESC VARCHAR(20) NOT NULL ) IN USERSPACE1
DB20000I  The SQL command completed successfully.

[db2inst2@xifenfei ~]$ db2 list tables

Table/View                      Schema          Type  Creation time             
------------------------------- --------------- ----- --------------------------
ACT_COPY                        DB2INST2        T     2012-04-05-16.40.25.103571

  1 record(s) selected.

[db2inst2@xifenfei ~]$ db2 "import from /home/db2inst1/sample.act of del 
messages xifenfei.log insert into act_copy"

Number of rows read         = 18
Number of rows skipped      = 0
Number of rows inserted     = 18
Number of rows updated      = 0
Number of rows rejected     = 0
Number of rows committed    = 18

[db2inst2@xifenfei ~]$ db2 "select * from act_copy"

ACTNO  ACTKWD ACTDESC             
------ ------ --------------------
    10 MANAGE MANAGE/ADVISE       
    20 ECOST  ESTIMATE COST       
    30 DEFINE DEFINE SPECS        
    40 LEADPR LEAD PROGRAM/DESIGN 
    50 SPECS  WRITE SPECS         
    60 LOGIC  DESCRIBE LOGIC      
    70 CODE   CODE PROGRAMS       
    80 TEST   TEST PROGRAMS       
    90 ADMQS  ADM QUERY SYSTEM    
   100 TEACH  TEACH CLASSES       
   110 COURSE DEVELOP COURSES     
   120 STAFF  PERS AND STAFFING   
   130 OPERAT OPER COMPUTER SYS   
   140 MAINT  MAINT SOFTWARE SYS  
   150 ADMSYS ADM OPERATING SYS   
   160 ADMDB  ADM DATA BASES      
   170 ADMDC  ADM DATA COMM       
   180 DOC    DOCUMENT            

  18 record(s) selected.

补充说明
1.chardel 指定字符串分隔符,默认是””
2.lobs to path 指定lob目录,modified by lobsinfile 指定保存一个文件;modified by lobsinsepfiles 指定每个值保存一个文件
3. into table_name指定表导入数据方式:inset(追加),insert_update(有主键,主键匹配更新,否则增加),replace(删除表数据,然后插入)
4.commitcount 和数据库提交相关,默认是automatic:db2内部自动计算什么时候提交
5.restartcount/skipcount N 表示跳过前N条记录,从N+1开始继续导入
6.rowcount N 表示插入条数

[db2inst2@xifenfei ~]$ db2 "import from /home/db2inst1/sample.act of del restartcount  10                               
rowcount 6  messages xifenfei.log  insert into act_copy"

Number of rows read         = 16
Number of rows skipped      = 10
Number of rows inserted     = 6
Number of rows updated      = 0
Number of rows rejected     = 0
Number of rows committed    = 16

7.插入指定列举例

[db2inst2@xifenfei ~]$ db2 "import from /home/db2inst1/sample.act of del method P(1,3) restartcount  10                               
rowcount 2  messages xifenfei.log  replace into act_copy(ACTNO,ACTDESC)"
SQL0668N  Operation not allowed for reason code "7" on table 
"DB2INST2.ACT_COPY".  SQLSTATE=57016
[db2inst2@xifenfei ~]$ db2 reorg table act_copy
DB20000I  The REORG command completed successfully.
[db2inst2@xifenfei ~]$ db2 "import from /home/db2inst1/sample.act of del method P(1,3) restartcount  10                               
rowcount 2  messages xifenfei.log  replace into act_copy(ACTNO,ACTDESC)"

Number of rows read         = 12
Number of rows skipped      = 10
Number of rows inserted     = 2
Number of rows updated      = 0
Number of rows rejected     = 0
Number of rows committed    = 12

[db2inst2@xifenfei ~]$ db2 "select * from act_copy"

ACTNO  ACTKWD ACTDESC             
------ ------ --------------------
   110 -      DEVELOP COURSES     
   120 -      PERS AND STAFFING   

  2 record(s) selected.
发表在 DB2 | 评论关闭

DB2 9.5.0.0升级至9.5.0.9(小版本升级)

0.升级前DB2版本

[db2inst1@xifenfei ~]$ db2level
DB21085I  Instance "db2inst1" uses "32" bits and DB2 code release "SQL09050" 
with level identifier "03010107".
Informational tokens are "DB2 v9.5.0.0", "s071001", "LINUXIA3295", and Fix Pack 
"0".
Product is installed at "/opt/db2/V9.5".

1.查看哪些实例

[root@xifenfei ~]# su - db2inst1
[db2inst1@xifenfei ~]$ db2ilist
db2inst1
db2inst2

2.关闭数据库

[db2inst1@xifenfei ~]$ db2 force applications all
SQL1032N  No start database manager command was issued.  SQLSTATE=57019
[db2inst1@xifenfei ~]$ db2 terminate
DB20000I  The TERMINATE command completed successfully.
[db2inst1@xifenfei ~]$ db2stop
04/05/2012 09:17:13     0   0   SQL1032N  No start database manager command was issued.
SQL1064N  DB2STOP processing was successful.
[db2inst1@xifenfei ~]$ su - db2inst2
Password: 
[db2inst2@xifenfei ~]$ db2 force applications all
DB20000I  The FORCE APPLICATION command completed successfully.
DB21024I  This command is asynchronous and may not be effective immediately.
[db2inst2@xifenfei ~]$ db2 terminate
DB20000I  The TERMINATE command completed successfully.
[db2inst2@xifenfei ~]$ db2stop
04/05/2012 09:20:00     0   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.

3.关闭管理服务器(DAS)

[root@xifenfei ~]# su - dasusr1
[dasusr1@xifenfei ~]$ db2admin stop
SQL4407W  The DB2 Administration Server was stopped successfully.

4.卸装未使用的共享库

[db2inst1@xifenfei ~]$  $HOME/sqllib/bin/ipclean
/home/db2inst1/sqllib/bin/ipclean: Removing DB2 engine and client's IPC resources for db2inst1.
[db2inst2@xifenfei ~]$  $HOME/sqllib/bin/ipclean
/home/db2inst2/sqllib/bin/ipclean: Removing DB2 engine and client's IPC resources for db2inst2.

5.升级数据库软件和组件

[root@xifenfei ~]# cd server/
[root@xifenfei server]# ./installFixPack -b /opt/db2/V9.5/
DBI1017I  installFixPack is updating the DB2 product(s) installed in
      location /opt/db2/V9.5/.


DB2 installation is being initialized.

 Total number of tasks to be performed: 36 
Total estimated time for all tasks to be performed: 1165 

Task #1 start
Description: Stopping DB2 Fault Monitor 
Estimated time 10 second(s) 
Task #1 end 

Task #2 start
Description: Preparing the system 
Estimated time 120 second(s) 
A major error occurred during the execution that caused this program to
terminate prematurely. If the problem persists, contact your technical service
representative.

For more information see the DB2 installation log at
"/tmp/installFixPack.log.9890".

--发生错误,通过日志文件寻找错误
[root@xifenfei server]# more /tmp/installFixPack.log.9890
Stopping DB2 Fault Monitor :.......Success 
ERROR: The installFixPack command detected some DB2 libraries are still loaded
in memory and some applications might still be running in the current
installation copy.  All applications must be stopped. See the fix pack readme
for pre-installation instructions, and re-run the installFixPack command.
Alternatively, to override automatic checking, you can re-issue the
installFixPack command with the '-f db2lib' parameter. Note: If you re-issue
the installFixPack command with the '-f db2lib' parameter, after the DB2
instances are updated, some applications might not work properly and might need
to be restarted to function properly against the updated DB2 instance.

Preparing the system :.......Failure 
--发现是some DB2 libraries are still loaded,导致升级不能进行

--使用-f db2lib参数
[root@xifenfei server]# ./installFixPack -b /opt/db2/V9.5/ -f db2lib
DBI1017I  installFixPack is updating the DB2 product(s) installed in
      location /opt/db2/V9.5/.


DB2 installation is being initialized.

 Total number of tasks to be performed: 36 
Total estimated time for all tasks to be performed: 1165 

Task #1 start
Description: Stopping DB2 Fault Monitor 
Estimated time 10 second(s) 
Task #1 end 

Task #2 start
Description: Preparing the system 
Estimated time 120 second(s) 
Task #2 end 

Task #3 start
Description: Base Client Support for installation with root privileges 
Estimated time 3 second(s) 
Task #3 end 

Task #4 start
Description: Product Messages - English 
Estimated time 11 second(s) 
Task #4 end 

Task #5 start
Description: Base client support 
Estimated time 86 second(s) 
Task #5 end 

Task #6 start
Description: The DB2 required component. 
Estimated time 78 second(s) 
Task #6 end 

Task #7 start
Description: Java Help (HTML) - English 
Estimated time 7 second(s) 
Task #7 end 

Task #8 start
Description: Base server support for installation with root privileges 
Estimated time 7 second(s) 
Task #8 end 

Task #9 start
Description: Global Secure ToolKit 
Estimated time 14 second(s) 
Task #9 end 

Task #10 start
Description: Java support 
Estimated time 11 second(s) 
Task #10 end 

Task #11 start
Description: SQL procedures 
Estimated time 3 second(s) 
Task #11 end 

Task #12 start
Description: ICU Utilities 
Estimated time 54 second(s) 
Task #12 end 

Task #13 start
Description: Java Common files 
Estimated time 20 second(s) 
Task #13 end 

Task #14 start
Description: Base server support 
Estimated time 197 second(s) 
Task #14 end 

Task #15 start
Description: IBM Software Development Kit (SDK) for Java(TM) 
Estimated time 32 second(s) 
Task #15 end 

Task #16 start
Description: Control Center Help (HTML) - English 
Estimated time 13 second(s) 
Task #16 end 

Task #17 start
Description: Connect support 
Estimated time 3 second(s) 
Task #17 end 

Task #18 start
Description: Communication support - TCP/IP 
Estimated time 3 second(s) 
Task #18 end 

Task #19 start
Description: Parallel Extension 
Estimated time 3 second(s) 
Task #19 end 

Task #20 start
Description: Replication tools 
Estimated time 16 second(s) 
Task #20 end 

Task #21 start
Description: Control Center 
Estimated time 40 second(s) 
Task #21 end 

Task #22 start
Description: DB2 data source support 
Estimated time 4 second(s) 
Task #22 end 

Task #23 start
Description: DB2 LDAP support 
Estimated time 3 second(s) 
Task #23 end 

Task #24 start
Description: DB2 Instance Setup wizard 
Estimated time 4 second(s) 
Task #24 end 

Task #25 start
Description: First Steps 
Estimated time 3 second(s) 
Task #25 end 

Task #26 start
Description: Product Signature for DB2 Enterprise Server Edition 
Estimated time 5 second(s) 
Task #26 end 

Task #27 start
Description: Sample database source 
Estimated time 4 second(s) 
Task #27 end 

Task #28 start
Description: Installing or updating SA MP Base Component 
Estimated time 40 second(s) 
Task #28 end 

Task #29 start
Description: Installing or updating DB2 HA scripts for SA MP Base Component 
Estimated time 40 second(s) 
Task #29 end 

Task #30 start
Description: Setting DB2 library path 
Estimated time 180 second(s) 
Task #30 end 

Task #31 start
Description: Executing control tasks 
Estimated time 20 second(s) 
Task #31 end 

Task #32 start
Description: Updating global registry 
Estimated time 20 second(s) 
Task #32 end 

Task #33 start
Description: Starting DB2 Fault Monitor 
Estimated time 10 second(s) 
Task #33 end 

Task #34 start
Description: Updating the db2ls link 
Estimated time 1 second(s) 
Task #34 end 

Task #35 start
Description: Updating the DB2 Administration Server 
Estimated time 40 second(s) 
Task #35 end 

Task #36 start
Description: Updating existing DB2 instances 
Estimated time 60 second(s) 
Task #36 end 

A minor error occurred during the execution.

For more information see the DB2 installation log at
"/tmp/installFixPack.log.15581".
--提示升级有错误发生

--检查日志文件
[root@xifenfei server]# more /tmp/installFixPack.log.15581
TSAMP_VERSION=3.2.1.2
 DBI1130E  The SA MP Base Component could not be installed or updated
      because system prerequisites were not met. See the log file
      /tmp/prereqSAM.log.17293 for details.
--发现是samp组件没有安装导致该错误,忽略

6.升级数据库

[root@xifenfei server]# su - db2inst1
[db2inst1@xifenfei ~]$ db2level  -a
DB21085I  Instance "db2inst1" uses "32" bits and DB2 code release "SQL09059" 
with level identifier "060A0107".
Informational tokens are "DB2 v9.5.0.9", "s120228", "IP23310", and Fix Pack 
"9".
Product is installed at "/opt/db2/V9.5".
[db2inst1@xifenfei ~]$ db2ilist 
db2inst1
db2inst2
[db2inst1@xifenfei ~]$ db2start
04/05/2012 09:39:45     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.
[db2inst1@xifenfei ~]$ db2 list database DIRECTORY

 System Database Directory

 Number of entries in the directory = 3

Database 1 entry:

 Database alias                       = XFF
 Database name                        = XIFENFEI
 Local database directory             = /home/db2inst1
 Database release level               = c.00
 Comment                              = XIFENFEI TEST DATABASE
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

Database 2 entry:

 Database alias                       = TOOLSDB
 Database name                        = TOOLSDB
 Local database directory             = /home/db2inst1
 Database release level               = c.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

Database 3 entry:

 Database alias                       = SAMPLE
 Database name                        = SAMPLE
 Local database directory             = /home/db2inst1
 Database release level               = c.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

[db2inst1@xifenfei ~]$ db2updv95 -d toolsdb


_________________________________________________________________________     
                                                                              
                    _____   DB2 Service Tools   _____                         
                                                                              
                            I      B      M                                   
                                                                              
                               db2updv95                                      
                                                                              
   This tool is a service utility designed to update a DB2 Version 9.5        
   database to the current fixpak level.                                      
                                                                              
_________________________________________________________________________     


DB2 Universal Database Version 9.5, 5622-044 (c) Copyright IBM Corp. 2007
Licensed Material - Program Property of IBM
IBM DATABASE 2 Database update to current fix pack tool

db2updv95 completed successfully for database 'toolsdb'. 
[db2inst1@xifenfei ~]$ db2updv95 -d SAMPLE


_________________________________________________________________________     
                                                                              
                    _____   DB2 Service Tools   _____                         
                                                                              
                            I      B      M                                   
                                                                              
                               db2updv95                                      
                                                                              
   This tool is a service utility designed to update a DB2 Version 9.5        
   database to the current fixpak level.                                      
                                                                              
_________________________________________________________________________     


DB2 Universal Database Version 9.5, 5622-044 (c) Copyright IBM Corp. 2007
Licensed Material - Program Property of IBM
IBM DATABASE 2 Database update to current fix pack tool

db2updv95 completed successfully for database 'SAMPLE'.

--指定数据库别名 
[db2inst1@xifenfei ~]$ db2updv95 -d Xff


_________________________________________________________________________     
                                                                              
                    _____   DB2 Service Tools   _____                         
                                                                              
                            I      B      M                                   
                                                                              
                               db2updv95                                      
                                                                              
   This tool is a service utility designed to update a DB2 Version 9.5        
   database to the current fixpak level.                                      
                                                                              
_________________________________________________________________________     


DB2 Universal Database Version 9.5, 5622-044 (c) Copyright IBM Corp. 2007
Licensed Material - Program Property of IBM
IBM DATABASE 2 Database update to current fix pack tool

db2updv95 completed successfully for database 'Xff'. 

[db2inst1@xifenfei ~]$ su - db2inst2
Password: 
[db2inst2@xifenfei ~]$ db2 list database DIRECTORY

 System Database Directory

 Number of entries in the directory = 1

Database 1 entry:

 Database alias                       = XIFENFEI
 Database name                        = XIFENFEI
 Local database directory             = /home/db2inst2/xifenfei
 Database release level               = c.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

[db2inst2@xifenfei ~]$ db2start
04/05/2012 09:46:47     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.
[db2inst2@xifenfei ~]$ db2updv95 -d  xifenfei


_________________________________________________________________________     
                                                                              
                    _____   DB2 Service Tools   _____                         
                                                                              
                            I      B      M                                   
                                                                              
                               db2updv95                                      
                                                                              
   This tool is a service utility designed to update a DB2 Version 9.5        
   database to the current fixpak level.                                      
                                                                              
_________________________________________________________________________     


DB2 Universal Database Version 9.5, 5622-044 (c) Copyright IBM Corp. 2007
Licensed Material - Program Property of IBM
IBM DATABASE 2 Database update to current fix pack tool

db2updv95 completed successfully for database 'xifenfei'. 

7.补充说明
1)在升级数据库前需要做好数据库和软件备份
2)升级过程时先关闭所有db2相关进程,如果不能正常关闭(非本文上面列举操作相关进程),直接kill
3)升级过程中,如果实例,DAS等升级失败,需要后续手工升级
4)检查相关进程,如果没有正常启动,需要手工给予启动
5)一些工具进行绑定和重新绑定packages

db2 terminate
db2 connect to dbname
db2 BIND /home/db2inst2/sqllib/bnd/db2schema.bnd BLOCKING ALL GRANT PUBLIC SQLERROR CONTINUE
db2 BIND /home/db2inst2/sqllib/bnd/@db2ubind.lst BLOCKING ALL GRANT PUBLIC ACTION ADD
db2 BIND /home/db2inst2/sqllib/bnd/@db2cli.lst BLOCKING ALL GRANT PUBLIC ACTION ADD
db2 terminate
db2rbind xifenfei -l logfile all
发表在 DB2 | 一条评论