Monday 30 December 2013

Connect Oracle to DB2

To BottomTo Bottom

26-Sep-2012HOWTO
Rate this documentEmail link to this documentOpen document in new windowPrintable Page
In this Document


Goal

Fix
 How to Setup DG4DRDA 11.2 (Oracle Database Gateway for DRDA) on Unix (Linux, AIX, HP-UX Itanium and Solaris)

This document is being delivered to you via Oracle Support's Rapid Visibility (RaV) process and therefore has not been subject to an independent technical review.

Applies to:

Oracle Database Gateway for DRDA - Version 11.2.0.0 and later
IBM AIX on POWER Systems (64-bit)
Oracle Solaris on SPARC (64-bit)
HP-UX Itanium
Linux x86-64

Goal

Starting with 11.2 Oracle released a complete new DRDA gateway containing features of the old DRDA gateway release up to 11.1, of the TG4DB2/400 gateway and the Mainframe gateway TG4DB2.
This new DRDA gateway release is certified with Oracle database release 10.1.0.5, 10.2.0.3 after applying the gateway compatibility patch bug 5965763 or you can directly use it with Oracle RDBMS 10.2.0.4, 10.2.0.5, 11.1  and 11.2.

It might work with 9.2.0.8 after applying patch bug 5965763 but there's no guarantee as the 11.2 gateway was never officially certified with 9.2.0.8 Oracle database release.

Fix

How to Setup DG4DRDA 11.2 (Oracle Database Gateway for DRDA) on Unix (Linux, AIX, HP-UX Itanium and Solaris)


The Oracle Database Gateway for DRDA for Unix platforms comes on a separate CD. It can be installed into an existing 11gR2 database Oracle_Home (please pay attention that if the Oracle_Home contains an already patched release of the database; then you MUST apply this patchset again. The reason for this is that the gateway installation might overwrite already patched libraries with the base version as delivered on the CD. To get a proper environment again an already applied patchset needs to be reapplied) or into its own, separate Oracle_Home.

