DB2 – Uninstall

Sometimes it is necessary to uninstall DB2 and then possible install it again. Do not think that db2_deinstall command alone would do this. You have to execute several steps in order to get completely rid of db2.


Default installation path for binaries is
DB2DIR = /opt/ibm/db2/9.7.2
9.7.2 is version number, so if you are using different version of DB2, then change it accordingly.

First I suggest you backup all databases, AND then move those backup copies to some other folder, since db2inst1 folder will be totally deleted in the last step. Change into user db2inst1, cd into db2inst1 home directory, then backup database and last, move all backups to your own home directory. Then it is advisable to drop those database also.

su db2inst1
cd
. ~/sqllib/db2profile
db2 backup db mydatabase_name
mv MYDATABASE_NAME* /home/myloginname/
drop db mydatabase_name
exit

Then we change into db2 admin server owner and stop admin server

su dasusr1
cd
. ~/das/dasprofile
db2admin stop
exit

Next step, where we get rid of das server, has to be done as root

sudo su
DB2DIR/instance/dasdrop
exit

Then, as db2 instance owner we stop the instance

su db2inst1
. ~/sqllib/db2profile
db2stop force
db2 terminate
exit

And finally, as root we drop the instance and then run deinstaller

sudo su
DB2DIR/instance/db2idrop db2inst1
DB2DIR/install/db2_deinstall -a
exit

DB2 related users and directories still exist. Lets get rid of them

sudo userdel -r db2inst1
sudo userdel -r db2fenc1
sudo userdel -r dasusr1

If you want to install DB2 again (maybe different version), there should be no old files remaining. But you have backups in your own home directory, and you can restore your database after new install.

Directories and Links not removed
Experience has shown that some symbolic links and even directories may be left behind. If you are deleting the DB2 installation because you want to install another version of DB2, then it is advisable to remove manually these links and directories, since they might hinder other version in various ways. At least for me db2rmln command was not able to remove such links. These are usually on directories

/usr/lib/
/usr/include/

You can find them with snappy command line trick (ls is piped to grep)

ls -l /usr/include | grep "VX.X"
ls -l /usr/lib | grep "VX.X"

Just replace X.X with the version number of DB2 you were using. Then remove all these symbolic links. If you were using 9.7 then with these commands you get rid of all links

sudo rm /usr/lib/libdb2*
sudo rm /usr/include/db2*
sudo rm /usr/include/fsumplugin.h
sudo rm /usr/include/sql*
sudo rm /usr/include/asn.h
sudo rm /usr/include/gssapiDB2.h

With other versions there may be differences.

Check also that db2_deinstall did not leave the VX.X directory. You can now remove it with

sudo rm -r /opt/ibm/db2/VX.X

Comments
3 Responses to “DB2 – Uninstall”
  1. Thomas says:

    Thank you ! Very good description… Saves a lot of my time….

  2. Thomas says:

    for complete remove, I also need to remove the groups

    dasadm1
    db2fadm1
    db2iadm1

  3. BinkyTheClown says:

    Great post!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

  • Enter your email address to follow this blog and receive notifications of new posts by email.

    Join 99 other followers

Follow

Get every new post delivered to your Inbox.

Join 99 other followers

%d bloggers like this: