修改Oracle监听端口

时间:2023-11-22 19:16:26

修改oracle监听端口

修改端口号的整体步骤:
1.1   查看当前监听的状态
1.2   停止监听
1.3   修改监听文件的端口号
1.4   修改初始化参数local_listener
1.5   重启监听器
1.6   修改完毕,使用新端口登录测试

实践步骤:

1.1 查看当前监听的状态

[test@ASI-1 ~]$lsnrctl status

1.2 停止监听

[test@ASI-1~]$lsnrctl stop

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 11-MAR-2011 16:36:49

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.100)(PORT=1521)))

The command completed successfully

1.3修改监听文件的端口号

把端口号修改为1530,分别修改listener.ora和tnsname.ora文件

[test@ASI-1 ~]$ cd/usr/opt/oracle/product/10.2.0/db_1/network/admin/

[test@ASI-1 admin]$ pwd

/usr/opt/oracle/product/10.2.0/db_1/network/admin

[test@ASI-1~]$vi  listener.ora

# listener.ora Network Configuration File: /usr/opt/oracle/product/10.2.0/db_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = PLSExtProc)

(ORACLE_HOME = /usr/opt/oracle/product/10.2.0/db_1)

(PROGRAM = extproc)

)

(SID_DESC =

(GLOBAL_DBNAME = orcl)

(ORACLE_HOME = /usr/opt/oracle/product/10.2.0/db_1)

(SID_NAME = orcl)

)

)

LISTENER =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.100)(PORT = 1530))

)

[test@ASI-1~]$vi tnsnames.ora

# Generated by Oracle configuration tools.

ORCL =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.100)(PORT = 1530))

)

(CONNECT_DATA =

(SERVICE_NAME = orcl)

)

)

EXTPROC_CONNECTION_DATA =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

(CONNECT_DATA =

(SID = PLSExtProc)

(PRESENTATION = RO)

)

)

1.4 修改初始化参数local_listener

[test@ASI-1~]$sqlplus / as sysdba

SQL*Plus:Release 10.2.0.1.0 - Production on 星期六 7月 19 13:24:02 2008

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

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> showparameter local_listener

NAME                                TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                      string      (address=(protocol=tcp)(host=s
kate)(port=1522))
SQL> alter system setlocal_listener="(address=(protocol=tcp)(host=192.168.0.100)(port=1530))";

系统已更改。

1.5 重启监听器

[test@ASI-1~]$lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 11-MAR-2011 17:56:42

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

Starting /usr/opt/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production

System parameter file is /usr/opt/oracle/product/10.2.0/db_1/network/admin/liste

ner.ora

Log messages written to /usr/opt/oracle/product/10.2.0/db_1/network/log/listener

.log

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.100)(PORT=1530

)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.100)(PORT=1530

)))

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production

Start Date                11-MAR-2011 17:56:42

Uptime                    0 days 0 hr. 0 min. 0 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /usr/opt/oracle/product/10.2.0/db_1/network/admin/list

ener.ora

Listener Log File         /usr/opt/oracle/product/10.2.0/db_1/network/log/listen

er.log

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.100)(PORT=1530)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

Service "orcl" has 1 instance(s).

Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

1.6使用新端口登录测试

1.6.1 检查监听端口是否改变

[test@ASI-1~]$netstat -na | grep "1530"

tcp       0     0 192.168.0.100:1530          0.0.0.0:*       LISTEN

1.6.2  查看监听器的状态

[test@ASI-1~]$lsnrctl status

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 11-MAR-2011 18:21:04

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.100)(PORT=1530)))

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production

Start Date                11-MAR-2011 17:56:42

Uptime                    0 days 0 hr. 24 min. 21 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /usr/opt/oracle/product/10.2.0/db_1/network/admin/listener.ora

Listener Log File         /usr/opt/oracle/product/10.2.0/db_1/network/log/listener.log

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.100)(PORT=1530)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

Service "orcl" has 1 instance(s).

Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

1.6.3 [test@ASI-1 ~]$tnsping orcl

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 11-MAR-2011 18:34:36

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

Used parameter files:

/usr/opt/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.100)(PORT = 1530))) (CONNECT_DATA = (SERVICE_NAME = orcl)))

OK (0 msec)