After the installation the following items must be configured:
1) listener (in the ORACLE_HOME where the gateway software is installed)
2) tnsnames (in the ORACLE_HOME where the Oracle database software is installed)
3) init<SID>.ora of the hs subsystem (in the ORACLE_HOME where the gateway software is installed)
4) Oracle database
  1. The listener needs a new SID entry like the following:
        
    (SID_NAME=dg4db2)
         (ORACLE_HOME=/home/oracle/oracle/product/11.2)
         (ENV="LD_LIBRARY_PATH=/home/oracle/product/11.2/dg4db2/driver/lib;/home/oracle/product/11.2/lib")
         (PROGRAM=dg4db2)



    Please correct the ORACLE_HOME entry and the ENV entry according to your installation.
    We strongly recommend to add the LD_LIBARARY_PATH to the listener.ora file to avoid any conflicts with already existing ODBC driver managers.
    SIDE NOTE: For AIX please use LIBPATH instead of LD_LIBRARY_PATH
    The LD_LIBRARY_PATH must contain the full qualified path to the $ORACLE_HOME/lib and $ORACLE_HOME/dg4db2/driver/lib directory. Please do NOT use $ORACLE_HOME variable in the ENV path.


    So a listener.ora file with a listener listening on port 1512 might look like:
    SID_LIST_LISTENER =
      (SID_LIST =
        (SID_DESC =
          (SID_NAME=dg4db2)
           (ORACLE_HOME=/home/oracle/oracle/product/11.2)
          (ENV="LD_LIBRARY_PATH=/home/oracle/product/11.2/dg4db2/driver/lib;/home/oracle/product/11.2/lib")
         (PROGRAM=dg4db2)
       )
     )
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS_LIST =
            (ADDRESS = (PROTOCOL = TCP)(HOST = <hostname of the Oracle Gateway Server>) (PORT = 1512))
          )
        )
     )


    The listener must be stopped and started after changing the listener.ora file!
  2. The tnsnames.ora needs an entry for the DG4DB2 alias:
    dg4db2.de.oracle.com =
      (DESCRIPTION=
        (ADDRESS=(PROTOCOL=tcp)(HOST=<hostname of the Oracle Gateway Server>)(PORT=1512))
        (CONNECT_DATA=(SID=dg4db2))
        (HS=OK)
      )



    The domain of the tns alias can differ from the one used above (de.oracle.com), depending on the parameter in the sqlnet.ora:
    NAMES.DEFAULT_DOMAIN = de.oracle.com

    But the important entry is the (HS=OK) key word. (HS=) is also a valid entry, but DBCA and NetCA will only recognize (HS=OK) entries and remove any (HS=) entries.

    After adding the tnsnames alias and restarting the listener, a
    connectivity check is to use tnsping <alias>.
                  tnsping dg4db2
    should come back with a successfull message.
  3. init.ora of the gateway:
    There are some restrictions how to name the SID (described in the Net Administrators Guide in detail).
    At this place only a short note: don't use dots in the SID and keep it short!

    The SID is also relevant for the initialiastion file of the gateway. The name of the
    file is init<SID>.ora. In this example it is called initdg4db2.ora.
    The file is located at $ORACLE_HOME/dg4db2/admin.
    It should contain at least the connect details:

    #
    HS_FDS_CONNECT_INFO=<DB2 hostname>:<DRDA Port>/<database>,<Type>

    # alternate connect format is hostname/serverinstance/databasename

    Short explanation of the parameter HS_FDS_CONNECT_INFO:
    <DB2 hostname>: is the hostname of the DB2 database. It can be determined by running a select statement directly on the DB2 database : SELECT CURRENT SERVER FROM <any_table>
    where any_table is a valid table with one or more rows.
    <DRDA Port> is the port of the DRDA server
    <database> is the name of the DB2 database you want to connect to
    <Type> specifys to which DB2 you want to connect to:
    ZOS (DB2 UDB for z/OS),
    IOS (DB2 UDB for iSeries), or
    LUW (DB2 UDB for Linux, Unix, or Windows)

    Example:
    HS_FDS_CONNECT_INFO=[db2.de.oracle.com]:5151/DB2,ZOS
  4. Configuring the Oracle database
    The only thing that must be done here is to create a database link:
    connect with the username/password that has sufficient rights to create a
    database link (i.e. system).
    The syntax is:
    create [public] database link <name>
    connect to <UID> identified by <pwd> using '<tnsalias>';


    In other words, to connect to the DB2 database configured in the last steps,
    the syntax must be:
    CREATE DATABASE LINK db2
    CONNECT TO db2admin IDENTIFIED BY password USING 'dg4db2';


    This new DB2 gateway is now binding the DB2 packages automatically. Thus you need to make sure you grant the required privileges to the DB2 user before the first usage of the gateway. More details of the privileges required for every DB2 database are mentioned in the manual.


Hello,

Please try to change your listener.ora file (in GATEWAY_HOME/network/admin) to :

DB2 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ebizprod.aarav.co)(PORT = 1721))
)
)

SID_LIST_DB2=
(SID_LIST=
(SID_DESC=
(SID_NAME=dg4db2)
(ORACLE_HOME=/u01/oracle/product/11.2.0/tg_1)
(ENV="LD_LIBRARY_PATH=/u01/oracle/product/11.2.0/tg_1/dg4db2/driver/lib;/u01/oracle/product/11.2.0/tg_1/lib")
(PROGRAM=dg4db2)
)
)

Note : I have changed the port number to 1721 (my choice, but you can choose another), because I suppose that 1521 is already dedicated to the Database.

To start this listener, you have to use the command:
lsnrctl start db2
and to get the status
lsnrctl status db2

If you use the listener above, you have to change the tnsnames.ora (in DATABASE_HOME/network/admin) to :
dg4db2 =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=ebizprod.aarav.co)(PORT=1721))
(CONNECT_DATA=(SID=dg4db2))
(HS=OK)
)

Once done, you should be able to test the connection with a command (from the database environment):
tnsping dg4db2

Please let me know the result.

No comments:

Post a Comment