Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

DBA Net Service - tnsnames.ora File

Back


Client Connection

connection_diagram


tnsnames.ora File


# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

# Lo
LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1521))


ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.com)
    )
  )


#################################################
# LISTENER_ORCL: local listener
# ORCL:     A TNS name entry

#################################################
# ADDRESS section
#   PROTOCOL parameter: identifies the listener protocol address
#   HOST parameter:     identifies the host name.
#   PORT parameter:     identifies the port. Default = 1521
#   HTTPS_PROXY and HTTPS_PROXY_PORT parameters:
#           Optional, allow the database client connection to traverse through the organization’s forward web proxy.
#           applicable only to the connect descriptors where PROTOCOL=TCPS.
#################################################
# CONNECT_DATA section:
#   SID parameter:          identifies the system identifier (SID) of the Oracle database.
#   SERVICE_NAME parameter  identifies the service. SERVICE_NAMES initialization parameter, typically the global database name
#   INSTANCE_NAME parameter optional, identifies the database instance. useful for an Oracle RAC configuration
#   SERVER parameter        identifies the service handler type.
#        DEDICATED, default value. a dedicated server process is assigned to each user session, providing isolation and dedicated resources for that connection.
#       SHARED, multiple client connections share a common server process.
#       POOLED, typically associated with Oracle Connection Manager. The pool contains shared server processes that are dynamically allocated to client connections as needed.
-- Command uses a connect string that has a complete connect descriptor as the connect identifier instead of a network service name.
CONNECT hr@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server1)
(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=sales.us.example.com)))

-- command uses a connect string that uses network service name sales as the connect identifier
CONNECT hr@sales
CONNECT hr/password@sales   # here sales represent the tnsname entry in the client machine.

Connect using a Connection String

CONNECT username@connect_identifier
CONNECT scott@'(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)
(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=sales.us.example.com)))'

CONNECT scott@'cn=sales, cn=OracleContext, dc=us, dc=example, dc=com'

CONNECT scott@'sales@"good"example.com'
CONNECT scott@"cn=sales, cn=OracleContext, ou=Mary's Dept, o=example"

Lab: Connect using Connection String

lab

lab


Lab: Create TNS name for PDB

Lab02

ORCLPDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orclpdb.com)
    )
  )

sqlplus /  as sysdba

show pdbs;    # confirm the pdb is open
ALTER PLUGGABLE DATABASE orclpdb OPEN;    # open target pdb
CONNECT sys/pwd@orclpdb AS SYSDBA;    # connect to pdb
show con_name   # confirm it is in the pdb

lab02


Lab: Connect with SQL Developer using TNS Name

lab03

lab03

lab03

unknow reason cannot load tns names. Skip

lab03


TOP