您好,登錄后才能下訂單哦!
昨天做了一個實驗,環境是這樣的,建立一個靜態監聽端口1526以及一個動態監聽端口1521,并且要通過在tnsname用兩種連接字符串進行連接,靜態連接的字符串直接連接沒有問題,可是后來動態連接的字符串怎么也連接不進去,嘗試注冊
SQL> alter system register; System altered. [oracle@demo2 ~]$ lsnrctl stat LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-OCT-2016 15:43:10 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=demo2)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 26-OCT-2016 15:41:57 Uptime 0 days 0 hr. 1 min. 13 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/demo2/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=demo2)(PORT=1521))) The listener supports no services The command completed successfully
監聽分為動態監聽以及靜態監聽兩種,靜態監聽直接指定數據庫或者實例名,所以不需要注冊,直接可以監聽。動態監聽需要注冊才可以進行監聽,因為靜態監聽沒有問題,所以我開始進行動態監聽的測試
首先我用netca配置了兩個動態監聽,一個端口是1526或是1521,一般情況下,
SQL> alter system register;
這樣子會進行動態監聽的注冊,可是結果發現只有1521的動態監聽監聽上去了,1526的不為所動
[oracle@demo2 ~]$ lsnrctl stat LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-OCT-2016 16:05:10 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=demo2)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 26-OCT-2016 16:04:33 Uptime 0 days 0 hr. 0 min. 37 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/demo2/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=demo2)(PORT=1521))) Services Summary... Service "PROD.us.oracle.cn" has 1 instance(s). Instance "PROD", status READY, has 1 handler(s) for this service... The command completed successfully
查詢資料,發現pmon進程只會定期將1521的端口注冊上去,不會注冊除1521以外的進程注冊上去,這個時候就需要另外一個參數local_listener,官方對loacl_listener的定義是
LOCAL_LISTENER specifies a network name that resolves to an address or address list of Oracle Net local listeners (that is, listeners that are running on the same machine as this instance). The address or address list is specified in the TNSNAMES.ORA file or other address repository as configured for your system.
這個時候看一下監聽的狀態
[oracle@demo2 admin]$ lsnrctl stat LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-OCT-2016 16:46:57 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=demo2)(PORT=1521))) TNS-12541: TNS:no listener TNS-12560: TNS:protocol adapter error TNS-00511: No listener Linux Error: 111: Connection refused
監聽是沒有起來的,這個時候我進入數據庫修改local_listener
SQL> show parameter local NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ local_listener string log_archive_local_first boolean TRUE parallel_force_local boolean FALSE SQL> alter system set local_listener='prod1526'; System altered. SQL> show parameter local NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ local_listener string prod1526 log_archive_local_first boolean TRUE parallel_force_local boolean FALSE
這個時候可以看見我的參數已經指定為tnsname的1526端口,這個時候監聽打開并動態注冊,然后觀測一下監聽的狀態
[oracle@demo2 ~]$ lsnrctl status prod1526 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-OCT-2016 16:56:05 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=demo2)(PORT=1526))(CONNECT_DATA=(service_name=PROD.us.oracle.cn))) STATUS of the LISTENER ------------------------ Alias LISTENER8 Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 26-OCT-2016 16:45:25 Uptime 0 days 0 hr. 10 min. 39 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/demo2/listener8/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=demo2)(PORT=1526))) Services Summary... Service "PROD.us.oracle.cn" has 1 instance(s). Instance "PROD", status READY, has 1 handler(s) for this service... The command completed successfully
注意查看監聽必須加上tnsname的名字或者監聽的名字,這個時候可以看見1526的這個監聽已經監聽到了,說明這個參數是可以指定動態連接的,也說明了除了1521這個端口是由pmon這個進程進行注冊,其他的動態注冊必須使用local_listener這個參數進行指定,這也就代表著一個實例只能由一個動態監聽進行監聽,除1521以外的端口必須指定locl_listener.
[oracle@demo2 admin]$ sqlplus scott/flllll@prod1526 SQL*Plus: Release 11.2.0.1.0 Production on Wed Oct 26 16:55:01 2016 Copyright (c) 1982, 2009, Oracle. All rights reserved. Error accessing PRODUCT_USER_PROFILE Warning: Product user profile information not loaded! You may need to run PUPBLD.SQL as SYSTEM Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。