When you create a database in a partitioned database environment, you can specify a drive letter to indicate where the database is to be created.
Note: | You do not set database drive mapping for single-partition database environments. |
When the CREATE DATABASE command runs, it expects that the drive that you specify will be simultaneously available to all of the machines that participate in the instance. Because this is not possible, DB2 uses database drive mapping to assign the same drive a different name for each machine.
For example, assume that a DB2 instance called DB2 contains two database partition servers:
NODE0 is active on machine WOLF_NODE_0 NODE1 is active on machine WOLF_NODE_1
Assume also that the share disk E: belongs to the same group as NODE0, and that the share disk F: belongs to the same group as NODE1.
To create a database on the share disk E:
db2 create database mppdb on e:
For the command to be successful, drive E: must be available to both machines. In a mutual takeover configuration, each database partition server may be active on a different machine, and the cluster disk E: is only available to one machine. In this situation, the CREATE DATABASE command will always fail.
To resolve this problem, the database drive should be mapped as follows:
For NODE0, the mapping is from drive F: to drive E: For NODE1, the mapping is from drive E: to drive F:
Any database access for NODE0 to drive F: is then mapped to drive E:, and any database access for NODE1 to drive E: is mapped to drive F:. Using drive mapping, the CREATE DATABASE command will create database files on drive E: for NODE0 and drive F: for NODE1.
Use the db2drvmp command to set up the drive mapping. The command syntax is as follows:
>>-db2drvmp----+-add-------+------------------------------------> +-drop------+ +-query-----+ '-reconcile-' >----node_number--from_drive--to_drive-------------------------><
The parameters are as follows:
If you wanted to set up database drive mapping from F: to E: for NODE0, you would use the following command:
db2drvmp add 0 F E
Note: | Database drive mapping does not apply to table spaces, containers, or any other database storage objects. |
Similarly, to set up database drive mapping from E: to F: for NODE1, you would issue the following command:
db2drvmp add 1 E F
Note: | Any setup of, or changes to, the database drive mapping does not take effect
immediately. To activate the database drive mapping, use the Cluster
Administrator tool to bring the DB2 resource offline, then online.
Using the TARGET_DRVMAP_DISK keyword in the DB2MSCS.CFG file will enable the drive mapping to be done automatically. |
When a database is created on a machine that has database drive mapping in effect, the map is saved on the drive in a hidden file. This is to prevent the database drive from being removed after the database is created. You will want to reconcile the database drive mapping if, for example, you accidentally drop the database drive map. To reconcile the map, run the db2drvmp reconcile command for each database partition server that contains the database. The command syntax is as follows:
>>-db2drvmp reconcile----+---------------------+--------------->< '-node_number--drive--'
The parameters are as follows:
The db2drvmp command scans all drives on the machine for database partitions that are managed by the database partition server, and reapplies the database drive mapping to the registry as required.