靜態註冊和動態註冊

ora_erin發表於2013-11-27

--整理以前的學習筆記


相關文章:http://blog.itpub.net/26524307/viewspace-1061151/


1、動態註冊
例項啟動的時候會進行動態註冊,alter system register也是動態註冊,動態註冊不需要listener.ora,如果

local_listener引數為空,則預設註冊到本機的1521埠


2、靜態註冊
先把例項關閉
在netmgr啟動net manager,在net manager-local-listeners下,對於這個預設監聽器listener,
選擇database services-add database,輸入
Global Database Name:aa(可以是任意的名字)
Oracle Home Directory:/u01/oracle
SID:ORCL


儲存之後,發現listener.ora中多了下面一項(這就是靜態註冊要配置的東西,是可以通過net manager來配置的)
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = aa)
      (ORACLE_HOME = /u01/oracle)
      (SID_NAME = ORCL)
    )
  )


重新啟動listener:lsnrctl start(此時就可以看到靜態註冊的服務了,unknown狀態的就是靜態註冊的)
[oracle@mylinux admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 08-APR-2012 20:27:20
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mylinux)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                08-APR-2012 20:25:49
Uptime                    0 days 0 hr. 1 min. 30 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/oracle/network/admin/listener.ora
Listener Log File         /u01/diag/tnslsnr/mylinux/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mylinux)(PORT=1521)))
Services Summary...
Service "AA" has 1 instance(s).
  Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully


此時如果再啟動例項(啟動例項的過程中PMON會根據local_listener動態註冊到相應的監聽)
[oracle@mylinux admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 08-APR-2012 20:28:21
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mylinux)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                08-APR-2012 20:25:49
Uptime                    0 days 0 hr. 2 min. 32 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/oracle/network/admin/listener.ora
Listener Log File         /u01/diag/tnslsnr/mylinux/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mylinux)(PORT=1521)))
Services Summary...
Service "AA" has 1 instance(s).
  Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
發現既有動態註冊的服務(ready狀態的),也有靜態註冊的服務(unknown狀態的)


如果已經靜態註冊,但是例項並沒有啟動的話,在客戶端用tnsping可以通,
C:\Documents and Settings\Administrator>tnsping orcllx
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 08-4月 -
2012 22:21:05
Copyright (c) 1997, 2005, Oracle.  All rights reserved.
已使用的引數檔案:
D:\oracle\product\10.2.0\client_1\network\admin\sqlnet.ora
已使用 TNSNAMES 介面卡來解析別名
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.1.10)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = AA)))
OK (100 毫秒)


使用SQLPLUS連線,提示連線到空閒例程:
C:\Documents and Settings\Administrator>sqlplus sys/oracle@orcllx as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期日 4月 8 22:21:16 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
已連線到空閒例程。

SQL>

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

相關文章