Friday, July 25, 2014

Changing the Default Directory Path for a DB2 Instance

Implementing Connections at a customer site, the databases were getting created in /home/db2inst1 instead of the dedicated filesystem set aside for it.
This is how to change the default database directory for an instance.  

1. Find out what the default database path is:
db2inst1@db2p143:~> db2 "get dbm cfg" | grep -i dftdbpath
 Default database path                       (DFTDBPATH) = /home/db2inst1

 
2. Change the default database path to what you'd like it to be:
db2inst1@db2p143:~> db2 "update dbm cfg using dftdbpath /db2/db2inst1/connections/data1 immediate"
DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed successfully.

3. Confirm the change was made:
db2inst1@db2p143:~> db2 "get dbm cfg" | grep -i dftdbpath
 Default database path                       (DFTDBPATH) = /db2/db2inst1/connections/data1

 
4. Stop the db2 instance:
 db2inst1@db2p143:~> db2stop
0   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.
5. Restart the db2 instance:
db2inst1@db2p143:~> db2start
0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

Done! After that, you can re-run your database creation scripts and they will be created in the correct directory.

No comments: