参看: http://www.ibm.com/developerworks/cn/education/data/db2-cert7315/section6.html 和 http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0712xiam/index.html?ca=drs The below is how to do the db2 data migration.
(1).Export source data from source DB
db2move <database_name> export -sn <database_schema> -u <DBA> -p <DBA_PASSWORD> > <logFile>
For example:
db2move GEHGAL export -sn GEH_ADMIN -u GEH_ADMIN -p GEH_ADMIN > mv.log
If you want to export the db DDL schema from source DB, you should use the below db2 commands:
db2look -d GEHGAL -e -o ddlfile -i GEH_ADMIN -w GEH_ADMIN
or
db2look -d GEHGAL -u GEH_ADMIN -e -o alltables.sql
(2).Create a 32k normal or large tablespace
db2 CREATE LARGE TABLESPACE LARGEGEHGAL32 PAGESIZE 32 K MANAGED BY DATABASE USING (FILE 'C:\DB2\NODE0000\SQL00001\largegehgal32' 20000) BUFFERPOOL IBMDEFAULT32K
(3).Create the db2 user that should be same name as exported <database_schema> that is from source DB in target DB2 database, assign the 32k tablespace to the user, and delete the other tablespaces
(4).Code page from target DB should be same as the code page of source DB. You should use the following command to check:
db2 get db cfg
If they are different, change the code page in target DB, use the following command:
db2set db2codepage=1252 (1252 is the page code of source DB)
db2 terminate
db2 terminate command must be executed(注意一定要进行terminate)
(5).Create a 16k or 32k temporary tablespace. It will be used when you view the Project Exception List from deployed GEH GUI
DB2 CREATE TEMPORARY TABLESPACE gehgalsystemtmp32 IN DATABASE PARTITION GROUP IBMTEMPGROUP PAGESIZE 32K MANAGED BY SYSTEM USING ('C:\DB2\NODE0000\SQL00001\gehgalsystemtmp32') EXTENTSIZE 32 PREFETCHSIZE 16 BUFFERPOOL IBMDEFAULT32K
(6).Import the data into the target DB
db2move <database_name> import -io create -u <DBA> -p <DBA_PASSWORD> > <logFile>
For example:
db2move GEHGAL import -io create -u GEH_MIGRATION -p Gal@pass > imp.log
Check the imp.log whether the import operation is successful.
If the table schema has been created/existed in target DB, so you can use the following command:
db2move GEHGAL import -io INSERT_UPDATE -u GEH_MIGRATION -p Gal@pass > imp.log
(7).If the export operation is successful, and you will find some tables in userspace1 tablespace, and the other tables in LARGEGEHGAL32 tablespace
(8).If there are some procedures in your db schema, you should execute the procedures that will not be imported into target database
(9).You should change the tables that have identify column if you want to store new messages in the target DB. The below is the commands that reset the identify value of EXCEPTION_MESSAGE table.
select max(EXCEPTION_MESSAGE_ID) from EXCEPTION_MESSAGE
$nextMessageId = max(EXCEPTION_MESSAGE_ID) + 1
alter table EXCEPTION_MESSAGE alter column EXCEPTION_MESSAGE_ID restart with $nextMessageId