DB2版本升級(V9.7升級到V11.1)


1.V11.1版本升級路線

DB2 11.1

可以將現有的 Db2 V9.7、Db2 V10.1 或 Db2 V10.5 實例和數據庫直接升級到 Db2 V11.1。
如果 Db2 服務器正在 Db2 V9.7 之前的發行版上運行,請先將它們升級到 Db2 V9.7、Db2 V10.1 或 Db2 V10.5,然后升級到 Db2 V11.1。建議升級到 Db2 V9.7 的最新修訂包。

 

2.升級前准備

 2.1檢查當前主機的文件系統

檢查/opt與/home/以及/db2data是否充足
/opt是DB2實例軟件默認安裝路徑(可更改)
/home/db2inst1 是實例目錄(可更改)
/db2data 是用於數據庫安裝路徑
如果空間足夠,建議歸檔日志,備份目錄單獨划分。

[root@ecdb2 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_ecdb2-LogVol02
                       31G  9.5G   20G  33% /
tmpfs                 1.9G   76K  1.9G   1% /dev/shm
/dev/sda1             190M   40M  141M  22% /boot
/dev/mapper/vg_ecdb2-LogVol00
                       15G  1.1G   13G   8% /home
/dev/mapper/vg_data-lv_data
                      9.5G  431M  8.6G   5% /db2data

 2.2備份當前實例下的數據庫

在升級之前必須備份數據庫,避免版本升級失敗導致數據庫無法使用的問題,建議做離線全備。

[db2inst1@ecdb2 ~]$ db2 list db directory

 System Database Directory

 Number of entries in the directory = 1

Database 1 entry:

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

[db2inst1@ecdb2 ~]$ ^C
[db2inst1@ecdb2 ~]$ db2 backup db sample to /db2data

Backup successful. The timestamp for this backup image is : 20190422184606

[db2inst1@ecdb2 ~]$ cd /db2data
[db2inst1@ecdb2 db2data]$ ls -lrt
total 446004
drwx------ 2 db2inst1 db2iadm     16384 Mar 27 21:34 lost+found
-rwxrwxr-x 1 db2inst1 db2iadm 200781824 Mar 27 21:59 SAMPLE.0.db2inst2.DBPART000.20190327215905.001
-rw-r--r-- 1 db2inst1 db2iadm      8083 Mar 27 23:22 redirect_sample.sql
-rw-r--r-- 1 db2inst1 db2iadm      1875 Mar 27 23:23 SAMPLE_NODE0000.out
drwxrwxr-x 2 db2inst1 db2iadm      4096 Mar 28 10:28 db2inst2
drwxrwxr-x 3 db2inst1 db2iadm      4096 Apr 18 11:52 db2inst1
-rw------- 1 db2inst1 db2iadm 255889408 Apr 22 18:46 SAMPLE.0.db2inst1.DBPART000.20190422184606.001
[db2inst1@ecdb2 db2data]$ 

 

2.3檢查當前的實例版本

檢查現有實例版本,首先是根據升級路線看是否能夠升級

[db2inst1@ecdb2 ~]$ 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".

當前實例版本為9.7,根據升級路線,是可以進行升級的

 

2.4上傳壓縮包解壓

[root@ecdb2 ~]# ls -lrt
total 3459620
drwxr-xr-x  4 root root       4096 Sep 25  2015 server
-rw-r--r--. 1 root root 1913293693 Jan  6 16:43 v10.5fp10_linuxx64_server_t.tar.gz
-rw-r--r--  1 root root  799372868 Mar 16 19:14 v9.7fp11_linuxx64_server.tar.gz
-rw-r--r--. 1 root root      10259 Mar 27 10:08 install.log.syslog
-rw-r--r--. 1 root root      52264 Mar 27 10:10 install.log
-rw-------. 1 root root       1552 Mar 27 10:10 anaconda-ks.cfg
drwxr-xr-x. 2 root root       4096 Mar 27 10:13 Videos
drwxr-xr-x. 2 root root       4096 Mar 27 10:13 Templates
drwxr-xr-x. 2 root root       4096 Mar 27 10:13 Public
drwxr-xr-x. 2 root root       4096 Mar 27 10:13 Pictures
drwxr-xr-x. 2 root root       4096 Mar 27 10:13 Music
drwxr-xr-x. 2 root root       4096 Mar 27 10:13 Downloads
drwxr-xr-x. 2 root root       4096 Mar 27 10:13 Documents
drwxr-xr-x. 2 root root       4096 Mar 27 10:13 Desktop
drwxr-xr-x  2 root root       4096 Mar 27 19:26 isus
-rw-r--r--  1 root root  829849600 Apr 15 19:58 v9.5fp5_linuxx64_server.tar
drwxr-xr-x  2 root root       4096 Apr 22 16:53 V11
[root@ecdb2 ~]# cd V11
[root@ecdb2 V11]# pwd
/root/V11
[root@ecdb2 V11]# ls -lrt
total 1935492
-rw-r--r-- 1 root root 1981938797 Apr 16 12:03 v11.1.4fp4a_linuxx64_server_t.tar.gz
解壓使用tar -zxvf v11.1.4fp4a_linuxx64_server_t.tar.gz
如果是aix的,需要gzip -d v11.1.4fp4a_linuxx64_server_t.tar.gz變成tar包
tar -xvf v11.1.4fp4a_linuxx64_server_t.tar

 

3.實例軟件安裝

 3.1預安裝檢查

[root@ecdb2 server_t]# ./db2prereqcheck
Validating "/lib/libpam.so*" ... 
   Requirement matched. 
Requirement not matched for DB2 database "Server" with pureScale feature . Version: "9.8.0.2". 
Summary of prerequisites that are not met on the current system: 
DBT3514W  The db2prereqcheck utility failed to find the following 32-bit library file: "libstdc++.so.5". 
DBT3613E  The db2prereqcheck utility failed to verify the prerequisites for TSA. Ensure your machine meets all the TSA installation prerequisites.

可以看到,預安裝檢查是有報錯的,這個報錯官方是說明的。這個是因為32位libstdc++沒有裝

官方的回應如下:

DBT3514W db2prereqcheck 實用程序找不到以下 32 位庫文件:庫文件名。
說明
您可以使用 db2prereqcheck 實用程序來驗證安裝先決條件。

當 db2prereqcheck 實用程序找不到 32 位版本的必需庫文件時,將返回此消息。如果缺少指定的文件,那么 32 位數據庫應用程序可能無法正常運行。

用戶響應
請以下列其中一種方式響應此消息:

如果您不打算將 32 位應用程序與 DB2 數據庫配合使用,那么無需進行響應。
如果您打算將 32 位應用程序與 DB2 數據庫配合使用,請先確保指定的 32 位庫文件存在於系統上,然后再安裝 DB2 數據庫。

如果需要安裝32位的應用程序,下面這個是解決方案:

    1.DBT3514W The db2prereqcheck utility failed to find the following 32-bit library file: "libstdc++.so.5". 
    解決方案:yum -y install libstdc++.so.6
    
    2.DBT3514W  The db2prereqcheck utility failed to find the following 32-bit library file: "/lib/libpam.so*"
    解決方案:yum -y install pam-devel.i686 pam.i686
    
    3.DBT3507E  The db2prereqcheck utility failed to find the following package or file: "sg3_utils". 
    解決方案:yum -y install sg3_utils-*
    
    4. Required minimum version for "ksh": "20100621" 
    解決方案:yum -y install ksh*

安裝完成后重新檢查

[root@ecdb2 server_t]# ./db2prereqcheck

Validating "32 bit version of "libstdc++.so.5" " ... 
   Found the 32 bit "/usr/lib/libstdc++.so.6" in the following directory "/usr/lib". 
   Requirement matched. 
   
Validating "libaio.so version " ... 
DBT3553I  The db2prereqcheck utility successfully loaded the libaio.so.1 file. 
   Requirement matched. 
   
Validating "libnuma.so version " ... 
DBT3610I  The db2prereqcheck utility successfully loaded the libnuma.so.1 file. 
   Requirement matched. 
   
Validating "/lib/libpam.so*" ... 
   Requirement matched. 
DBT3533I  The db2prereqcheck utility has confirmed that all installation prerequisites were met.

這個表示預安裝檢查通過了。

 3.2實例軟件安裝

[root@ecdb2 server_t]# ls -lrt
total 120
-r-xr-xr-x  1 bin bin  5111 Feb 27 17:31 db2prereqcheck
-r-xr-xr-x  1 bin bin  5259 Feb 27 17:31 db2_deinstall
-r-xr-xr-x  1 bin bin  5111 Feb 27 17:32 db2setup
-r-xr-xr-x  1 bin bin  5093 Feb 27 17:32 db2ls
-r--r--r--  1 bin bin 47346 Feb 27 17:32 db2checkCOL.tar.gz
-r--r--r--  1 bin bin  4987 Feb 27 17:32 db2checkCOL_readme.txt
-r-xr-xr-x  1 bin bin  5306 Feb 27 17:32 db2ckupgrade
-r-xr-xr-x  1 bin bin  5129 Feb 27 17:32 db2_install
drwxr-xr-x 10 bin bin  4096 Feb 27 17:32 ibm_im
-r-xr-xr-x  1 bin bin  5147 Feb 27 17:32 installFixPack
drwxr-xr-x  6 bin bin  4096 Feb 27 17:32 db2
[root@ecdb2 server_t]# ./db2_install 
Read the license agreement file in the db2/license directory.

***********************************************************
To accept those terms, enter "yes". Otherwise, enter "no" to cancel the install process. [yes/no]
yes


Default directory for installation of products - /opt/ibm/db2/V11.1

***********************************************************
Install into default directory (/opt/ibm/db2/V11.1) ? [yes/no] 
yes


Specify one of the following keywords to install DB2 products.

  SERVER 
  CONSV 
  CLIENT 
  RTCL 

Enter "help" to redisplay product names.

Enter "quit" to exit.

***********************************************************
SERVER
***********************************************************
Do you want to install the DB2 pureScale Feature? [yes/no] 
no
DB2 installation is being initialized.

Total number of tasks to be performed: 58 
Total estimated time for all tasks to be performed: 2613 second(s) 
中間安裝步驟就省略了
Task #59 start
Description: Updating global profile registry 
Estimated time 3 second(s) 
Task #59 end 

The execution completed successfully.

For more information see the DB2 installation log at
"/tmp/db2_install.log.55688".

 在最后會產生一個The execution completed successfully.如果失敗會有報錯。

3.3檢查實例軟件安裝日志

在安裝實例軟件后會在/tmp下面有生成相關的日志,比如:/tmp/db2_install.log.55688
這里面記錄了安裝的版本,安裝的步驟,安裝了哪些東西。

Installing or updating DB2 HA scripts for IBM Tivoli System Automation for Multiplatforms (Tivoli SA MP) :..
.....Success 
Executing control tasks :.......Success 
Updating global registry :.......Success 
Starting DB2 Fault Monitor :.......Success 
Updating the db2ls and db2greg link :.......Success 
Registering DB2 licenses :.......Success 
Setting default global profile registry variables :.......Success 
Initializing instance list :.......Success 
Registering DB2 Update Service :.......Success 
Updating global profile registry :.......Success

如果這些都是Success ,表示實例軟件安裝成功。

 

4.升級實例

升級之前,必須停止現有實例,否則升級的時候會出現報錯

[root@ecdb2 instance]# pwd
/opt/ibm/db2/V11.1/instance
[root@ecdb2 instance]# ./db2iupgrade -u db2fenc1 db2inst1
DBI1446I  The db2iupgrade command is running.


DB2 installation is being initialized.

The DB2 installer detects that one or more DB2 instances "db2inst1" are still
active. Stop the active instances and rerun the command again.

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/db2iupgrade.log.99362".
DBI1264E  This program failed. Errors encountered during execution were
      written to the installation log file. Program name:
      db2iupgrade. Log file name: /tmp/db2iupgrade.log.99362.

Explanation: 

This message is returned when some processes and operations have failed.
Detailed information about the error was written to the log file.

User response: 

Contact IBM support to get assistance in resolving this issue. Keep the
log file intact as this file is an important reference for IBM support.


   Related information:
   Contacting IBM Software Support

檢查相關的日志

[root@ecdb2 instance]# more /tmp/db2iupgrade.log.99362

DB2 Setup log file started at:  Mon Apr 22 06:03:56 PM 2019 CST
============================================================

Operating system information: Linux 2.6.32-642.el6.x86_64.#1 SMP Wed Apr 13 00:51:26 EDT 2016 x86_64 
ERROR: The DB2 installer detects that one or more DB2 instances "db2inst1" are still
active. Stop the active instances and rerun the command again.

ERROR: The "db2iupgrade" command failed. Ensure that errors reported in the log
file are fixed, then rerun the command.


Post-installation instructions 
-------------------------------
Required steps: 
There were some errors detected during DB2 installation. To collect the information files from the system, run the "db2support -install" command with the proper options before reporting the problem to IBM service. For information re
garding the usage of the db2support tool, check the DB2 Information Center. 


DB2 Setup log file finished at:  Mon Apr 22 06:03:58 PM 2019 CST
============================================================

 4.1升級預檢查

升級預檢查可以使用db2ckupgrade去進行檢查

[db2inst1@ecdb2 instance]$ ./db2ckupgrade sample -l /home/db2inst1/db2ckupgrade.log -u db2inst1 -p enmodb2
db2upgrade was successful. Database(s) can be upgraded  

 4.2停止現有實例

[root@ecdb2 instance]# su - db2inst1
[db2inst1@ecdb2 ~]$ db2stop force
04/22/2019 18:11:22     0   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.
[db2inst1@ecdb2 ~]$ exit

這一步必須在應用或者甲方同意的情況下進行,如果存在應用,應用同意可以殺可以使用以下命令:

db2 force applications all
db2 terminate

執行完成之后去停止實例,如果停止不了,需要應用人員停止相關的應用。

  4.3升級實例

[root@ecdb2 instance]# ls -lrt |grep db2iupgrade
-r-xr--r-- 1 root root  94819 Feb 27 16:50 db2iupgrade_local
-r-xr--r-- 1 root root  76962 Apr 22 17:41 db2iupgrade
[root@ecdb2 instance]# ./db2iupgrade -u db2fenc1 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.100946".
DBI1070I  Program db2iupgrade completed successfully.

升級后會顯示升級完成,並且會在/tmp下面生成一個upgrade的日志

檢查相關的升級日志,看升級日志中是否存在報錯(/tmp/db2iupgrade.log.100946

Existing instances to configure:        
    Instance name:                              db2inst1
        Instance user information:      
            User name:                          db2inst1
        Fenced user information:        
            User name:                          db2fenc1
                                        
                                        
                                        
                                        

Setting default global profile registry variables :.......Success 
Initializing instance list :.......Success 
The instance "db2inst1" has been upgraded successfully.

Configuring DB2 instances :.......Success 
Updating global profile registry :.......Success

 4.4檢查升級后實例版本

[root@ecdb2 instance]# su - db2inst1
[db2inst1@ecdb2 ~]$ db2level
DB21085I  This instance or install (instance name, where applicable: 
"db2inst1") uses "64" bits and DB2 code release "SQL11014" with level 
identifier "0205010F".
Informational tokens are "DB2 v11.1.4.4", "s1902261400", "DYN1902261400AMD64", 
and Fix Pack "4a".
Product is installed at "/opt/ibm/db2/V11.1".

可以看到實例已經升級到11.1.0.4了。

5.升級數據庫

 5.1啟動實例連接數據庫

[db2inst1@ecdb2 ~]$ db2start
SQL8007W  There are "90" 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.
04/22/2019 18:20:37     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.
[db2inst1@ecdb2 ~]$ db2 connect to sample
SQL5035N  The connection failed because the database product has been updated 
and the database needs to be upgraded  SQLSTATE=55001

這里因為我沒有許可證,試用天數為90天,如果是生產數據庫,建議把lisence也打上。

[db2inst1@ecdb2 ~]$ db2licm -l
Product name:                     "DB2 Advanced Enterprise Server Edition"
License type:                     "Trial"
Expiry date:                      "07/20/2019"
Product identifier:               "db2aese"
Version information:              "11.1"

可以看到,到了V11,默認安裝都是AESE(高級企業版)了。

從剛剛的連接數據庫來看,存在報錯

SQL5035N The connection failed because the database product has been updated 
and the database needs to be upgraded??SQLSTATE=55001

這個報錯是因為我們暫時只是升級了實例,但是數據庫還沒有進行版本升級。

 5.2 數據庫升級

[db2inst1@ecdb2 ~]$ db2 upgrade db sample
DB20000I  The UPGRADE DATABASE command completed successfully.
[db2inst1@ecdb2 ~]$ db2 connect to sample

   Database Connection Information

Database server        = DB2/LINUXX8664 11.1.4.4
SQL authorization ID   = DB2INST1
Local database alias   = SAMPLE

 

注意事項:

1.升級前必須將數據庫做離線全備。
2.升級過程中不能中斷,否則只有重裝。
3.版本升級從數據庫命令層面沒有回退方案,只能通過備份恢復,如果升級出現問題,可以刪掉實例,重建實例,恢復數據庫。

4.升級完成之后需要綁定相關的package

5.升級完成后如果事件監視器,需要刪除后重建

 

注意事項中第三條,也是為什么在准備過程中就需要對數據庫進行全備的,如果是生產還需要考慮,應用停機等。DB2 的版本升級分享到此結束,祝好運。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM