Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2004
    Posts
    2

    How to check if db2 is up and running?

    Hi,
    I need to test if db2 (version 8.1) is already started using a script, but I actually don't know anything about the databases already created on it (it is still possible than no database is present at all).
    Is there a solution other than to create a test database and then drop it?
    Thank you

  2. #2
    Join Date
    Jul 2003
    Location
    Austin, TX, USA
    Posts
    278

    Commands

    Hi,

    Please let us know what your operating system is.

    Just login to the db2 command window (start-->run-->db2cmd) and execute the following command.

    db2 list database directory.

    This will list all the databases under the instance.

    The windows option is to see whether the db2 services are running under the services option of the db2 control panel. If it is running that means the instance is started.

    HTH

    Nitin
    HTH

    Nitin

    Ask the experienced rather than the learned

  3. #3
    Join Date
    Feb 2004
    Posts
    2

    Re: Commands

    Hi, tks for your quick reply.
    Unfortunately I need to check on various operating systems (including W2000, Linux, AIX, Solaris, HP-UX).

    The "db2 list db directory" commands works even if db2 is stopped, and moreover if no database is present, it returns an empty list.
    I need a command (or a script) that returns a different errorlevel/exitcode if the instance is running or not.

    I need this as a "precheck" in order to determine if ahould try to create my own database or not.

    Hope this clarify.
    Tks

  4. #4
    Join Date
    Jul 2003
    Location
    Austin, TX, USA
    Posts
    278

    db2start

    Hi,

    The simplest is..

    db2start.

    When you fire this command and the instance is running, you will get the message below else the instance will be started.

    C:\Documents and Settings\nmaker>db2start
    02-20-2004 17:52:00 0 0 SQL1026N The database manager is already active
    .
    SQL1026N The database manager is already active.

    This works on all platforms.

    HTH

    Nitin.
    HTH

    Nitin

    Ask the experienced rather than the learned

  5. #5
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    15

    Re: How to check if db2 is up and running?

    Hi,

    another way is to use the netstat command with the option -a . this command lists all TCP/IP connections you'd then look for the instance name or/and the db2 server port.

    kirna

    Originally posted by jason512
    Hi,
    I need to test if db2 (version 8.1) is already started using a script, but I actually don't know anything about the databases already created on it (it is still possible than no database is present at all).
    Is there a solution other than to create a test database and then drop it?
    Thank you

  6. #6
    Join Date
    Sep 2003
    Location
    canada
    Posts
    230

    Re: How to check if db2 is up and running?

    Originally posted by kirna
    Hi,

    another way is to use the netstat command with the option -a . this command lists all TCP/IP connections you'd then look for the instance name or/and the db2 server port.

    kirna
    another way is toy use

    ps -eaf|grep -i db2sysc


    if you get db2sysc then instance is up

    Thanks

  7. #7
    Join Date
    Sep 2003
    Posts
    237
    On UNIX, in V8 or V7 FP5 or later
    db2_local_ps|wc -l will give number of instance related processes, if you execute the command as instance owner. Your script should check if the number generated is greater than 0 OR not equal to 0 to verify instance is UP
    mota

Posting Permissions

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