分类: 数据库开发技术
2011-03-22 13:16:34
9 This command renames a database, or relocates a database or part of a database 9 (for example, the container and the log directory) as specified in the 9 configuration file provided by the user. This tool makes the necessary changes 9 to the DB2 instance and database support files.
None
>>-db2relocatedb-- -f--configFilename--------------------------><
DB_NAME=oldName,newName 9 DB_PATH=oldPath,newPath 9 INSTANCE=oldInst,newInst 9 NODENUM=nodeNumber 9 LOG_DIR=oldDirPath,newDirPath 9 CONT_PATH=oldContPath1,newContPath1 9 CONT_PATH=oldContPath2,newContPath2 9 ... 9 STORAGE_PATH=oldStoragePath1,newStoragePath1 9 STORAGE_PATH=oldStoragePath2,newStoragePath2 9 ...9 Where: 9 9
9 If the instance that a database belongs to is changing, the following must 9 be done before running this command to ensure that changes to the instance 9 and database support files are made:
9If the instance is changing, the tool must be run by the new instance owner.
|In a partitioned database environment, this tool must be run against every |partition that requires changes. A separate configuration file must be supplied |for each partition, that includes the NODENUM value of the partition being |changed. For example, if the name of a database is being changed, every |partition will be affected and the db2relocatedb command |must be run with a separate configuration file on each partition. If containers |belonging to a single database partition are being moved, the db2relocatedb command only needs to be run once on that partition.
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 table space 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 two partitions on database partition servers |10 and 20. The instance is servinst and the database path is /home/servinst on both database partition servers. The name of the database |is being changed to SERVDB and the database path is being changed to /databases on both database partition servers. In addition, the log |directory is being changed on database partition server 20 from /testdb_logdir to /servdb_logdir.|
||Since changes are being made to both database partitions, a configuration |file must be created for each database partition and db2relocatedb must be run on each database partition server with the |corresponding configuration file.|
||On database partition server 10, the following configuration file |will be used:
|DB_NAME=TESTDB,SERVDB | DB_PATH=/home/servinst,/databases | INSTANCE=servinst | NODE_NUM=10| |
|On database partition server 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| |
Example 6
|The database MAINDB exists in the instance maininst on the path /home/maininst. The location of four table space containers needs to |be changed as follows:
|| /maininst_files/allconts/C0 needs to be moved to /MAINDB/C0 | /maininst_files/allconts/C1 needs to be moved to /MAINDB/C1 | /maininst_files/allconts/C2 needs to be moved to /MAINDB/C2 | /maininst_files/allconts/C3 needs to be moved to /MAINDB/C3|
After the physical directories and files are 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=MAINDB | DB_PATH=/home/maininst | INSTANCE=maininst | NODE_NUM=0 | CONT_PATH=/maininst_files/allconts/*, /MAINDB/*