oracle例項和監聽器

路途中的人2012發表於2015-09-29

一、靜態註冊

靜態註冊指例項啟動時讀取listener.ora配置檔案,將例項和服務註冊到監聽程式。無論何時啟動一個
,預設都有兩條資訊註冊到監聽器中:例項和服務。
SID_LIST_LISTENER =
  ( SID_LIST =
      (SID_DESC =
         (GLOBAL_DBNAME = Ora8)
         (SID_NAME = test)
      )
  )

LISTENER =
  ( DESCRIPTION =
     (ADDRESS = (HOST = 192.168.0.8)(PROTOCOL = TCP)(PORT = 1522))
  )
這是一個最簡單的靜態監聽配置檔案,SID_LIST_LISTENER部分的GLOBAL_DBNAME表示向外提供的服務名,SID_NAME是提供註冊的例項。
在tnsnames.ora檔案中的CONNECT_DATA部分,可分別選擇SERVICE_NAME=Ora8或SID=test為客戶端提供連線。
對於配置非1521監聽埠,只能選擇靜態註冊方式。
二、動態註冊
動態註冊不需要顯示的配置listener.ora檔案,例項啟動的時候,PMON程式根據instance_name,service_name引數將例項和服務動態註冊到listerer中。如果沒有設定instance_name,將使用db_name初始化引數值。如果沒有設定service_names,將拼接db_name和db_domain引數值來註冊監聽。
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      test
SQL> show parameter instance_name

             NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_name                        string      test

LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------

Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                24-SEP-2008 16:50:01
Uptime                    0 days 0 hr. 0 min. 33 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test1)(PORT=1521)))
Services Summary...
Service "test" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
Service "test_XPT" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
The command completed successfully


SQL> alter system set service_names='oratest' scope=both;

System altered.

SQL> alter system set instance_name='instest' scope=spfile;

System altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area   96468992 bytes
Fixed Size                  1217884 bytes
Variable Size              88083108 bytes
Database Buffers            4194304 bytes
Redo Buffers                2973696 byte
Database mounted.
Database opened.
LSNRCTL> status

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                24-SEP-2008 16:52:44
Uptime                    0 days 0 hr. 1 min. 52 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log

Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test1)(PORT=1521)))
Services Summary...
Service "oratest" has 1 instance(s).
  Instance "instest", status READY, has 1 handler(s) for this service...
Service "test" has 1 instance(s).
  Instance "instest", status READY, has 1 handler(s) for this service...
Service "test_XPT" has 1 instance(s).
  Instance "instest", status READY, has 1 handler(s) for this service...
The command completed successfully
可以看到,監聽註冊的服務和例項已發生了相應的變化。同靜態監聽,這裡也可以分別使用SERVICE_NAME=oratest或SID=instest來進行客戶端的連線

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

相關文章