我是靠谱客的博主 震动康乃馨,最近开发中收集的这篇文章主要介绍DB2从9.7到10.5升级,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

测试:把9.7.0.2的db2实例数据库升级到新版本10.5.0.0
参考升级步骤,官方文档:
https://www.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.qb.upgrade.doc/doc/t0007200.html

升级之前要做好检查,看是否满足升级的要求(重点关注表空间等):

https://www.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.qb.upgrade.doc/doc/t0007187.html

升级前要做好各种备份: db backup/db cfg/dbm cfg/db2support/db2look等,以便在升级失败的情况下能快速恢复db进行回退。

 

Db29.7-10.5升级大致步骤:

1. 升级之前要做好检查,看是否满足升级的要求(重点关注表空间等)
2. 做好备份(db backup/db cfg/dbm cfg/db2support/db2look等)
3. 安装新版本10.5.0.0检查安装先决条件是否符合(db2prereqcheck )
4. 安装高版本DB2软件(10.5)
5. 升级实例
6. 升级数据库
7. 重新rebind package

详细步骤:

1.查看当前系统安装的所有db2版本

[root@test instance]# db2ls

Install Path                       Level   Fix Pack   Special Install Number   Install Date                  Installer UID 
---------------------------------------------------------------------------------------------------------------------
/opt/ibm/db2/V9.7                9.7.0.11       11                            Wed May  8 00:17:22 2019 CST             0 

2.安装新版本10.5.0.0检查安装先决条件是否符合

[root@test universal]# pwd
/my_DB2_10.5/universal                                                  #该路径为我放上去解压的DB2 10.5的软件存放的路径
./db2prereqcheck -v 10.5.0.0

3.安装10.5.0.0到新的路径,且成功
[root@localhost ese]# ./db2_install -b /opt/ibm/db2/V10.5

[root@test universal]# db2ls

Install Path                       Level   Fix Pack   Special Install Number   Install Date                  Installer UID 
---------------------------------------------------------------------------------------------------------------------
/opt/ibm/db2/V9.7                9.7.0.11       11                            Wed May  8 00:17:22 2019 CST             0 
/opt/ibm/db2/V10.5              10.5.0.10       10                            Sun Jan 12 14:11:15 2020 CST             0 

4.su - db2inst1到实例下,检查实例数据库是否可以升级

[db2inst1@test universal]$ ./db2ckupgrade testdb -l /tmp/db2ckupgrade.log                       # [-u db2inst1 -p mypass]
DBT5508I  The db2ckupgrade utility completed successfully. The database or databases can be upgraded.

如果检查失败报“ the database is in an inconsistent state”错误,可以db2 force applications all  / db2 termiante然后再试

5.升级之前务必做好数据库备份
db2 backup db testdb 

6.升级实例:


1>升级之前查看实例版本信息:
[db2inst1@test ~]$ db2level
DB21085I  This instance or install (instance name, where applicable: 
"db2inst1") uses "64" bits and DB2 code release "SQL0907B" with level 
identifier "080C0107".
Informational tokens are "DB2 v9.7.0.11", "s150922", "IP23944", and Fix Pack 
"11".
Product is installed at "/opt/ibm/db2/V9.7".


2>先停止实例db2stop force


3>再用root用户,cd到10.5.0.0的安装目录下执行升级实例:
[root@test instance]# pwd
/opt/ibm/db2/V10.5/instance

然后执行升级实例命令:

./db2iupgrade  db2inst1

或:

./db2iupgrade  -u db2fenc1 db2inst1 

db2fenc1 为fence用户,db2pd -fmp|grep fenc或 grep fenc /etc/passwd可以找到。

[root@test instance]# ./db2iupgrade  db2inst1 
DBI1446I  The db2iupgrade command is running.


DB2 installation is being initialized.

 Total number of tasks to be performed: 4 
Total estimated time for all tasks to be performed: 309 second(s) 

Task #1 start
Description: Setting default global profile registry variables 
Estimated time 1 second(s) 
Task #1 end 

Task #2 start
Description: Initializing instance list 
Estimated time 5 second(s) 
Task #2 end 

Task #3 start
Description: Configuring DB2 instances 
Estimated time 300 second(s) 
Task #3 end 

Task #4 start
Description: Updating global profile registry 
Estimated time 3 second(s) 
Task #4 end 

The execution completed successfully.

