版本注意事項


|14.3 db2relocatedb (new command)

|db2relocatedb - Relocate Database

|Renames a database, or relocates a database or part of a database (e.g., |container, log directory) as specified in the configuration file provided |by the user. This tool makes the necessary changes to the DB2 instance and |database support files.

|Authorization

|None

|Required Connection

|None

|Command Syntax

|>>-db2relocatedb---f--configFilename---------------------------><
| 
| 

|Command Parameters |

|-f configFilename
|Specifies the name of the file containing configuration information |necessary for relocating the database. This can be a relative or absolute |filename. The format of the configuration file is:

|   DB_NAME=oldName,newName
|   DB_PATH=oldPath,newPath
|   INSTANCE=oldInst,newInst
|   NODENUM=nodeNumber
|   LOG_DIR=oldDirPath,newDirPath
|   CONT_PATH=oldContPath1,newContPath1
|   CONT_PATH=oldContPath2,newContPath2
|   ...

|Where:

|

|DB_NAME
|Specifies the name of the database being relocated. If the database |name is being changed, both the old name and the new name must be specified. |This is a required field.

|DB_PATH
|Specifies the path of the database being relocated. This is the path |where the database was originally created. If the database path is changing, |both the old path and new path must be specified. This is a required field.

|INSTANCE
|Specifies the instance where the database exists. If the database is |being moved to a new instance, both the old instance and new instance must |be specified. This is a required field.

|NODENUM
|Specifies the node number for the database node being changed. The |default is 0.

|LOG_DIR
|Specifies a change in the location of the log path. If the log path |is being changed, then both the old path and new path must be specified. |This specification is optional if the log path resides under the database |path, in which case the path is updated automatically.

|CONT_PATH
|Specifies a change in the location of table space containers. Both |the old and new container path must be specified. Multiple CONT_PATH |lines can be provided if there are multiple container path changes to be |made. This specification is optional if the container paths reside under the |database path, in which case the paths are updated automatically. |

|

|Note:
Blank lines or lines beginning with a comment character |(#) will be ignored. |
|

|Examples

|Example 1

|To change the name of the database TESTDB to PRODDB in the instance DB2INST1 |that resides on the path /home/db2inst1, create the following configuration |file:

|    DB_NAME=TESTDB,PRODDB
|   DB_PATH=/home/db2inst1
|   INSTANCE=db2inst1
|   NODENUM=0

|Save the configuration file as relocate.cfg and use the following |command to make the changes to the database files:

|db2relocatedb -f relocate.cfg

|Example 2

|To move the database DATAB1 from the instance JSMITH on the path /dbpath to the instance PRODINST do the following: |

  1. |Move the files in the directory /dbpath/jsmith to /dbpath/prodinst.
  2. |Use the following configuration file with the db2relocatedb command to make the changes to the database files:
    |   DB_NAME=DATAB1
    |   DB_PATH=/dbpath
    |   INSTANCE=jsmith,prodinst
    |   NODENUM=0
    |

|Example 3

|The database PRODDB exists in the instance INST1 on the path /databases/PRODDB. The location of two tablespace containers needs to be changed as |follows: |

|After the physical directories and files have been moved to the new locations, |the following configuration file can be used with the db2relocatedb command to make changes to the database files so that |they recognize the new locations:

|   DB_NAME=PRODDB
|   DB_PATH=/databases/PRODDB
|   INSTANCE=inst1
|   NODENUM=0
|   CONT_PATH=/data/SMS1,/DATA/NewSMS1
|   CONT_PATH=/data/DMS1,/DATA/DMS1

|Example 4

|The database TESTDB exists in the instance DB2INST1 and was created on |the path /databases/TESTDB. Table spaces were then created with |the following containers:

|   TS1
|   TS2_Cont0
|   TS2_Cont1
|   /databases/TESTDB/TS3_Cont0
|   /databases/TESTDB/TS4/Cont0
|   /Data/TS5_Cont0
|   /dev/rTS5_Cont1

|TESTDB is to be moved to a new system. The instance on the new system |will be NEWINST and the location of the database will be /DB2.

|When moving the database, all of the files that exist in the /databases/TESTDB/db2inst1 directory must be moved to the /DB2/newinst directory. |This means that the first 5 containers will be relocated as part of this |move. (The first 3 are relative to the database directory and the next |2 are relative to the database path.) Since these containers are located |within the database directory or database path, they do not need to be listed |in the configuration file. If the 2 remaining containers are to be moved to |different locations on the new system, they must be listed in the configuration |file.

|After the physical directories and files have been moved to their new |locations, the following configuration file can be used with db2relocatedb to make changes to the database files so that they recognize |the new locations:

|   DB_NAME=TESTDB
|   DB_PATH=/databases/TESTDB,/DB2
|   INSTANCE=db2inst1,newinst
|   NODENUM=0
|   CONT_PATH=/Data/TS5_Cont0,/DB2/TESTDB/TS5_Cont0
|   CONT_PATH=/dev/rTS5_Cont1,/dev/rTESTDB_TS5_Cont1

|Example 5

|The database TESTDB has 2 partitions on nodes 10 and 20. The instance |is SERVINST and the database path is /home/servinst on both nodes. |The name of the database is being changed to SERVDB and the database path |is being changed to /databases on both nodes. In addition, the |log directory is being changed on node 20 from /testdb_logdir |to /servdb_logdir.

|Since changes are being made to both nodes, a configuration file must |be created for each node and db2relocatedb must |be run on each node with the corresponding configuration file.

|On node 10, the following configuration file will be used:

|   DB_NAME=TESTDB,SERVDB
|   DB_PATH=/home/servinst,/databases
|   INSTANCE=servinst
|   NODE_NUM=10

|On node 20, the following configuration file will be used:

|   DB_NAME=TESTDB,SERVDB
|   DB_PATH=/home/servinst,/databases
|   INSTANCE=servinst
|   NODE_NUM=20
|   LOG_DIR=/testdb_logdir,/servdb_logdir

| Usage Notes

|If the instance that a database belongs to is changing, the following must |be done before running this command to ensure that changes to the instance |and database support files will be made: |

|If the instance is changing, the tool must be run by the new instance |owner.

|In a EEE environment, this tool must be run against every node that requires |changes. A separate configuration file must be supplied for each node, that |includes the NODENUM value of the node being changed. For example, if the |name of a database is being changed, every node will be affected and the db2relocatedb command must be run with a separate |configuration file on each node. If containers belonging to a single node |are being moved, the db2relocatedb command only |needs to be run once on that node.

|See Also

|For more information, see the db2inidb - Initialize |a Mirrored Database command in the Command Reference.


[ 頁面頂端 | 前一頁 | 下一頁 | 目錄 | 索引 ]