| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |
|

06-30-09, 02:18
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 153
|
|
|
Force application on database
|
|
Hi Experts,
How to kill all process of a particular database?
TIA
|
|

06-30-09, 08:39
|
|
Registered User
|
|
Join Date: May 2009
Posts: 457
|
|
ratheeshknair, Assuming you are using LUW, try:
DB2 FORCE APPLICATION ALL
This should disconnect all applications from the database.
|
|

06-30-09, 08:41
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 153
|
|
|
|
FORCE APPLICATION (APPLICATION_HANDLE)-->KILLS THAT PARTICULAR CONNECTION
FORCE APPLICATION ALL --> KILLS ALL CONNECTION IN THE SERVER(HOPE I AM RIGHT)
My requirement is to kill only applications related to a particular DB
TIA
|
|

06-30-09, 08:51
|
|
Registered User
|
|
Join Date: May 2009
Posts: 457
|
|
This is from the COMMAND REFERENCE manual:
Code:
Command parameters
FORCE APPLICATION
ALL All applications will be disconnected from the database.
From what I read, this indicates it only disconnects from the database.
|
|

06-30-09, 09:06
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,473
|
|
Quote:
|
Originally Posted by Stealth_DBA
This is from the COMMAND REFERENCE manual:
Code:
Command parameters
FORCE APPLICATION
ALL All applications will be disconnected from the database.
From what I read, this indicates it only disconnects from the database.
|
That is assuming that you only have one database. If there is more than one DB under the instance and they all have connections, then FORCE APPLICATIONS ALL will kill all the connections to all of the DBs.
This exact question was asked in this forum just a short while ago. Search the forum for the answer.
Andy
|
|

06-30-09, 10:14
|
|
Registered User
|
|
Join Date: Apr 2007
Posts: 6
|
|
suppose if "db2inst1" is your db2 instance ID.
1) db2stop force
2) ipcs -ma | grep db2inst1
3) Is there something left?
4) If so - db2_kill or db2kill
5) Check 2).
6) If still something left - try to remove the segments with ipcrm -m
<segment ID>
Or use below scripts:
- kill all db2 processes
ps -ef | grep db2 | awk '{print "kill -9",$2}' > out.file
chmod 755 out.file
out.file - this will kill all db2 processes
- remove db2 shared memory
ipcs -a | grep db2 | awk '{print "ipcrm -"$1,$2}' > out.ipcs
chmod 755 out.ipcs
edit out.ipcs removing extra fields if necessary
out.ipcs (removes shared memory)
---------------
Eric Xu (许 昌)
|
|

06-30-09, 10:57
|
|
Registered User
|
|
Join Date: Nov 2005
Location: IL
Posts: 552
|
|
Quote:
|
Originally Posted by ratheeshknair
FORCE APPLICATION (APPLICATION_HANDLE)-->KILLS THAT PARTICULAR CONNECTION
FORCE APPLICATION ALL --> KILLS ALL CONNECTION IN THE SERVER(HOPE I AM RIGHT)
My requirement is to kill only applications related to a particular DB
TIA
|
If you have to kill only appls for one DB. Write a script that collects applid for appls that are connected to that db. Then using loop kill only those appls. Problem solved.
Question is why do you need to kill all connections? If it is in order to bring that db down. before you do the kill, you must revoke access. Other wise if you have a persistent applications they will make connections right after the kill command is done.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
DB2 v9.1.0.2 os 5.3.0.0
|
|

06-30-09, 11:10
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,473
|
|
If any of you had bothered to look up the other post like I suggested, you would have found that you can do a QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS that will force the applications only on the DB desired.
Andy
|
|

07-02-09, 03:14
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 153
|
|
|
|

07-25-09, 21:13
|
|
Registered User
|
|
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 580
|
|
Quote:
|
Originally Posted by ARWinner
If any of you had bothered to look up the other post like I suggested, you would have found that you can do a QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS that will force the applications only on the DB desired.
Andy
|
Andy, will this work if 6 different apps are connected as same id as myself ??
I may need to get an array of app_ids to force them. I did not succeed to do that so far in a single statement.
DBFinder
|
|

07-27-09, 09:30
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,473
|
|
This is from the manual:
[Text]
QUIESCE DATABASE results in all objects in the database being in the quiesced mode. Only the allowed user/group and sysadm, sysmaint, dbadm, or sysctrl will be able to access the database or its objects.
Authorization
One of the following:
For database level quiesce:
* sysadm
* dbadm
[/Text]
If you have 6 different applications that connect to the database and they have any of the authorities listed above, then they will not be disconnected.
Normal users should not have these authorities. It gives them too much access to the DB and to DB2.
Andy
|
|

07-27-09, 09:37
|
|
Registered User
|
|
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 580
|
|
Thanks,
So,
Quote:
|
I may need to get an array of app_ids to force them.
|
I do need to set up some sql to get list of app_ids and force these using a loop.
Thanks again.
|
|

07-27-09, 09:41
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,473
|
|
That could be one way. How often do you anticipate doing this, and does it need to be automatic or just manually started?
Andy
|
|

07-27-09, 09:48
|
|
Registered User
|
|
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 580
|
|
Automatic,
Every night ( MirrorNightlyRestore ) job which is pure DOS batch file on Win 2k3 Server currently DB2V9.5 FP 4, last month it was DB2 V8.1.5.
So far it failed only once in last 2 months because of an application that was not disconnected.
|
|

07-27-09, 09:55
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,473
|
|
I assume you want to perform an offline backup since you want to force the users off. If that is the case, then you will have to do a "LIST APPLICATIONS" command and capture the IDs of the user on the DB in question and force them off. I cannot help you with the DOS scripting to do this.
Can you do the "MirrorNightlyRestore" using an online backup? It should be easier to script that.
Andy
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|