How to Stop DB2 Instance when the command "db2stop force" Fails?


The problem

When using a DB2 on AIX. When you did the following steps in order:

  • Start DB2 with db2start.
  • Execute db2 connect to prd.
  • Execute db2stop.

When you execute db2stop the following error was raised:

the database manager was not stopped because databases = are still active

The error code was SQL1025N.

To list db2 processes you can execute ps = -aef|grep db2|wc -l

If you even tried db2stop force command and it didn't work, check the following solution.

Solution 1

The command db2stop force will bring down an active instance by force and will stop the instance.Have patience with this command since it could take a lot of time to finish. You can check the list of db2 application with the command given above (ps = -aef|grep db2|wc -l). Rememeber that ""db2stop"" with or without force could hang in certain situations. For example if you executed the command db2stop force multime times a hand is very probable.

Solution 2

You can use the command db2_kill, but it will bring down your instance immediately. This will crash your application. If you use db2_kill,, we recommend to cleanup shared memory. If still not working try to reboot.

Solution 3

Execute the following command to stop db2:

1) ipclean 2) ipcs | grep | awk '{print "" ipcrm -""$1"" ""$2}' > clnhngthrds.ksh chmod +x clnhngthrds.ksh ./clnhngthrds.ksh

Check running threads with: ipcs | grep <instance name>, repeat until the list is empty.

The step above should stop the instance.