Nonstop Database, HiRDB Version 9 System Operation Guide

[Contents][Index][Back][Next]

12.1.6 Example 2: Migrating tables of a schema

This example migrates to HiRDB system B all tables in HiRDB system A owned by the user with authorization identifier USR01. It is assumed that RDAREAs with the same names have been created in the migration target system. Unloading and reloading of the tables is performed by schema (all tables in the specified schema are unloaded and reloaded).

[Figure]

Organization of this subsection
(1) Use the pdhold command to shut down RDAREAs storing data to be migrated
(2) Create the control statements file for the pdrorg command
(3) Use the pdrorg command to unload tables by schema
(4) Use the pdrels command to release RDAREAs from shutdown status
(5) Create the control statements file for the pdexp command
(6) Use the pdexp command to export table definition information on all tables
(7) Store the unload data file and export file on a medium such as CMT
(8) Store the unload data file and export file at the migration target system
(9) Use the pddef command to define a schema (authorization identifier: USR01)
(10) Swap the system log files
(11) Use the pdcopy command to back up the data
(12) Use the pdexp command to import table definition information
(13) Use the pdhold command to shut down RDAREA1-RDAREA6
(14) Create the control statements file for the pdrorg command
(15) Use the pdrorg command to reload all tables
(16) Swap the system log files
(17) Use the pdcopy command to back up the data
(18) Use the pdrels command to release RDAREAs from shutdown status

(1) Use the pdhold command to shut down RDAREAs storing data to be migrated

 
pdhold -r RDAREA1,RDAREA2,RDAREA3,RDAREA4,...
 

(2) Create the control statements file for the pdrorg command

The following are the contents of the control statements file (/pdrorg/rorg01).

(a) HiRDB single server configuration
 
unload /pdrorg/unfile1
 

Explanation
Specifies the name of the unload data file.
(b) HiRDB parallel server configuration
 
unload bes1:/pdrorg/unfile1
 

Explanation
Specifies the name of the unload data file. Because the -g option is assumed, the unload data file is created at one location.

(3) Use the pdrorg command to unload tables by schema

 
pdrorg -k unld -t USR01.all /pdrorg/rorg01
 

Explanation
-k: Specifies unld for unloading.
-t: Specifies the authorization identifier of the schema whose tables are to be unloaded.
/pdrorg/rorg01: Specifies the name of the control statements file for the pdrorg command created in step (2).

Remarks
When tables are unloaded by schema, the -j option (unloading with LOB data present) is assumed. In the case of a HiRDB parallel server configuration, the -g option (unload data file standardization) is also assumed.

(4) Use the pdrels command to release RDAREAs from shutdown status

 
pdrels -r RDAREA1,RDAREA2,RDAREA3,RDAREA4,...
 

(5) Create the control statements file for the pdexp command

The following are the contents of the control statements file (/pdexp/exp01):

 
-t USR01.TABLE1
-t USR01.TABLE2
 

Explanation
USR01: Name of the schema to which TABLE1 and TABLE2 belong.
TABLE1,TABLE2: Names of the tables being exported.

(6) Use the pdexp command to export table definition information on all tables

 
pdexp -e /pdexp/expfile1 -f /pdexp/exp01
 

Explanation
-e: Specifies the name of the file that is to be exported.
-f: Specifies the name of the control statements file for the pdexp command that was created in step (5).

(7) Store the unload data file and export file on a medium such as CMT

The unload data file created in step (3) and the export file created in step (6) are stored on a medium such as CMT.

Operations at the migration source system (HiRDB system A) have now been completed.

(8) Store the unload data file and export file at the migration target system

The operations from here on are performed at the migration target system (HiRDB system B).

The unload data file and export file that have been stored on a medium such as CMT are now stored at the migration target system.

(9) Use the pddef command to define a schema (authorization identifier: USR01)

This operation is not necessary if the tables are being migrated to a different schema (a schema other than USR01).

 
pddef
   CREATE SCHEMA AUTHORIZATION USR01;
 

(10) Swap the system log files

Before making a backup copy, use the pdlogswap command to swap the system log files.

 
pdlogswap -d sys -w
 

Explanation
For a HiRDB parallel server configuration, specify the -s option and execute the pdlogswap command on each server that is to be backed up.

(11) Use the pdcopy command to back up the data

 
pdcopy -m /rdarea/mast/mast01 -M r
-r RDMAST,RDDIR,RDDIC,RDAREA1,RDAREA2,RDAREA3,RDAREA4,RDAREA5,RDAREA6
-b /pdcopy/backup01 -p /pdcopy/list01
 

