Configuring one listener for two databases?

I have two databases in my server and I want to use one listener for both of them. I have done some configurations and so far it's more or less working but something must be wrong because if I do a tnsping for one of the databases in the admin folder  it works:

----------------------------------------------------------------------------------------------------------------------
C:\app\Cris\product\11.2.0\dbhome_1\NETWORK\ADMIN>tnsping testorcl

TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 22-JUN-2
015 14:17:50

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

Parameterdateien benutzt:
C:\app\Cris\product\11.2.0\dbhome_2\network\admin\sqlnet.ora


Adapter TNSNAMES zur Auflösung des Alias benutzt
Verbindungsversuch mit (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP
)(HOST = CRIS-WS)(PORT = 1521))) (CONNECT_DATA = (SID_NAME = OUC) (SERVICE_NAME =
 ORCL.168.1.205)))
OK (0 ms)
----------------------------------------------------------------------------------------------------------------------

Buuuuuuuuut if I do a tnsping for the same database outside this folder [C:\app\Cris\product\11.2.0\dbhome_1\NETWORK\ADMIN] it does not work. Example:

----------------------------------------------------------------------------------------------------------------------
C:\>tnsping testorcl

TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 22-JUN-2
015 14:15:25

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

Parameterdateien benutzt:
C:\app\Cris\product\11.2.0\dbhome_2\network\admin\sqlnet.ora

Adapter HOSTNAME zur Auflösung des Alias benutzt
Verbindungsversuch mit (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROT
OCOL=TCP)(HOST=202.202.236.10)(PORT=1521)))
TNS-12541: TNS: Kein Listener
----------------------------------------------------------------------------------------------------------------------

When I do tnsping for the second database it works no matter in which folder I'm in.
Does anybody have any idea what could be wrong, please help me!
PanadroidAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
My guess is your environment variables are pointing to a different ORACLE_HOME.

So you are calling two different tnsping's which is using two different tnsnames.ora files.
0
PanadroidAuthor Commented:
Yes

This is the tnsnames.ora for the first database
C:\app\Cris\product\11.2.0\dbhome_1\NETWORK\ADMIN>
TESTORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = CRIS-WS)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID_NAME = OUC)
      (SERVICE_NAME = ORCL.168.1.205)
    )
  )

This is my tnsnames.ora for the second database:

C:\app\Cris\product\11.2.0\dbhome_2\NETWORK\ADMIN>
ORCLWE8 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = CRIS-WS)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID_NAME = OWE8)  
      (SERVICE_NAME = ORCLWE8)      
    )
  )


And the listener.ora:
C:\app\Cris\product\11.2.0\dbhome_1\NETWORK\ADMIN>
# listener.ora Network Configuration File: c:\app\Cris\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS =
          (PROTOCOL = TCP)
          (HOST = CRIS-WS)
          (PORT = 1521)
        )
      )
    )
  )


SID_LIST_LISTENER =
     (SID_LIST =
        (SID_DESC =
          (GLOBAL_DBNAME = orcl.168.1.205)
          (ORACLE_HOME = c:\app\Cris\product\11.2.0\dbhome_1)
          (SID_NAME = OUC)
        )
         
        (SID_DESC =
          (GLOBAL_DBNAME = orclwe8)
          (ORACLE_HOME = c:\app\Cris\product\11.2.0\dbhome_1)
          (SID_NAME = OWE8)
        )
     )
0
slightwv (䄆 Netminder) Commented:
The first tnsping uses the correct tnsnames.ora file.

The second tnsping is likely from a different ORACLE_HOME and is using the other one.

The other one doesn't have an entry for testORCL so it fails.

To have one 'common' tnsnames.ora file on a Windows server you need to set the environment variable TNS_ADMIN to point to the correct tnsnames.ora file.

http://docs.oracle.com/cd/E11882_01/network.112/e10835/tnsnames.htm#NETRF259
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.