Oracle *names

ygzhou518發表於2011-12-14

GLOBAL_DBNAME 、DB_UNIQUE_NAME、DB_NAME、SERVICE_NAME、SERVICE_NAMES之間相互關系

當前環境:

  • ORACLE_SID=ygzhou
    [oracle@ygzhou518]$ env |grep ORA
    ORACLE_SID=ygzhou
    ORACLE_BASE=/u01/app/oracle
    ORACLE_HOSTNAME=ygzhou518
    ORACLE_TERM=xterm
    ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
  • INSTANCE_NAME=ygzhou
    SQL> select instance_name from v$instance;
          INSTANCE_NAME
    --------------------------
             ygzhou
  • DB_NAME=ygzhou
    SQL> select name from v$database;
             NAME
    --------------------------
            YGZHOU
  • DB_UNIQUE_NAME=ygzhou
    SQL> show parameter db_unique_name;
     NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ----------
    db_unique_name                       string      ygzhou
  • SERVICE_NAMES=ygzhou
    SQL> show parameter service_names;
     
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ----------
    service_names                        string      ygzhou    

[grid@ygzhou518 admin]$ strings listener.ora
# listener.ora Network Configuration File: /u01/app/grid/product/11.2.0/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = ygzhou518)(PORT = 2013))
    )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ygzhoudg)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME = ygzhou)
    )
ADR_BASE_LISTENER = /u01/app/grid
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent

[oracle@ygzhou518 admin]$ strings tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
YGZHOU =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ygzhou518)(PORT = 2013))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ygzhou)
    ))
YGZHOUDG =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ygzhou518)(PORT = 2013))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ygzhoudg)
    ))

1、GLOBAL_DBNAME、SERVICE_NAME and SERVICE_NAMES

[oracle@standbyDB admin]$ sqlplus system/system@ygzhou
 
SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 14 02:31:32 2011
 
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
 
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor

[oracle@standbyDB admin]$ sqlplus system/system@ygzhoudg
 
SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 14 02:31:49 2011
 
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
結論:GLOBAL_DBNAME、SERVICE_NAME 與SERVICE_NAMES沒有直接關系、只要保證listener.ora與tnsname.ora中的global_dbname=service_name;

2、DB_UNIQUE_NAME、DB_NAME AND SERVICE_NAMES

[grid@ygzhou518 admin]$ lsnrctl status
 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-DEC-2011 02:37:38
 Copyright (c) 1991, 2009, Oracle.  All rights reserved.
 Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                14-DEC-2011 02:14:05
Uptime                    0 days 0 hr. 23 min. 33 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/grid/product/11.2.0/grid/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/standbyDB/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ygzhou518)(PORT=2013)))
Services Summary...
Service "ygzhoudg" has 1 instance(s).
  Instance "ygzhou", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

SQL> alter system set db_unique_name=target scope=spfile;

[grid@ygzhou518 admin]$ lsnrctl status
 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-DEC-2011 02:37:38
 Copyright (c) 1991, 2009, Oracle.  All rights reserved.
 Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                14-DEC-2011 02:14:05
Uptime                    0 days 0 hr. 23 min. 33 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/grid/product/11.2.0/grid/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/standbyDB/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ygzhou518)(PORT=2013)))
Services Summary...
Service "ygzhoudg" has 1 instance(s).
  Instance "ygzhou", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

SQL> show parameter db_unique_name;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ----------------
db_unique_name                       string      TARGET
SQL>
SQL> show parameter service_name;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ----------------
service_names                        string      TARGET
SQL>

結論:service_names=db_unique_name

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24867586/viewspace-713273/,如需轉載,請註明出處,否則將追究法律責任。

相關文章