Oracle 靜態監聽註冊詳解

Oracle 靜態監聽註冊詳解


       網上有很多關於oracle 監聽靜態註冊的文章,但大多都是簡單說說,並沒有詳細的例子,這裏,將結合Linux as4 下的oracle 10gR2.0.1 舉一個具體的例子
1、在 $ORACLE_HOME/network/admin/listener.ora 文件中加入一個靜態註冊的節點

  1. [oracle@prudent oracle]$ cd $ORACLE_HOME/network/admin  
  2. [oracle@prudent admin]$ vi listener.ora  
  3. # listener.ora Network Configuration File: /mydatafile2/app/oracle/oracle/product/11.2.0/db_1/network/admin/listener.ora  
  4. # Generated by Oracle configuration tools.  
  5. SID_LIST_LISTENER =  
  6.   (SID_LIST =  
  7.     (SID_DESC =  
  8.       (SID_NAME = PLSExtProc)  
  9.       (ORACLE_HOME = /mydatafile2/app/oracle/oracle/product/11.2.0/db_1)  
  10.       (PROGRAM = extproc)  
  11.     )  
  12.     (SID_DESC =  
  13.       (SID_NAME = ORCL)  
  14.       (ORACLE_HOME = /mydatafile2/app/oracle/oracle/product/11.2.0/db_1)  
  15.       (GLOBAL_DBNAME=WOO.COM)  
  16.     )  
  17.   )  
  18. LISTENER =  
  19.   (DESCRIPTION_LIST =  
  20.     (DESCRIPTION =  
  21.       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))  
  22.       (ADDRESS = (PROTOCOL = TCP)(HOST = prudent)(PORT = 1521))  
  23.     )  
  24.   )  
注意這裏的GLOBAL_DBNAME=WOO.COM
SID_NAME=ORCL 
這個SID_NAME 應與你對外提供服務的 $ORACLE_SID 一致

[plain] view plain copy
 print?
  1. [oracle@prudent admin]$ echo $ORACLE_SID  
  2.  ORCL  
 2、配置對應的tnsnames.ora 中的節點

  1. [oracle@prudent admin]$ vi tnsnames.ora  
  2. # tnsnames.ora Network Configuration File: /mydatafile2/app/oracle/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora  
  3. # Generated by Oracle configuration tools.  
  4. ORCL=  
  5.   (DESCRIPTION =  
  6.     (ADDRESS = (PROTOCOL = TCP)(HOST = prudent)(PORT = 1521))  
  7.     (CONNECT_DATA =  
  8.       (SERVER = DEDICATED)  
  9.       (SERVICE_NAME = ORCL)  
  10.     )  
  11.   )  
  12.   
  13. WOOORCL=  
  14.   (DESCRIPTION =  
  15.     (ADDRESS = (PROTOCOL = TCP)(HOST = prudent)(PORT = 1521))  
  16.     (CONNECT_DATA =  
  17.       (SERVER = DEDICATED)  
  18.       (SERVICE_NAME = WOO.COM)  
  19.     )  
  20.   )  

tnsname WOOORCL 中的 SERVICE_NAME=WOO.COM

這裏的服務名爲 WOO.COM 而不是通常的 ORCL,因爲在 listener.ora 中已經註冊了 WOO.COM,lsnrctl 啓動時會監聽 WOO.COM ,並對應到 SID_NAME=ORCL 上。

3、啓動監聽和服務

  1. [oracle@prudent oracle]$ cat dbstart  
  2. lsnrctl start  
  3. sqlplus /nolog <<EOF  
  4. connect /as sysdba  
  5. startup  
  6. EOF  
  7. [oracle@prudent oracle]$ ./dbstart  
  8. LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 13-FEB-2011 20:11:15  
  9. Copyright (c) 1991, 2005, Oracle.  All rights reserved.  
  10. Starting /mydatafile2/app/oracle/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...  
  11. TNSLSNR for Linux: Version 11.2.0.1.0 - Production  
  12. System parameter file is /mydatafile2/app/oracle/oracle/product/11.2.0/db_1/network/admin/listener.ora  
  13. Log messages written to /mydatafile2/app/oracle/oracle/product/11.2.0/db_1/network/log/listener.log  
  14. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))  
  15. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=prudent)(PORT=1521)))  
  16. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))  
  17. STATUS of the LISTENER  
  18. ------------------------  
  19. Alias                     LISTENER  
  20. Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production  
  21. Start Date                13-FEB-2011 20:11:15  
  22. Uptime                    0 days 0 hr. 0 min. 0 sec  
  23. Trace Level               off  
  24. Security                  ONLocal OS Authentication  
  25. SNMP                      OFF  
  26. Listener Parameter File   /mydatafile2/app/oracle/oracle/product/11.2.0/db_1/network/admin/listener.ora  
  27. Listener Log File         /mydatafile2/app/oracle/oracle/product/11.2.0/db_1/network/log/listener.log  
  28. Listening Endpoints Summary...  
  29.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))  
  30.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=prudent)(PORT=1521)))  
  31. Services Summary...  
  32. Service "WOO.COM" has 1 instance(s).  
  33.   Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...  
  34. Service "ORCL" has 1 instance(s).  
  35.   Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...  
  36. Service "PLSExtProc" has 1 instance(s).  
  37.   Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...  
  38. The command completed successfully  
  39. SQL*Plus: Release 11.2.0.1.0 - Production on Sun Feb 13 20:11:16 2011  
  40. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  41. SQL> Connected to an idle instance.  
  42. SQL> ORA-32004: obsolete and/or deprecated parameter(s) specified  
  43. ORACLE instance started.  
  44. Total System Global Area  461373440 bytes  
  45. Fixed Size                  1220000 bytes  
  46. Variable Size              75498080 bytes  
  47. Database Buffers          381681664 bytes  
  48. Redo Buffers                2973696 bytes  
  49. Database mounted.  
  50. Database opened.  
  51. SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 11.2.0.1.0 - Production  
  52. With the Partitioning, OLAP and Data Mining options  
可以看到  
Service "WOO.COM" has 1 instance(s).
  Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
正在被監聽。

4、驗證該服務可以到達

  1. [oracle@prudent oracle]$ tnsping WOOORCL  
  2. TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 13-FEB-2011 20:14:59  
  3. Copyright (c) 1997, 2005, Oracle.  All rights reserved.  
  4. Used parameter files:  
  5. /mydatafile2/app/oracle/oracle/product/11.2.0/db_1/network/admin/sqlnet.ora  
  6.   
  7. Used TNSNAMES adapter to resolve the alias  
  8. Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = prudent)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = WOO.COM)))  
  9. OK (10 msec)  
5、利用靜態註冊的服務登入oracle

  1. [oracle@prudent oracle]$ sqlplus system/oracle@WOOORCL  
  2. SQL*Plus: Release 11.2.0.1.0 - Production on Sun Feb 13 20:17:27 2011  
  3. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  4.   
  5. Connected to:  
  6. Oracle Database 10g Enterprise Edition Release 11.2.0.1.0 - Production  
  7. With the Partitioning, OLAP and Data Mining options  
  8. SQL> select count(*) from date_log;  
  9.   COUNT(*)  
  10. ----------  
  11. SQL>  

至此:已驗證該靜態註冊可以成功的被解析,監聽,連接

文章轉載:http://blog.csdn.net/wuweilong/article/details/39695359

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章