1. 程式人生 > 其它 >Oracle RAC修改監聽埠號

Oracle RAC修改監聽埠號

目錄

修改OracleRAC監聽埠號:

修改前一定要檢視修改後的埠有沒有被佔用:

# netstat -an|grep <new-listener-port>

1、檢視當前資料庫監聽狀態:

(grid使用者執行)

$ lsnrctl status

$ srvctl config listener

示例:

[+ASM1][grid@ceshi1 ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 05-APR-2022 06:34:12

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

Connecting to (ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                05-APR-2022 06:18:47
Uptime                    0 days 0 hr. 15 min. 25 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/11.2.0.4/grid/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/ceshi1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.48.130)(PORT=1522)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.48.132)(PORT=1522)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
  Instance "orcl1", status BLOCKED, has 1 handler(s) for this service...
Service "test" has 1 instance(s).
  Instance "orcl1", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully

[+ASM1][grid@ceshi1 ~]$ srvctl config listener
Name: LISTENER
Network: 1, Owner: grid
Home: <CRS home>
End points: TCP:1522

2、修改叢集監聽埠:

  1. 修改監聽埠:(grid使用者單節點執行)

    $ srvctl modify listener -l LISTENER -p "TCP:<new-listener-port>"
    
  2. 修改scan埠:(grid使用者單節點執行)

    $ srvctl modify scan_listener -p <new-scan-port>
    

示例:

[+ASM1][grid@ceshi1 ~]$ srvctl modify listener -l LISTENER -p "TCP:1533"

[+ASM1][grid@ceshi1 ~]$ srvctl modify scan_listener -p 1533

3、手動修改LOCAL_LISTENER:

(oracle使用者所有節點執行)

SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<Host-name>)(PORT=<new-port-number>))))' scope=both sid='[<your-chosen-instance> | * ] '

注意:按照例項所在節點修改"IP""例項名"

示例:

節點一:

#修改LOCAL_LISTENER
[orcl1][oracle@ceshi1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Apr 5 07:26:34 2022

Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> alter system set local_listener ="(ADDRESS=(PROTOCOL=TCP)(HOST= 192.168.48.130)(PORT=1533))" SID='orcl1';

System altered.

#檢視LOCAL_LISTENER
SQL> show parameter LOCAL_LISTENER

NAME				     TYPE	 VALUE
------------------------ ------- ------------------------------
local_listener			 string	 (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.48.130)(PORT=1533))

節點二:

#修改LOCAL_LISTENER
[orcl2][oracle@ceshi2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Apr 6 02:50:46 2022

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> alter system set local_listener ="(ADDRESS=(PROTOCOL=TCP)(HOST= 192.168.48.131)(PORT=1533))" SID='orcl2';

System altered.

#檢視LOCAL_LISTENER
SQL> show parameter LOCAL_LISTENER

NAME				     TYPE	 VALUE
------------------------ ------- ------------------------------
local_listener			 string	 (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.48.131)(PORT=1533))

若移除監聽(REMOTE_LISTENER)也需要進行類似更改

4、停止叢集監聽和SCAN:

停止監聽和scan:(grid使用者單節點執行)

$ srvctl stop listener [-l <lsnr_name>] [-n <node_name>] [-f]
$ srvctl stop scan [-i <ordinal_number>] [-f]
$ srvctl stop scan_listener [-i <ordinal_number>] [-f]

示例:

$ srvctl stop listener -l LISTENER
$ srvctl stop scan_listener

5、修改listener.ora檔案:

修改listener.ora檔案中的埠資訊:(grid使用者所有節點執行)

$ vi $GRID_HOME/network/admin/listener.ora
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))))            # line added by Agent
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1))))                # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON                # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent

LISTENER =
    (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.48.130)(PORT = 1522))
    )

將預設偵聽器配置檔案下的(埠=1521)更改為所需的值。如果您沒有此檔案,則可以使用以下示例:

LISTENER =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
(ADDRESS = (PROTOCOL = TCP)(HOST = myhostname)(PORT = myport))
)

若配置了$GRID_HOME/network/admin/tnsnames.ora檔案也需要進行埠調整

6、啟動叢集監聽和SCAN:

啟動監聽和scan:(grid使用者所有節點執行)

$ srvctl start listener [-l <lsnr_name>] [-n <node_name>]
$ srvctl start scan [-i <ordinal_number>] [-n <node_name>]
$ srvctl start scan_listener [-n <node_name>] [-i <ordinal_number>]

示例:

#啟動叢集監聽和SCAN
$ srvctl start listener -l LISTENER
$ srvctl start scan_listener

7、驗證資料庫監聽埠狀態:

(grid使用者執行)

$ lsnrctl status

$ srvctl config listener

示例:

節點一:

[+ASM1][grid@ceshi1 /u01/app/11.2.0.4/grid/network/admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-APR-2022 06:24:25

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

Connecting to (ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                06-APR-2022 06:24:16
Uptime                    0 days 0 hr. 0 min. 8 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/11.2.0.4/grid/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/ceshi1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.48.130)(PORT=1533)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.48.132)(PORT=1533)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl1", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl1", status READY, has 1 handler(s) for this service...
Service "test" has 1 instance(s).
  Instance "orcl1", status READY, has 1 handler(s) for this service...
The command completed successfully

[+ASM1][grid@ceshi1 /u01/app/11.2.0.4/grid/network/admin]$ srvctl config listener -a
Name: LISTENER
Network: 1, Owner: grid
Home: <CRS home>
  /u01/app/11.2.0.4/grid on node(s) ceshi2,ceshi1
End points: TCP:1533

節點二:

[+ASM2][grid@ceshi2 /u01/app/11.2.0.4/grid/network/admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 07-APR-2022 02:01:14

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

Connecting to (ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                07-APR-2022 01:48:13
Uptime                    0 days 0 hr. 13 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/11.2.0.4/grid/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/ceshi2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.48.131)(PORT=1533)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.48.133)(PORT=1533)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl2", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl2", status READY, has 1 handler(s) for this service...
Service "test" has 1 instance(s).
  Instance "orcl2", status READY, has 1 handler(s) for this service...
The command completed successfully

[+ASM2][grid@ceshi2 /u01/app/11.2.0.4/grid/network/admin]$ srvctl config listener -a
Name: LISTENER
Network: 1, Owner: grid
Home: <CRS home>
  /u01/app/11.2.0.4/grid on node(s) ceshi2,ceshi1
End points: TCP:1533

For RAC and/or SCAN please see:Changing Listener Ports On RAC/EXADATA (Doc ID 1473035.1)