天天看點

oracle執行個體和監聽器

一、靜态注冊

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).

The command completed successfully

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

System altered.

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

SQL> shutdown immediate

Database closed.

Database dismounted.

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.

Start Date                24-SEP-2008 16:52:44

Uptime                    0 days 0 hr. 1 min. 52 sec

 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test1)(PORT=1521)))

Service "oratest" has 1 instance(s).

  Instance "instest", status READY, has 1 handler(s) for this service...

可以看到,監聽注冊的服務和執行個體已發生了相應的變化。同靜态監聽,這裡也可以分别使用SERVICE_NAME=oratest或SID=instest來進行用戶端的連接配接