For more information see the DB2 installation log at
"/tmp/db2iupgrade.log.57960".
DBI1070I  Program db2iupgrade completed successfully.


4>实例升级成功:[db2inst1@test ~]$ db2level
DB21085I  This instance or install (instance name, where applicable: 
"db2inst1") uses "64" bits and DB2 code release "SQL1005A" with level 
identifier "060B010E".
Informational tokens are "DB2 v10.5.0.10", "s180615", "IP24053", and Fix Pack 
"10".
Product is installed at "/opt/ibm/db2/V10.5".

 

5>su - db2inst1,重启实例db2start   , 启动失败。

[root@test instance]# su - db2inst1
Last login: Sun Jan 12 14:58:46 CST 2020 on pts/0
[db2inst1@test ~]$ db2start
01/12/2020 14:59:51     0   0   SQL6048N  A communication error occurred during START or STOP DATABASE MANAGER processing.
SQL1032N  No start database manager command was issued.  SQLSTATE=57019

启动实例失败。经检查发现/etc/hosts里的IP配置错了,做了修改,然后重启成功。

[db2inst1@test ~]$ db2start
SQL8007W  There are "89" day(s) left in the evaluation period for the product 
"DB2 Advanced Enterprise Server Edition". For evaluation license terms and 
conditions, refer to the License Agreement document located in the license 
directory in the installation path of this product. If you have licensed this 
product, ensure the license key is properly registered. You can register the 
license by using the db2licm command line utility. The license key can be 
obtained from your licensed product CD.
01/12/2020 22:25:39     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

 

 

7.升级数据库
1>升级实例后尝试连接库失败:
[db2inst1@test ~]$ db2 connect to testdb
SQL5035N  The database must be upgraded to the current release.  
SQLSTATE=55001
2>升级数据库
db2 UPGRADE DATABASE <dbname> USER <user> USING <password>
[db2inst1@test ~]$ db2 UPGRADE DATABASE testdb                           # [ USER db2inst1 USING passd ]
DB20000I  The UPGRADE DATABASE command completed successfully.
3>升级后重建连接数据库,显示新版本,至此升级成功

[db2inst1@test ~]$ db2 connect to testdb

   Database Connection Information

 Database server        = DB2/LINUXX8664 10.5.10
 SQL authorization ID   = DB2INST1
 Local database alias   = TESTDB

[db2inst1@test ~]$ db2ls

Install Path                       Level   Fix Pack   Special Install Number   Install Date                  Installer UID 
---------------------------------------------------------------------------------------------------------------------
/opt/ibm/db2/V9.7                9.7.0.11       11                            Wed May  8 00:17:22 2019 CST             0 
/opt/ibm/db2/V10.5              10.5.0.10       10                            Sun Jan 12 14:11:15 2020 CST             0 
[db2inst1@test ~]$ db2level
DB21085I  This instance or install (instance name, where applicable: 
"db2inst1") uses "64" bits and DB2 code release "SQL1005A" with level 
identifier "060B010E".
Informational tokens are "DB2 v10.5.0.10", "s180615", "IP24053", and Fix Pack 
"10".
Product is installed at "/opt/ibm/db2/V10.5".

[db2inst1@test ~]$ db2 "select count(*) from syscat.tables"

1          
-----------
        428

  1 record(s) selected.

 

8.升级之后任务,重新rebind package等:

1>找出需要rebind的package:

db2 "select count(*) from syscat.packages where valid <>'Y'"

2>rebind这些package:select 'db2 rebind package '||trim(PKGSCHEMA)||'.'||trim(PKGNAME) from syscat.packages where valid <>'Y'  with ur; 

或者全部rebind:

db2rbind testdb -l testdb.log all


https://www.ibm.com/support/knowledgecenter/zh/SSEPGG_10.5.0/com.ibm.db2.luw.qb.upgrade.doc/doc/t0050543.html

 

注意事项:

1.升级前必须将数据库做离线全备。
2.升级过程中不能中断,否则只有重装。
3.版本升级从数据库命令层面没有回退方案,只能通过备份恢复,如果升级出现问题,可以删掉实例,重建实例,恢复数据库。4.升级完成之后需要绑定相关的package

5.升级完成后如果事件监视器,需要删除后重建


 

最后

以上就是震动康乃馨为你收集整理的DB2从9.7到10.5升级的全部内容,希望文章能够帮你解决DB2从9.7到10.5升级所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部