Вы находитесь на странице: 1из 5

Cloning DB2 9.7 Database across the platform AIX to Windows.

Author: Amol D Barsagade, Software Architect, IBM India Software Labs, Enterprise Marketing Management, India. Email: amolbarsagade@in.ibm.com

Introduction:- This document will describe the step by step approach to create a clone copy of db2 v9.7 database across the platform. Here the source platform is considered as AIX and Target as Windows. Later you can apply the similar steps for other platform. Objective :- Create a clone copy of the "AEROPLAN" database from AIX machine to any Windows machine. Source DB details Database name Version Operating System Target DB details Database name Version OS :- AEROPLANE :- DB2 9.7 FP-4 :- Windows 7 :- AEROPLANE :- DB2 9.7 FP-2 :- AIX 6.1.0.0

Note:- To simplify this activity we will use db2look and db2move utility.db2look will create the structure of the source database and db2move will move the data from source to target. 1. Conect to the Source DB "AEROPLAN" Verify the following objects and note down the count: db2 connect to aeroplan db2 select count(*) from syscat.tables db2 select count(tabschema) from syscat.tables db2 select count(tabname) from syscat.tables db2 list tablespaces show detail it will display all the tablespaces with the details Note down all the tablespaces details with Tablespace ID & TYPE ( SMS or DMS) db2 select bpname,pagesize from syscat.bufferpools Note down the bufferpool name and its equivalent pagesize. 2. Execute db2look :- At Source machine execute "db2look" utility for "AEROPLAN" Database. to generate the DDL for all the objects and the schema as follows. db2 connect to aeroplan

db2look -d aeroplan -a -e -wrapper wrap -m -l -x -f -o db2look.sql >db2lookoutput.txt -- db2look -d aeroplan -a -e -m -x -f -o db2look1.sql 3. Execute db2move At source machine execute DB2MOVE with EXPORT option Use db2move with export & Lob option at source machine to generate the data transformation script. This scripts will be in ".ixf" format with the message files. db2 connect to aeroplan db2move aeroplan export -l /home/db2inst1/aeroplan Note:Here we have used "- l " option with the location so that the tables having LOBS columns will export at the given location "/home/db2inst1/aeroplan" 4. Move the files from source to target Move db2look and db2move files from source (AIX) machine to Target (Windows) machine. Now you will have ".ixf" files for each table as well as db2look.sql and db2move.lst files on the source destination. 5. Create a target Database on windows db2 create database aeroplan using codepage 1252 country us Note :- make sure the codepage and territory of the source and the target db should be same. db2 connect to aeroplan 6. Create the source database structure on target system To create the source database structure on the target machine execute the db2look.sql copied from the source machine(AIX). db2 -td; -f C:\AEROPLAN\Backup\db2look.sql 7. Verify all the objects Verify all the objects created in source and target database.

Tables. db2 "select count(tabname) from syscat.tables" db2 list tables for schema <schema_name>

Schema

db2 "select schemaname from syscat.schemata" Procedures

db2 select procschema,procname from syscat.procedures Views

db2 select viewschema,viewname from syscat.views Indexes

db2 select indschema,indname from syscat.indexes

8. move the data into the target database After creating the target database structure on windows machine you need to import the data into it. Note:- to execute the db2move command make sure that you are in the same directory where you have kept "db2move.lst" file. e.g. C:\AEROPLAN\db2move cd C:\AEROPLAN\db2move C:\AEROPLAN\db2move > db2 connect to aeroplan Note:- you must specify -l option to import the lobs if exists along with the data db2move aeroplan import -l c:\aeroplan\db2move >output.txt Once the import competed check the "output.txt" and verify all the tables data. There might be some rows of the tables which are not imported due to "primary and foreign" key dependency issue which needs to be addressed manually.

Resources:Using DB2 utilities to clone databases across different platforms http://www.ibm.com/developerworks/data/library/techarticle/dm0403melnyk/index.html Conveniently create new versions of your database objects http://www.ibm.com/developerworks/data/library/techarticle/dm-0608schuetz/ Basic FTP command http://www.cs.colostate.edu/helpdocs/ftp.html

Вам также может понравиться