Oracle監聽配置(四)--如何實現靜態、動態註冊

第三節咱們已經大概瞭解什麼是靜態 註冊和動態 註冊,下面咱們將經過兩個例子來更加深刻了解它們之間的區別。
靜態 註冊:當listener使用的是非標準端口(1522),在listener.ora的文件裏手工註冊(添加instance name 和 service name)
動態 註冊:listener 採用的是默認端口(1521),當實例啓動時,由pmon 自動將instance name 和service name 註冊到listener
 
一、靜態註冊
(1)經過netca 創建非標準端口的listener :lis2(1522)
(2)修改listener.ora
  ——查看listener.ora
[oracle@work ~]$ cd /u01/app/oracle/product/10.2.0/db_1/network/admin/
[oracle@solaris10 admin]$cat listener.ora
LISTENER2 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = solaris10)(PORT = 1522))
    )
  )
 
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
  )
 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = solaris10)(PORT = 1521))
    )
  )
 
——添加靜態 註冊信息
[oracle@solaris10 admin]$vi listener.ora
 
***************************這裏面的是靜態 註冊信息*****************************
SID_LIST_LISTENER2 =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = anny)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME = anny)
    )
  )
***************************這裏面的是靜態 註冊信息************************************
 
LISTENER2 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = solaris10)(PORT = 1522))
    )
  )
 
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = work)(PORT = 1521))
    )
  )
 
——啓動lsn2
[oracle@solaris10 admin]$lsnrctl start listener2
 
LSNRCTL for Solaris: Version 10.2.0.2.0 - Production on 16-MAR-2012 17:58:12
 
Copyright (c) 1991, 2005, Oracle.  All rights reserved.
 
Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
 
TNSLSNR for Solaris: Version 10.2.0.2.0 - Production
System parameter file is /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener2.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=solaris10)(PORT=1522)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=solaris10)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     listener2
Version                   TNSLSNR for Solaris: Version 10.2.0.2.0 - Production
Start Date                16-MAR-2012 17:58:12
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener2.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=solaris10)(PORT=1522)))
Services Summary...
Service "anny" has 1 instance(s).
  Instance "anny", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
 
[oracle@solaris10 admin]$netstat -an|grep 1522
192.168.12.17.34007  192.168.12.31.1522   49640      0 49640      0 ESTABLISHED
192.168.12.17.1522   192.168.12.31.34220  49640      0 49640      0 ESTABLISHED
      *.1522               *.*                0      0 49152      0 LISTEN
 
 
——查看lsn2 status
 
[oracle@solaris10 admin]$lsnrctl status listener2
 
LSNRCTL for Solaris: Version 10.2.0.2.0 - Production on 16-MAR-2012 18:02:24
 
Copyright (c) 1991, 2005, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=solaris10)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     listener2
Version                   TNSLSNR for Solaris: Version 10.2.0.2.0 - Production
Start Date                16-MAR-2012 17:58:12
Uptime                    0 days 0 hr. 4 min. 12 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener2.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=solaris10)(PORT=1522)))
Services Summary...
Service "anny" has 1 instance(s).
  Instance "anny", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully                        
                  ——status unknown 表示instance 是以靜態 註冊方式註冊
二、動態註冊
實現動態 註冊有兩步:在服務端修改tnsnames.ora-->修改參數local_listener
若是前面有進行靜態 註冊,要去listener.ora把靜態 註冊信息刪掉
 
——server 配置tnsnames.ora
 
LISTENER2 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.17)(PORT = 1522))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = anny)
    )
  )
 
——修改參數local_listener
SQL> show parameter local_listener
 
NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
local_listener                       string
SQL> alter system set local_listener=listener2;
 
System altered.
 
——客戶端連接
 
bash-3.00$ sqlplus sys/oracle@anny1522 as sysdba
 
SQL*Plus: Release 10.2.0.2.0 - Production on Fri Mar 16 18:31:39 2012
 
Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
 
 
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
 
SQL> show user;
USER 爲 "ANNY"
SQL>
總結:
靜態 註冊可以啓動多個監聽,動態 註冊只能啓動一個監聽
啓動默認監聽時能夠註冊多個實例,非默認端口就只能啓動動態 註冊的實例

相關文章
相關標籤/搜索