Friday, January 8, 2010

Migrate_V7(32)_to_V8(64).doc

Migrate DB2 UDB from V7 to V8 64 bits

 

 

 

 

INDEX

 

  • Purpose
  • Scope
  • Process
  • DB2 V8 32 bit instance creation
  • Offline back of V7 and use of DB2CKBKP utility
  • Preparation of ‘set tablespace container’ script
  • Re-direct restore of V7 database backup into DB2 V8 32 bit instance
  • Verification of restore re-direct
  • Migrate instance from V8 32 bits to V8 64 bits (db2iupdb)
  • Post migration activities
  • Rebinding DB2 Packages
  • Verify packages are migrated into V8 sqllib directory
  • Updating your System Catalog Statistics
  • Converting all Indexes from TYPE-1 to TYPE-2
  • Perform offline backup of database (V8 64 bit)

 

 

 

 

 

 

 

 

 

 

 

 

 

Purpose: This document provides standard way of migrating database DB2 UDB from V7 to V8 64 bits.

 

Scope: DBA and System admin

 

              It is not possible to restore database backup image from V7 32 bit to V8 64 Bit directly, but it is possible to migrate by restoring a V7 32-bit backup, restore it to v8 32-bit before updating the instance to 64-bit.

 

 

 

 

 

 

 

 

 

 

 

 

Process:

 

  • DB2 V8 32 bit instance creation:

 

Create db2 32 bits instance sandbox (test server).

 

Below document describe brief way to create V8 32 bit instance.

 

 

  • Offline back of V7 and use of DB2CKBKP utility:

 

Take full offline back up of DB2 V7

 

Check whether backup is restorable or not and also extract tablespace information and other object information from backup image.

 

FTP backup image to the sandbox (test server where you have created 32 bit instance)

 

Below document provides way to perform the same task.

 

  • Preparation of set tablespace container script:

 

Base on tablespace information extracted from db2ckbkp command; prepare script to set tablespace containers which will be use in redirect restore process.

 

Below document has set tablespace container script

 

 

Don’t execute the script

 

  • Re-direct restore of V7 database backup into DB2 V8 32 bit instance:

 

Now be ready for redirect restore.

 

Find out the file system where you can have space double or more then size of the backup image as restore command will dump data there in that file system.

 

 

db2inst2@mcdb-ha17:~> db2 RESTORE DATABASE AC202 FROM /home/db2inst1/nfsbackup/db200/ac202/db2backupfiles TAKEN AT 20070510091206 NEWLOGPATH /db2data1/db2inst2/data/ac202/logs REDIRECT

SQL1032N  No start database manager command was issued.

 

Make sure instance is up and running. If not start db2 instance.

 

db2inst2@mcdb-ha17:~> db2start

SQL1063N  DB2START processing was successful.

 

 

db2inst2@mcdb-ha17:~> db2 RESTORE DATABASE AC202 FROM /home/db2inst1/nfsbackup/db200/ac202/db2backupfiles TAKEN AT 20070510091206 NEWLOGPATH /db2data1/db2inst2/data/ac202/logs 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.

 

 

As shown in “SQL1277N” you need to set tablespace container for each tablespace as restore is not able to identify path for the tablespace containers in new server (test server).

 

So need to define storage path of each tablespace container.

             

Now run script for set tablespace container.

 

db2inst2@mcdb-ha17:~> db2 -td~ -vf set_tab_cont.sh

set tablespace containers for 0 using (path '/db2data1/db2inst2/data/ac202/SYSCATSPACE')

DB20000I  The SET TABLESPACE CONTAINERS command completed successfully.

 

set tablespace containers for 1 using (path '/db2data1/db2inst2/data/ac202/TEMPSPACE1')

DB20000I  The SET TABLESPACE CONTAINERS command completed successfully.

 

set tablespace containers for 2 using (file '/db2data1/db2inst2/data/ac202/USERSPACE1' 220000)

DB20000I  The SET TABLESPACE CONTAINERS command completed successfully.

 

set tablespace containers for 3 using (file '/db2data1/db2inst2/data/ac202/IDXSPACE1' 132000)

DB20000I  The SET TABLESPACE CONTAINERS command completed successfully.

 

set tablespace containers for 4 using (path '/db2data1/db2inst2/data/ac202/USERTEMP1')

DB20000I  The SET TABLESPACE CONTAINERS command completed successfully.

 

set tablespace containers for 5 using (path '/db2data1/db2inst2/data/ac202/TEMP32SYS')

DB20000I  The SET TABLESPACE CONTAINERS command completed successfully.

 

