Updating a database option in DB2
Sometimes after a database has been created, you may want to move where the default log path is. Or you may want to change DB2 places the log path in the home directory, and you may want to have the logs stored on another storage device.
Login as the DB2 adminstrative user, then type the following command to change your log path:
> db2 UPDATE DB CFG FOR MyDB USING <OptionName – ex., NEWLOGPATH> <Value – ex., /db2data/AnyDirectory/NODE0000/logdir>
Stop and restart DB2 (db2stop force and db2start). Your new log path is now active.
Updating the log path in DB2
Sometimes after a database has been created, you may want to move where the default log path is. DB2 places the log path in the home directory, and you may want to have the logs stored on another storage device.
Login as the DB2 adminstrative user, then type the following command to change your log path:
> db2 UPDATE DB CFG FOR MyDB USING NEWLOGPATH /db2data/AnyDirectory/NODE0000/logdir
Stop and restart DB2 (db2stop force and db2start) and the your new log path will now be active.
Dropping a DB2 database
Normally, to drop a database in DB2, you run the following command:
>db2 drop db YourDb
If you run into errors trying to drop the database, you may need to recatalog the database. You can run the following series of commands:
>db2 uncatalog db YourDb
>db2 catalog database
Restart DB2.
Then run:
>db2 drop db YourDb
Changing a DB2 server name
If you find DB2 not being able to start because of a server name problem, it most likely is caused by moving a virtual machine and not renaming the DB2 database.
To update DB2 to the proper name:
- Stop DB2 as administrator (db2inst user).
>su – db2inst
>db2stop
If there are open database connections, then force them off.
>db2stop force - Go to the sqllib directory.
- Edit the db2nodes.cfg file. The file is usually read-only, so make enable writing first.
>chmod u+w db2nodes.cfg
>vi db2nodes.cfg - In the db2nodes.cfg file, rename the existing computer name to that of the new computer name.
- Save the file.
- Reset the permissions to read-only.
>chmod u-w db2nodes.cfg - Start DB2.
>db2start
You should no longer see any error messages about finding the database.
