[20160418]修改oracle監聽埠.txt

lfree發表於2016-04-18

[20160418]修改oracle監聽埠.txt

--上午開發提出要修改oracle的監聽埠,我以前測試遇到過一些問題:
--連結: http://blog.itpub.net/267265/viewspace-758983/
-- 但是在11.2.0.4下遇到以前不一樣的情況,時間太久了,測試在2013年做的,也許現在存在一些變化.

1.無靜態註冊監聽:
SYS@book> @ &r/ver1

PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

--以前的測試在11.2.0.3做的.

$ cd /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin

$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
#      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 1529))
#      (ADDRESS = (PROTOCOL = TCP)(HOST = gxqyydg4)(PORT = 1529))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle
DIAG_ADR_ENABLED_LISTENER=OFF

$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-APR-2016 15:36:21
Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.78)(PORT=1529)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                18-APR-2016 15:36:06
Uptime                    0 days 0 hr. 0 min. 15 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/11.2.0.4/dbhome_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.78)(PORT=1529)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

--很奇怪這個時候無論執行 alter system register ;,看到的結果都是像上面一樣.

$ sqlplus -L scott/book@192.168.100.78:1529/book
$ sqlplus -L scott/book@192.168.100.78:1521/book
--都是報ORA-12541: TNS:no listener錯誤.

SYS@book> alter system set local_listener='(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.78)(PORT=1529))' scope=memory ;
System altered.

SYS@book> alter system register ;
System altered.

$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-APR-2016 15:40:41

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.78)(PORT=1529)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                18-APR-2016 15:36:06
Uptime                    0 days 0 hr. 4 min. 35 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/11.2.0.4/dbhome_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.78)(PORT=1529)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "book" has 1 instance(s).
  Instance "book", status READY, has 2 handler(s) for this service...
Service "bookXDB" has 1 instance(s).
  Instance "book", status READY, has 1 handler(s) for this service...
The command completed successfully

--這個時候可以動態註冊.執行如下可以登入,看來以前11.2.0.3測試存在的問題實際上是一個bug.
$ sqlplus -L scott/book@192.168.100.78:1529/book


2.再看看看存在靜態監聽註冊的情況:

$ cat  listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

#SUBSCRIBE_FOR_NODE_DOWN_EVENT_LISTENER=OFF

SID_LIST_LISTENER =
   (SID_LIST =
    (SID_DESC =
      (SDU=32767)
      (GLOBAL_DBNAME = book)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/dbhome_1)
      (SID_NAME = book)
      )
    )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
#      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 1529))
#      (ADDRESS = (PROTOCOL = TCP)(HOST = gxqyydg4)(PORT = 1529))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle
DIAG_ADR_ENABLED_LISTENER=OFF

SYS@book> alter system set local_listener='' scope=memory ;
System altered.
--如果害怕影響,最好的方法就是重啟資料庫.

SYS@book> alter system register ;
System altered.

$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-APR-2016 15:46:57
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.78)(PORT=1529)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                18-APR-2016 15:45:27
Uptime                    0 days 0 hr. 1 min. 29 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/11.2.0.4/dbhome_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.78)(PORT=1529)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "book" has 1 instance(s).
  Instance "book", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

$ sqlplus -L scott/book@192.168.100.78:1529/book => 透過ok
$ sqlplus -L scott/book@192.168.100.78:1521/book => 報錯ORA-12541.

3.總結:
1.看來以前在11.2.0.3遇到的問題,應該是bug.
2.要使用非標準埠,可以使用靜態註冊。這樣可以不要修改引數local_listener.但是動態註冊1521埠無效,也就是無法再透過1521
  埠連線資料庫。
3.使用非標準埠,如果使用非靜態註冊,必須修改local_listener引數,讓動態註冊使用非標準的埠來實現,這樣就無法使用1521埠。
4.總之,修改監聽的預設埠,無法再使用1521埠連線資料庫.
5.看來以前遇到的是bug.要以動態的態度看待oracle,不能報老經驗,一句話最好的方法就是測試.

--另外我還發現一些問題,如果配置靜態監聽並且使用1521埠:
$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-APR-2016 16:24:32
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.78)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                18-APR-2016 16:22:55
Uptime                    0 days 0 hr. 1 min. 36 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/11.2.0.4/dbhome_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.78)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=gxqyydg4)(PORT=8888))(Presentation=HTTP)(Session=RAW))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=gxqyydg4)(PORT=7777))(Presentation=FTP)(Session=RAW))
Services Summary...
Service "book" has 1 instance(s).
  Instance "book", status READY, has 2 handler(s) for this service...
Service "bookXDB" has 1 instance(s).
  Instance "book", status READY, has 1 handler(s) for this service...
The command completed successfully

--我還開啟了http 8888,以及ftp的7777埠.而如果使用非標準埠,是看不到了http 8888,以及ftp的7777.

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

相關文章