|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 |
| 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:
|
|
|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: |
| 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.