Dropping instances
There could be situations when it is necessary to drop an instance. An instance might be dropped by using the db2idrop command.
Getting ready
In this recipe, we will drop the instance db2inst2
, created previously.
How to do it...
The command for dropping an instance is
db2idrop
. You have to be userroot
to drop an instance. First, we need to ensure that the instance is not active. If the instance has active connections and it is active, thedb2idrop
command fails.Stop the instance by force:
[db2inst2@nodedb21 ~]$ db2stop force 07/12/2011 16:38:27 0 0 SQL1064N DB2STOP processing was successful. SQL1064N DB2STOP processing was successful. [db2inst2@nodedb21 ~]$
Note
If the instance hangs for some reason, the
db2_kill
command might be used. It will bring down the instance abruptly. However, be careful running this, because your databases running under this instance remain in an inconsistent mode.As the user
root
, issue the following command to dropdb2inst2
:[root@nodedb21 ~]# /opt/ibm/db2/V9.7/instance/db2idrop db2inst2 DBI1070I Program db2idrop completed successfully.
How it works...
On Linux and Unix, db2idrop
actually deletes the sqllib
directory from the instance owner home. Therefore, it is recommended to save anything you have placed in this directory such as UDFs or external programs.
On Windows, db2idrop
removes the service associated with the instance.
There's more…
As a best practice, before the instance is dropped, it is recommended to save the information related to that instance in a server profile file. In case you plan to recreate the instance and configure it as before, you can simply import the server profile after the instance is created again.
To export the instance profile, use Control Center | Tools | Configuration assistant | Export profile | Customize.
In the Export tab, you have plenty of options to export; choose anything you consider worth being saved.