服務端配置一個多埠號(如1521/1526)監聽器

skyin_1603發表於2016-12-13

服務端的監聽器有多種配置方法:1、預設的情況下是一個監聽器一個埠,這個時候,
不需要在tnsnames.ora檔案裡解析監聽器資訊;2、多個監聽器多個埠(埠號可以相同),
這時候,需要在tnsnames.ora檔案裡解析監聽器資訊;3、一個監聽器多個埠號的監聽器,
這時候同樣需要在tnsnames.ora檔案裡解析監聽器資訊。
以下是測試第3種情況的過程:

----配置多埠號的監聽器:
---配置服務端 listener.ora檔案:
[oracle@enmo admin]$ cat listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.
 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = enmo)(PORT = 1521))

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

    )

    (DESCRIPTION =

        (ADDRESS = (PROTOCOL = TCP)(HOST = enmo)(PORT = 1526))

        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1526))

    )

  )

 

 ---配置服務端  tnsnames.ora檔案:

[oracle@enmo admin]$ cat tnsnames.ora

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = enmo)(PORT = 1521))

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

    )

    (DESCRIPTION =

        (ADDRESS = (PROTOCOL = TCP)(HOST = enmo)(PORT = 1526))

        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1526))

    )

  )

[oracle@enmo admin]$

 #配置服務端 tnsnames.ora檔案是為了解析服務端LISTENER 監聽器有兩個埠號。

 

 ---在資料庫修改本地的監聽器:

sys@PROD>alter system set local_listener='LISTENER';

System altered.

 #修改成功。

 
---啟動伺服器端的監聽器:

LSNRCTL> start

Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 11.2.0.4.0 - Production

System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Log messages written to /u01/app/oracle/diag/tnslsnr/enmo/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=enmo.oracle.com)(PORT=1521)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=enmo.oracle.com)(PORT=1526)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1526)))

 

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date                03-DEC-2016 23:34:15

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/11.2.0/dbhome_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/enmo/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=enmo.oracle.com)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=enmo.oracle.com)(PORT=1526)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1526)))

The listener supports no services

The command completed successfully

LSNRCTL>

LSNRCTL>

 ---把資料庫主動註冊到監聽器:

sys@PROD>alter system register;

System altered.

sys@PROD>/

 #註冊完成。


---註冊資料庫後檢視監聽器的狀態: 

LSNRCTL> status

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date                03-DEC-2016 23:34:15

Uptime                    0 days 0 hr. 0 min. 28 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/enmo/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=enmo.oracle.com)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=enmo.oracle.com)(PORT=1526)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1526)))

Services Summary...

Service "PROD" has 1 instance(s).

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

Service "PRODXDB" has 1 instance(s).

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

The command completed successfully

LSNRCTL>

 

 ---Windows客戶端透過EZCONNECT使用1521埠連線服務端資料庫測試:

C:\Users\Asus>sqlplus sys/oracle@192.168.2.6:1521/PROD as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on 星期六 123 23:58:14 2016

 

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

 

 

連線到:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL>

SQL>

SQL> show parameter service

 

NAME                                 TYPE

------------------------------------ ----------------------

VALUE

------------------------------

service_names                        string

PROD

#連線成功,證明多埠的監聽器配置成功。
 

  ---Windows客戶端透過EZCONNECT使用1526埠連線服務端資料庫測試:

C:\Users\Asus>sqlplus sys/oracle@192.168.2.6:1526/PROD as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on 星期日 124 00:00:17 2016

 

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

 

 

連線到:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> show parameter service

 

NAME                                 TYPE

------------------------------------ ----------------------

VALUE

------------------------------

service_names                        string

PROD
#連線成功,證明多埠的監聽器配置成功。

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

相關文章