joi, 25 aprilie 2013

How to exactly match the name of a database listener service

The services of a listener are not given by default, the same with the database name. And, more so, they can be a lot, created subsequently of the database and the first listener creation. So, sometimes, we should address that service we want to use in order to connect to a certain schema and we can't figure out the precise name of the service. Useless to say that in this situation you cannot connect to that given schema by any chance. So, what do you have to do is:


host1 >lsnrctl services

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 25-APR-2013 11:13:22

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:9367 refused:0 state:ready
         LOCAL SERVER
Service "mydb.infra" has 1 instance(s).
  Instance "mydb1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:25443 refused:0 state:ready
         LOCAL SERVER
Service "mydbXDB.infra" has 1 instance(s).
  Instance "mydb1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "D000" established:0 refused:0 current:0 max:1022 state:ready
         DISPATCHER <machine: host1, pid: 21623>
         (ADDRESS=(PROTOCOL=tcp)(HOST=host1.infra)(PORT=50186))
Service "db.infra" has 1 instance(s).
  Instance "db1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:2021 refused:0 state:ready
         LOCAL SERVER
Service "dbXDB.infra" has 1 instance(s).
  Instance "db", status READY, has 1 handler(s) for this service...
    Handler(s):
      "D000" established:0 refused:0 current:0 max:1022 state:ready
         DISPATCHER <machine: host1, pid: 25637>
         (ADDRESS=(PROTOCOL=tcp)(HOST=host1.infra)(PORT=24653))
Service "db_DGB.infra" has 1 instance(s).
  Instance "db1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:2021 refused:0 state:ready
         LOCAL SERVER
The command completed successfully
<oracle@host1:~


Notice that the listener above is by some complexity. It services two databases, db and mydb, the two databases are clustered, the two instances, db_name and db_name1 are registered, the XDB service, meant to ensure the connection to the APEX features (htmldb part of the database) it appears as well in the ecuation.
So if we want to use, let's say the mydb database, we will conect like this:

vi tnsnames.ora


# tnsnames.ora Network Configuration File: \oracle\32\11.2.0\client_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

mydb=
  (DESCRIPTION=
    (ADDRESS=
      (PROTOCOL=TCP)
      (HOST=host-cluster.infra)
      (PORT=1521)
    )
    (CONNECT_DATA=
      (SERVICE_NAME=mydb.infra)
    )
  )

Notice that the host is not found from the lsnrctl command from above, is a scan name, 11g database specific, but it doesn't matter for the purpose here.

Niciun comentariu:

Trimiteți un comentariu