oracle12c 端口查看,Oracle12c修改端口号

本文详细介绍了如何修改Oracle12c数据库的监听端口号,包括查看监听状态、停止监听、修改监听文件、启动监听器以及调整初始化参数local_listener。在修改端口号后,需更新local_listener以确保数据库实例能正确注册到新的监听器。通过实例展示了local_listener参数的重要性,如果不设置,可能导致数据库实例无法自动注册。
摘要由CSDN通过智能技术生成

Oracle12c数据库更改端口号

修改端口号的整体步骤

1.1、查看当前监听的状态

1.2、停止监听

1.3、修改监听文件的端口号

1.4、修改初始化参数local_listener

1.5、重启监听器

1.6、修改完毕,使用新端口登录测试

实践步骤:

1、查看当前监听的状态

[oracle@localhost ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 21-DEC-2016 17:34:54

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

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

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production

Start Date                20-DEC-2016 22:26:52

Uptime                    0 days 19 hr. 8 min. 1 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/12.1.0/db/network/admin/listener.ora

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

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))

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

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=localhost)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/qywsxxdb/xdb_wallet))(Presentation=HTTP)(Session=RAW))

Services Summary...

Service "qyws_jkda" has 1 instance(s).

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

Service "qyws_qyrk" has 1 instance(s).

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

Service "qyws_tjzb" has 1 instance(s).

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

Service "qyws_xnh" has 1 instance(s).

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

Service "qyws_yzxt" has 1 instance(s).

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

Service "qywsxxdb" has 1 instance(s).

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

Service "qywsxxdbXDB" has 1 instance(s).

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

Service "qywsxxdb_pdb1" has 1 instance(s).

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

The command completed successfully

2、停止监听

[oracle@localhost admin]$ lsnrctl stop

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 21-DEC-2016 17:56:15

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

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

The command completed successfully

3、修改监听文件的端口号

监听文件位置:$ORACLE_HOME/network/admin/通过系统自带vi工具将listener.ora和tnsname.ora文件中port参数的值由1521改成1522,存盘即可。或者通过netca实用程序配置更改监听端口。

4、启动监听程序

[oracle@localhost admin]$ lsnrctl start

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 21-DEC-2016 17:56:20

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

Starting /u01/app/oracle/12.1.0/db/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.1.0.2.0 - Production

System parameter file is /u01/app/oracle/12.1.0/db/network/admin/listener.ora

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

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1522)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1522)))

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production

Start Date                21-DEC-2016 17:56:20

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/12.1.0/db/network/admin/listener.ora

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

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1522)))

The listener supports no services

The command completed successfully

5、修改初始化参数local_listener参数

此处将4和5步骤调换,就是为了通过测试,说明为什么要修改local_listener参数,首先,在不修改该参数的情况,我们注册数据库到监听程序。

[oracle@localhost admin]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Dec 21 17:56:25 2016

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

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show parameter local_li

NAME      TYPE  VALUE

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

local_listener      string

SQL> alter system register;

System altered.

SQL> exit

Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

[oracle@localhost admin]$ lsnrctl status

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 21-DEC-2016 17:56:36

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1522)))

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production

Start Date                21-DEC-2016 17:56:20

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/12.1.0/db/network/admin/listener.ora

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

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1522)))

The listener supports no services

The command completed successfully

通过手动注册数据库,可以看到数据库并未注册到监听程序,此时的local_listener为默认值,默认情况下会注册默认监听程序。接下来我们修改local_listener参数的值,看看修改后的效果。

SQL> alter system set local_listener="(address = (protocol = tcp)(host = 192.168.227.11)(port = 1522))" scope=both;

System altered.

SQL>

SQL>

SQL> show parameter local_li

NAME      TYPE  VALUE

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

local_listener      string  (address = (protocol = tcp)(ho

st = 192.168.227.11)(port = 15

22))

SQL> exit

Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

[oracle@localhost ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 21-DEC-2016 18:02:09

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1522)))

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production

Start Date                21-DEC-2016 17:56:20

Uptime                    0 days 0 hr. 5 min. 49 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/12.1.0/db/network/admin/listener.ora

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

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1522)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=localhost.localdomain)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/qywsxxdb/xdb_wallet))(Presentation=HTTP)(Session=RAW))

Services Summary...

Service "qyws_jkda" has 1 instance(s).

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

Service "qyws_qyrk" has 1 instance(s).

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

Service "qyws_tjzb" has 1 instance(s).

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

Service "qyws_xnh" has 1 instance(s).

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

Service "qyws_yzxt" has 1 instance(s).

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

Service "qywsxxdb" has 1 instance(s).

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

Service "qywsxxdbXDB" has 1 instance(s).

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

Service "qywsxxdb_pdb1" has 1 instance(s).

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

The command completed successfully

可以看到监听程序很快就会自动注册可以识别到的数据库实例。

那么为什么在这里要修改local_listener参数的值呢,默认情况下该参数为空值,依然可以动态将数据库实例自动注册监听呢?首先,我们得知道是pmon进程在实时动态注册数据库的,一般在默认情况下,pmon只会动态注册port等于1521的监听,否则pmon不能动态注册listener,如果想让pmon动态注册listener,那么就需要设置local_listener参数。这也是为什么必须在修改端口时,必须要修改local_listener参数的原因。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31403259/viewspace-2131183/,如需转载,请注明出处,否则将追究法律责任。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值