set tablespace containers for 6 using (file '/db2data1/db2inst2/data/ac202/LONGSPACE1' 1600000)

DB20000I  The SET TABLESPACE CONTAINERS command completed successfully.

 

Above process might take some time as Operating System has to allocate GBs of space to the containers.

 

Once tablespace containers got set, you need to continue restore operation.

 

Use nohup or screen (Linux) command so even if session expires process will continue at backend.

 

db2inst2@mcdb-ha17:~> nohup db2 restore db AC202 continue > continue.out &

[1] 25617

 

Using jobs –l you can check status for the background running jobs

 

db2inst2@mcdb-ha17:~> jobs -l

[1]+ 25617 Running                 nohup db2 restore db AC202 continue >continue.out &

db2inst2@mcdb-ha17:~> jobs -l

[1]+ 25617 Running                 nohup db2 restore db AC202 continue >continue.out &

 

db2inst2@mcdb-ha17:~> jobs -l

[1]+ 25617 Exit 2                  nohup db2 restore db AC202 continue >continue.out

 

 

  • Verification of restore re-direct:

 

db2inst2@mcdb-ha17:~> more continue.out

SQL2517W  The restored database was migrated to the current release. Migration

returned sqlcode "0" and tokens "".

 

Now perform below tasks for verification

 

List database directory and check if database is added in local system directory:

 

db2inst2@mcdb-ha17:~> db2 list db directory

 

System Database Directory

 

Number of entries in the directory = 1

 

Database 1 entry:

 

Database alias                       = AC202

Database name                        = AC202

Local database directory             = /home/db2inst2

Database release level               = a.00

Comment                              =

Directory entry type                 = Indirect

Catalog database partition number    = 0

Alternate server hostname            =

Alternate server port number         =

 

Check db2level:

 

db2inst2@mcdb-ha17:~> db2level

DB21085I  Instance "db2inst2" uses "32" bits and DB2 code release "SQL08025"

with level identifier "03060106".

Informational tokens are "DB2 v8.1.3.112", "s060429", "MI00159", and FixPak

"12".

Product is installed at "/opt/IBM/db2/V8.1".

 

Connect to database:

 

db2inst2@mcdb-ha17:~> db2 connect to AC202

 

   Database Connection Information

 

Database server        = DB2/LINUX 8.2.5

SQL authorization ID   = DB2INST2

Local database alias   = AC202

 

db2inst2@mcdb-ha17:~> db2 terminate    //don’t use conenct reset

DB20000I  The TERMINATE command completed successfully.

 

 

 

 

  • Migrate instance from V8 32 bits to V8 64 bits:

Using DB2IUPDT utility:

 

db2inst1@mcdb-ha17:/opt/IBM/db2/V8.1/instance> sudo ./db2iupdt -w 64 -u db2fenc2 db2inst2

Password:

DBI1070I Program db2iupdt completed successfully.                      

 

 

But it gave error while starting instance

 

db2inst2@mcdb-ha17:/db2data3/db2inst2/data/ac202> db2level

DB21085I  Instance "db2inst2" uses "64" bits and DB2 code release "SQL08025"

with level identifier "03060106".

Informational tokens are "DB2 v8.1.3.112", "s060429", "MI00159", and FixPak "12".

Product is installed at "/opt/IBM/db2/V8.1".

 

db2inst2@mcdb-ha17:~> db2start

SQL1042C  An unexpected system error occurred.

 

If this error occurs just use below command and you will be able to start instance

 

db2inst2@mcdb-ha17:~/sqllib/bin> ipclean

ipclean: Removing DB2 engine and client's IPC resources for db2inst2.

 

 

db2inst2@mcdb-ha17:/db2data3/db2inst2/data/ac202> db2start

SQL1063N  DB2START processing was successful.

 

 

  • Post migration activities:

 

  • Rebinding DB2 Packages:

 

After the database migration you should rebind the DB2 packages for database AC202

 

              cd ~db2<dbsid>/sqllib/bnd

 

db2inst2@mcdb-ha17:~/sqllib/bnd> db2 bind @db2ubind.lst blocking all grant public

 

LINE    MESSAGES FOR db2ubind.lst

------  --------------------------------------------------------------------

        SQL0061W  The binder is in progress.

 

LINE    MESSAGES FOR db2clpnc.bnd

------  --------------------------------------------------------------------

        SQL0595W  Isolation level "NC" has been escalated to "UR".

                  SQLSTATE=01526

 

LINE    MESSAGES FOR db2arxnc.bnd

------  --------------------------------------------------------------------

        SQL0595W  Isolation level "NC" has been escalated to "UR".

                  SQLSTATE=01526

 

