ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 更改DB2数据库容器路径相关 db2relocatedb

更改DB2数据库容器路径相关 db2relocatedb

原创 Linux操作系统 作者:wangkxxe 时间:2009-03-25 20:56:21 0 删除 编辑

http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/core/r0004500.htm

db2relocatedb - Relocate Database Command

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.

Authorization

None

Command syntax
Read syntax diagramSkip visual syntax diagram>>-db2relocatedb-- -f--configFilename--------------------------><

Command parameters | | -f configFilename | 9 Specifies the name of the file containing the configuration information necessary for relocating 9 the database. 9 This can be a relative or absolute file name. 9 The format of the configuration file is: 9 9
   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 DB_NAME 9 Specifies the name of the database being relocated. If the database 9 name is being changed, both the old name and the new name must be specified. 9 This is a required field. 9 9 DB_PATH 9 9 Specifies the original path of the database being relocated. 9 If the database path is changing, both the old path and new path must be specified. 9 This is a required field.9 9 9 INSTANCE 9 Specifies the instance where the database exists. If the database is 9 being moved to a new instance, both the old instance and new instance must 9 be specified. This is a required field. 9 9 NODENUM 9 Specifies the node number for the database node being changed. The 9 default is 0. 9 9 LOG_DIR 9 9 Specifies a change in the location of the log path. If the log path 9 is being changed, both the old path and new path must be specified. 9 This specification is optional if the log path resides under the database 9 path, in which case the path is updated automatically.9 9 9 CONT_PATH 9 Specifies a change in the location of table space containers. Both 9 the old and new container path must be specified. Multiple CONT_PATH 9 lines can be provided if there are multiple container path changes to be 9 made. This specification is optional if the container paths reside under the 9 database path, in which case the paths are updated automatically. If you are 9 making changes to more than one container where the same old path is being 9 replaced by a common new path, a single CONT_PATH entry can 9 be used. In such a case, an asterisk (*) could be used both in the 9 old and new paths as a wildcard. 9 9 9 STORAGE_PATH 9 This is only applicable to databases with automatic storage enabled. 9 It specifies a change in the location of one of the storage paths for the database. 9 Both the old storage path and the new storage path must be specified. 9 Multiple STORAGE_PATH lines can be given if there are several storage path changes to be made. 9 9 9 9 9
Note:
9 9
Blank lines or lines beginning with a comment character 9 (#) are ignored.
9 | |
| |Usage notes |

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:

9
    9
  • If a database is being moved to another instance, create the new instance. 9
  • 9 Copy the files and devices belonging to the databases being copied onto the 9 system where the new instance resides. The path names must be changed as necessary. 9 9 9
    Note:
    9 9
    However, if there are already databases in the directory where the database files are moved 9 to, you can mistakenly overwrite the existing sqldbdir file, thereby 9 removing the references to the existing databases. 9 In this scenario, the db2relocatedb utility cannot be used. 9 Instead of db2relocatedb, an alternative is a redirected restore operation.
    9 9 9
  • Change the permission of the files/devices that were copied so that they 9 are owned by the instance owner.
| |

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

| |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 table space containers needs |to be changed as follows:

|
    |
  • SMS container /data/SMS1 needs to be moved to /DATA/NewSMS1. |
  • DMS container /data/DMS1 needs to be moved to /DATA/DMS1.
| |

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.

| |
Note:
|
A similar change is being made to all of the containters; |that is, /maininst_files/allconts/ is being replaced by /MAINDB/ so that a single entry with the wildcard character can be |used: |
   DB_NAME=MAINDB
|   DB_PATH=/home/maininst
|   INSTANCE=maininst
|   NODE_NUM=0
|   CONT_PATH=/maininst_files/allconts/*, /MAINDB/* 

http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/core/r0004500.htm

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12801008/viewspace-578391/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-02-25

  • 博文量
    68
  • 访问量
    94613