Explanation
A backup is made as a safeguard in the event errors occur during database migration. The following RDAREAs are backed up:
  • Master directory RDAREA
  • Data directory RDAREA
  • Data dictionary RDAREA
  • User RDAREAs and user LOB RDAREAs that store the tables being imported (RDAREA1-RDAREA6)
-m: Specifies the name of the first HiRDB file in the master directory RDAREA.
-M: Specifies the backup acquisition mode.
-r: Specifies the names of the RDAREAs to be backed up.
-b: Specifies a name for the backup file.
-p: Specifies the output destination for the pdcopy command's processing results listing.
For details about making backups, see 6. Backup Procedures.

(12) Use the pdexp command to import table definition information

 
pdexp -i /pdexp/expfile1
 

Explanation
-i: Specifies the name of the export file.

(13) Use the pdhold command to shut down RDAREA1-RDAREA6

 
pdhold -r RDAREA1,RDAREA2,RDAREA3,RDAREA4,...
 

(14) Create the control statements file for the pdrorg command

Shown below are the contents of the control statements file (/pdrorg/rorg01).

If the tables are to be migrated to a different schema (a schema other than USR01), the contents of the control statements file will be different. For an example of a control statements file when tables are migrated to a different schema, see 12.1.7 Example of a control statements file when migrating tables to a different schema.

(a) HiRDB single server configuration
 
unload /pdrorg/unfile1                        1
idxwork /pdrorg/idxwork                       2
sort /sortwork                                3
 

Explanation
  1. Specifies the name of the unload data file.
  2. Specifies the name of the directory in which an index information file is to be created. The index information file is created under this directory.
  3. Specifies the name of the work directory for sorting.
(b) HiRDB parallel server configuration
 
unload bes1:/pdrorg/unfile1                     1
idxwork bes1 /pdrorg/idxwork                    2
sort bes1 /sortwork                             3
idxwork bes2 /pdrorg/idxwork                    4
sort bes2 /sortwork                             5
 

Explanation
  1. Specifies the name of the unload data file. Because the -g option is assumed, the unload data file is created at one location.
  2. Specifies the name of the directory in which an index information file is to be created (for bes1). The index information file is created under this directory.
  3. Specifies the name of the work directory for sorting (for bes1).
  4. Specifies the name of the directory in which an index information file is to be created (for bes2). The index information file is created under this directory.
  5. Specifies the name of the work directory for sorting (for bes2).

(15) Use the pdrorg command to reload all tables

 
pdrorg -k reld -t USR01.all /pdrorg/rorg01
 

Explanation
Because an index (INDEX1) is re-created simultaneously, the -i option is omitted and indexes are created in the batch index creation mode.
-k: Specifies reld for reloading.
-t: Specifies the authorization identifier of the schema to be reloaded. If the tables are to be migrated to a different schema (a schema other than USR01), specify the authorization identifier at the migration target. For example, if the tables were to be migrated to authorization identifier USR02, the specification would be -t USR02.all.
/pdrorg/rorg01: Specifies the name of the control statements file for the pdrorg command created in step (14).
Remarks
When tables are unloaded by schema, the -j option (unloading with LOB data present) is assumed. In the case of a HiRDB parallel server configuration, the -g option (unload data file standardization) is also assumed.

(16) Swap the system log files

Before making a backup copy, use the pdlogswap command to swap the system log files.

 
pdlogswap -d sys -w
 

Explanation
For a HiRDB parallel server configuration, specify the -s option and execute the pdlogswap command on each server that is to be backed up.

(17) Use the pdcopy command to back up the data

 
pdcopy -m /rdarea/mast/mast01 -M r
-r RDMAST,RDDIR,RDDIC,RDAREA1,RDAREA2,RDAREA3,RDAREA4,RDAREA5,RDAREA6
-b /pdcopy/backup02 -p /pdcopy/list02
 

Explanation
The following RDAREAs are backed up:
  • Master directory RDAREA
  • Data directory RDAREA
  • Data dictionary RDAREA
  • User RDAREAs and user LOB RDAREAs that store the tables being imported (RDAREA10-RDAREA6)
-m: Specifies the name of the first HiRDB file in the master directory RDAREA.
-M: Specifies the backup acquisition mode.
-r: Specifies the names of the RDAREAs to be backed up.
-b: Specifies a name for the backup file.
-p: Specifies the output destination for the pdcopy command's processing results listing.
For details about making backups, see 6. Backup Procedures.

(18) Use the pdrels command to release RDAREAs from shutdown status

 
pdrels -r RDAREA1,RDAREA2,RDAREA3,RDAREA4,...
 

We recommend that after the command has executed you check whether the execution results are correct. For details on how to check command execution results, see the manual HiRDB Version 9 Command Reference.