LINE    MESSAGES FOR db2ubind.lst

------  --------------------------------------------------------------------

        SQL0091N  Binding was ended with "0" errors and "2" warnings.

 

 

  • Verify packages are migrated into V8 sqllib directory:

 

Check all packages are copied into /sqllib/function/routine/sqlproc/ path and they are same like V7 /sqllib/function/routine/sqlproc/

 

db2inst2@mcdb-ha17:~/sqllib/function/routine/sqlproc/AC202/AC_USER> ls

P0055630  P2549490  P3609540  P3620580  P3622520  P3625290  P3627410  P3629820  P3633620  P3636260  P3639090  P4649720  P0954660  P2724930  P3613200  P3620860  P3623450  P3625600  P3627730  P3630120  P3634040  P3636670  P3639460  P4709790  P1203280  P3109340  P3618380  P3621130  P3623730  P3625900  P3628030  P3630400  P3634360  P3637040  P3640350  P5939870  P1259090  P3225770  P3619240  P3621400  P3624000  P3626190  P3628320  P3631200  P3634870  P3637420  P3641320  P1756630  P3608330  P3619580  P3621670  P3624370  P3626560  P3628610  P3631560  P3635220  P3637830  P3642900  P2042530  P3608780  P3619870  P3621970  P3624670  P3626840  P3629240  P3632770  P3635550  P3638190  P3643220  P2454450  P3609190  P3620170  P3622240  P3624950  P3627130  P3629540  P3633190  P3635900  P3638580  P4459410

 

 

 

 

 

  • Updating your System Catalog Statistics:

 

From DB2 UDB Version 8 and higher, the structure of the system catalog tables has changed. Since the statistics stored for the old Version 7 catalog tables are not suitable for Version 8, you have to update the statistics on the system tables

 

db2inst2@mcdb-ha17:~/sqllib/db2dump> db2 reorgchk update statistics on table system

 

Below file contains out put of reorgchk command.

 

 

  • Converting all Indexes to TYPE-2 Indexes

 

DB2 UDB Version 8 supports a new index type. These TYPE-2 indexes are designed for better performance and concurrency. After your migration to DB2 UDB Version 8 you need to convert all your existing indexes to TYPE-2 indexes to benefit from new features like inplace reorganization

 

 

 

Write a script to convert all type1 indexes into type2 indexes as shown below.

 

db2inst2@mcdb-ha17:~/sqllib/db2dump> db2 "select 'reorg indexes all for table ' || chr(34) || rtrim(tabschema) || chr(34) || '.' || chr(34) || tabname || chr(34) || ' convert on all dbpartitionnums ~' from syscat.tables where type = 'T'" | grep reorg > convert.sql

 

db2inst2@mcdb-ha17:~/sqllib/db2dump> head convert.sql

reorg indexes all for table "SYSIBM"."SYSVIEWDEP" convert on all dbpartitionnums ~                                                                                                                                                                       

reorg indexes all for table "SYSIBM"."SYSCOLDIST" convert on all dbpartitionnums ~                                                                                                                                                                       

reorg indexes all for table "SYSIBM"."SYSCOLAUTH" convert on all dbpartitionnums ~    

 

Run script to convert type-I index into Type-II

 

db2inst2@mcdb-ha17:~> db2 -td~ -vf convert.sql

reorg indexes all for table "SYSIBM"."SYSVIEWDEP" convert on all dbpartitionnums

DB20000I  The REORG command completed successfully.

 

reorg indexes all for table "SYSIBM"."SYSCOLDIST" convert on all dbpartitionnums

DB20000I  The REORG command completed successfully.

 

reorg indexes all for table "SYSIBM"."SYSCOLAUTH" convert on all dbpartitionnums

DB20000I  The REORG command completed successfully.

 

reorg indexes all for table "SYSIBM"."SYSSCHEMAAUTH" convert on all dbpartitionnums

DB20000I  The REORG command completed successfully.      

 

:

:

:

 

Above script will convert all type1 indexes into type2 indexes

 

  • Perform offline backup of database (V8 64 bit):

 

Perform the offline backup of database after all above post migration activities.

 

db2inst2@mcdb-ha17:~/backup> more backup.sh

echo 'backup started on `date`';

db2 "backup database AC202 ";

echo 'backup ended on `date`';

 

db2inst2@mcdb-ha17:~/backup> jobs -l

[1]+ 17390 Running                 nohup sh backup.sh >backup.out &

 

[1]+  Done                    nohup sh backup.sh >backup.out

 

You can use DB2CKBKP on this backup image for verification

 

 


0 comments: