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.
db2 backup db mydatabase_name
mv MYDATABASE_NAME* /home/myloginname/
drop db mydatabase_name
Then we change into db2 admin server owner and stop admin server
Next step, where we get rid of das server, has to be done as root
Then, as db2 instance owner we stop the instance
And finally, as root we drop the instance and then run deinstaller
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
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