Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2004
    Posts
    6

    Unanswered: Multiple instances in AIX machine - How to easy switch between them?

    Hi:

    I'm having the need to switch between different DB2 instances in a single AIX LPAR without changing user login.

    Here´s scenario:

    -AIX 7.1 lpar
    -4 DB2 V9.7 instances (called db2inst1, db2inst2, db2inst3 and db2inst4)

    All of these instances have the SYSADM group set to the AIX group called DB2ADM.
    My user id is member of this DB2ADM group.

    What I need is something that would allow me to quickly switch between DB2 profiles (.bin files, DB2 Environment variables, etc) and that would let me operate SAFELY each of them.
    I'm worried that I would issue a DB2STOP on the wrong DB2 instance...

    Until now what I'm doing is manually invoking the 'db2profile' file for each instance before acting on it.
    But I'm getting stressed of the additional checking tasks before I issue any command to make sure that I'm acting on the correct instance.

    I hope I'm explaining my situation correctly...

    Does anyone have any brilliant idea on how to do this?

    Your help would be greatly appreciated.

    Regards.
    Enrique Valdez
    Buenos Aires - Argentina

  2. #2
    Join Date
    Sep 2013
    Posts
    11
    search for any gui tool or db2 client tool. toad for db2. you can switch easily b/w the instances.

  3. #3
    Join Date
    Nov 2004
    Posts
    6
    Quote Originally Posted by zulfiqarali.memon View Post
    search for any gui tool or db2 client tool. toad for db2. you can switch easily b/w the instances.
    Thanks for your response. Of course this option would work with any of the tools that you mention.

    I'm more 'command line' driven and that's the reason why I posted this question.

    Thanks again.

    Regards.
    Enrique Valdez

  4. #4
    Join Date
    Apr 2012
    Posts
    1,035
    Provided Answers: 18
    For command-line operation you can either:
    (a) sudo to the relevant instance then run the script or command you need, provided that the shell startup script each instance owner dots in the correct db2profile, or
    (b) if you don't want to change userid (even temporarily) then you can script your programs/commands to take an argument that is the instance-name or number and in the script dot in the relevant db2profile (per the argument) before connecting to the database(s).

    I normally use option (b) in a multi-instance environment if the same script can be instance-agnostic although I allow scripts to have the instance-argument as optional on command line or if absent to default to the value of another variable (read from config file for example).

  5. #5
    Join Date
    Jul 2013
    Location
    Moscow, Russia
    Posts
    666
    Provided Answers: 55
    Hi,

    try to set the PS1 environment variable like:
    Code:
    export PS1="[\$DB2INSTANCE@`hostname`]:\$PWD \> "
    And you will see the instance name in the command prompt.
    Regards,
    Mark.

  6. #6
    Join Date
    Jan 2009
    Location
    Zoetermeer, Holland
    Posts
    746
    Quote Originally Posted by mark.b View Post
    Hi,

    try to set the PS1 environment variable like:
    Code:
    export PS1="[\$DB2INSTANCE@`hostname`]:\$PWD \> "
    And you will see the instance name in the command prompt.
    yes, combine with some quick alias-ses like:
    Code:
    alias i1='db2 terminate && . /home/db2inst1/sqllib/db2profile'
    alias i2='db2 terminate && . /home/db2inst2/sqllib/db2profile'
    alias i3='db2 terminate && . /home/db2inst3/sqllib/db2profile'
    alias i4='db2 terminate && . /home/db2inst4/sqllib/db2profile'
    Do not forget to enable at least 1 instance in your ~/.profile to support the initial 'terminate'. You can work on all databases form you own home dir so you can easely share all you nice little scripts
    Somewhere between " too small" and " too large" lies the size that is just right.
    - Scott Hayes

  7. #7
    Join Date
    Nov 2004
    Posts
    6
    Hi all!!!

    Seems easier than what I originally thought...!!

    I'll work on it and let you know about the outcome...

    Regards.
    Enrique Valdez

  8. #8
    Join Date
    Jan 2009
    Location
    Zoetermeer, Holland
    Posts
    746
    Put this in your ~/.profile
    Code:
    typeset -i inst_nr=0
    rm -f ~/extra_db2_alias.txt
    for myDB2Inst in `db2ilist`
    do
       inst_nr=$((${inst_nr}+1))
       echo "alias i${inst_nr}='. /appl/udb/${myDB2Inst}/sqllib/db2profile'" >> ~/extra_db2_alias.txt 
       echo "alias s${inst_nr}='su -        ${myDB2Inst}'"                   >> ~/extra_db2_alias.txt 			
    done
     . ~/extra_db2_alias.txt
    Somewhere between " too small" and " too large" lies the size that is just right.
    - Scott Hayes

Posting Permissions

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