Please pay attention, one gateway can only connect to one, dedicated foreign database. So when you want to access 2 different DB2 databases, then you need to configure 2 gateways.
That just means you need a separate entry in the gateway listener with its own SID (for example dg4odbc1, dg4odbc2 or any other name of your choice.) Having separate gateway SID entries requires also separate gateway config files as they depend on the SID name of the gateway. Finally in the tnsnames.ora of the Oracle database you need to have an entry pointing to each gateway SID which you can then specify in your create database link statement.
So regarding the 2 Oracle instances you only need to make sure that the gateway tns entry is present in the tnsnames.ora file used by the Oracle database to be able to create the database link and to use the gateway.
Is the gateway installed in the ORACLE_HOME of the existing Oracle instance install ? If it is in a separate gateway only ORACLE_HOME it makes it easier but even so, you can use the existing gateway from the new Oracle instance.
You need to do the following -
- in the gateway ORACLE_HOME create a new gateway instance that accesses the new DB2. You can copy and rename the existing gateway instance, making sure to change the connect details.
- add the new gateway instance to the gateway listener.ora
- on the new Oracle instance create a tnsnames.ora entry that refers to the gateway listener and new instance.
- create a database link in the new Oracle instance that uses this new tnsnames.ora entry.
If you have access to My Oracle Support have a look at this note -
How To Add A New Database or Destination To An Existing Gateway Configuration (Doc ID 1304573.1)