Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Join Date
    Jan 2009
    Posts
    153

    Unanswered: Force application on database

    Hi Experts,

    How to kill all process of a particular database?

    TIA

  2. #2
    Join Date
    May 2009
    Posts
    508
    Provided Answers: 1
    ratheeshknair, Assuming you are using LUW, try:

    DB2 FORCE APPLICATION ALL

    This should disconnect all applications from the database.

  3. #3
    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

  4. #4
    Join Date
    May 2009
    Posts
    508
    Provided Answers: 1
    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.

  5. #5
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    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

  6. #6
    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 (许 昌)

  7. #7
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    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.7.0.6 os 6.1.0.0

  8. #8
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    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

  9. #9
    Join Date
    Jan 2009
    Posts
    153
    Thanks ARWinner

  10. #10
    Join Date
    Sep 2008
    Location
    Toronto,Canada
    Posts
    655
    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

  11. #11
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    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

  12. #12
    Join Date
    Sep 2008
    Location
    Toronto,Canada
    Posts
    655
    Thanks,

    So,
    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.

  13. #13
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    That could be one way. How often do you anticipate doing this, and does it need to be automatic or just manually started?

    Andy

  14. #14
    Join Date
    Sep 2008
    Location
    Toronto,Canada
    Posts
    655
    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.

  15. #15
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •