|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Features Cross-Platform Data Migration
A step-by-step approach to cloning the DB2 Universal Database (DB2 UDB)
By: Ravi Shankar
Nov. 16, 2009 06:00 PM
This article provides a step-by-step approach to cloning the DB2 Universal Database (DB2 UDB) across platforms and describes the usage of DB2 utilities that help to accomplish the task. There is no direct support in DB2 UDB for cross-platform backup and restore operations. It means one cannot simply take a backup of your DB2 UDB running on the Windows operating system and restore it to DB2 UDB running on the Linux operating system. This simple restore operation will not work across platforms. The two DB2 utilities db2move and db2look can be used for cross-platform backup and restore operations. The db2move command helps accomplish the movement of database tables and the db2look command helps transfer other database objects, such as triggers, indexes, sequences, constraints, buffer pools, and tablespaces. b2look command helps to capture the data definition language (DDL) for these objects on the source database and re-create these objects on the target database (see Figure 1).
Migration Life Cycle Data Migration Process 1. Creating dumps on a Source machine 2. Downloading Dumps on a Target machine For example, the following UNIX command will compress the dump files into a single jar file. Example: tar -cf db2dump.tar /<folder path > If you are using FTP for transferring files from the Linux machine to the Windows machine, please note the following. After Compression, the .tar file is to be downloaded in binary mode, whereas the files db2move.lst and db2look.sql are to be downloaded in ASCII mode.
After downloading the file to the Windows machine, you can use tools like TUGZIP to uncompress the tar file. 3. Checking Code page settings
We need to change the code page settings on Windows if it is not the same as Linux box. This is explained in the next section. 4. Changing code page settings To change the code page settings on Windows please use the following steps:
This change affects all sessions db2set db2codepage=1208 This change affects only the current session and should be done before connecting to the database export DB2CODEPAGE=1208 The above code page settings will be reflected for newly created databases and not existing ones. 5. Drop Old DB instance
To drop the database instance you need to have admin privileges. 6. Creating a new database
db2 create db DBNAME DBNAME is the name of the database you want to create. E.g. db2 create db MYESTDB
db2 get db cfg for DBNAME It should show the following settings
7. Connecting to the created database
DB2 CONNECT TO DBNAME USER <user-name> USING "<password>" E.g., DB2 CONNECT TO MYTESTDB USER admin USING "admin" 8. Creating a buffer pool and Table space If the buffer pool and table space are not sufficient then db2move command will fail with the following error SQL0286N A default table space could not be found with a page size of at least "8192" that authorization ID "admin" is authorized to use. To overcome this we need to create buffer pool and table space before we run the db2move command. There are two options to do this.
Creating the buffer pools and Table spaces from db2look_tbs_buf.sql To create buffer pools and tablespaces from a sql file please perform the following steps.
Creating Buffer Pools and Table Spaces from db2 Commands Run the following commands from DB2 CLP.
CREATE BUFFERPOOL BP_16 IMMEDIATE SIZE 250 PAGESIZE 16 K CREATE REGULAR TABLESPACE TBSP_16 PAGESIZE 16 K MANAGED BY DATABASE USING (FILE 'C: \cont1' 3200) EXTENTSIZE 16 OVERHEAD 10.5 PREFETCHSIZE 16 TRANSFERRATE 0.14 BUFFERPOOL BP_16 5. Please ensure that the above commands are run one after the other 6. Also ensure that each command is run in one-line mode. 9. Running DB2MOVE command
To run the db2 move command you have to do the following steps. 1. Open DB2 CLP. 2. Connect to the newly created database. 3. Change the directory to the folder where you have copied the dumps. cd <path to dump folder> 4. Folder dump should contain all the dump files along with db2move.lst file 5. Open this file in any Text Editor 6. Change the schema name for all the tables if you want. Entries in first file will be like this!"DB2UAT "."DESC"!tab1.ixf!tab1.msg! If you want SCHEMA name to be ADMIN change DB2UAT to ADMIN.This can be easily done with the replace feature of text editors. After changing your entries would be like this !"ADMIN "."DESC"!tab1.ixf!tab1.msg! 7. Run the following command DB2MOVE DBNAME import -io REPLACE_CREATE -u <user-name> -p <password> E.g. DB2MOVE ADMIN import -io REPLACE_CREATE -u admin -p admin 8. After completion of DB2MOVE command open IMPORT.out file from the same folder and check for any Errors or Warnings logged. For successful completion no errors should be reported. 10. Verification To verify the number of tables that were migrated run the following command.
The count of all three should be equal to the table count in your dump folder. 11. Running DB2LOOK command Once db2move command is completed successfully, we will run db2look command. To run the db2 look command you have to do the following steps. 1. Open DB2 CLP. 2. Connect to the newly created database. 3. Change the directory to the folder where you have copied the dumps. cd <path to dump folder> 4. Folder criuat should contain all the dump files along with db2look.sql file. 5. Open db2look.sql file in any Text Editor. 6. Check the line "CONNECT TO DBNAME".DBNAME will be the name of the database from which this sql file was generated. 7. Change DBNAME to the name of your newly created database for the migration.Run the following command 8. Change the SCHEMA name as you have done in db2move command. 9. Run the below command. DB2 -tvf db2look.sql 12. Running the INTEGRITY1.BAT file After running the db2look commands it's possible that some of the tables can be in check pending state and we have to bring them to normal state. To do that run integrity1.bat file from DB2 CLP. cd D:\integrity D:\integrity> integrity1.bat 13. Verification To verify the success of db2look command you can do the following:
Conclusion Resources
Reader Feedback: Page 1 of 1
Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
|||||||||||||||||||||||||||||||||||||||||||||||||