阿里云优惠
 汇集各种优惠信息 技术资料

首页    数据库    教你怎么修改oracle默认监听端口?

教你怎么修改oracle默认监听端口?

创建时间:2019-04-26 15:06
浏览量:0
收藏

主要是修改两个文件和修改oracle参数local_listener

1 查看当前监听状态
[oracle@test ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 05-JUL-2018 14:26:26
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.162.4.68)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                11-JUN-2018 17:39:44
Uptime                    23 days 20 hr. 46 min. 42 sec
Trace Level               off
Security                  ON: Password or Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /data/app/oracle/diag/tnslsnr/DSJ-RTB-4T-349/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.162.4.68)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "dwca" has 1 instance(s).
  Instance "dwca", status READY, has 1 handler(s) for this service...
Service "dwcaXDB" has 1 instance(s).
  Instance "dwca", status READY, has 1 handler(s) for this service...
The command completed successfully
2 关闭监听
[oracle@test ~]$ lsnrctl stop
 
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 05-JUL-2018 14:29:30
 
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.162.4.68)(PORT=1521)))
The command completed successfully

附:申请阿里云服务器等产品时,可以先领取1888元阿里云代金券

3 修改监听端口号

端口修改为2345,主要修改$ORACLE_HOME/network/admin/目录下的两个文件,listener.ora和tnsnames.ora
修改PORT
 (ADDRESS = (PROTOCOL = TCP)(HOST = 10.162.4.68)(PORT = 2345))

[oracle@test admin]$ cd $ORACLE_HOME/network/admin/
[oracle@test admin]$ vim listener.ora
[oracle@test admin]$ cat listener.ora
# listener.ora Network Configuration File: /data/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
 
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /data/app/oracle/product/11.2.0/dbhome_1)
      (PROGRAM = extproc)
    )
  )
 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.162.4.68)(PORT = 2345))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )
 
#----ADDED BY TNSLSNR 11-APR-2018 16:08:51---
PASSWORDS_LISTENER = 313DBE5E70EB94B5
#--------------------------------------------
[oracle@test admin]$ vi tnsnames.ora
[oracle@test admin]$ cat tnsnames.ora
DWCA =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.162.4.68)(PORT = 2345))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dwca)
    )
  )
 
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )
LISTENER_DWCA =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
4 修改初始化参数local_listener
[oracle@test admin]$ sqlplus / as sysdba;
 
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 5 14:38:41 2018
 
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
SQL> show parameter local_listener;
 
NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
local_listener                 string     LISTENER_DWCA
 
SQL>   alter system set local_listener="(address=(protocol=tcp)(host=10.162.4.68)(port=2345))";
 
System altered.
5 重新开启监听
[oracle@test admin]$ lsnrctl start
 
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 05-JUL-2018 14:41:06
 
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
 
Starting /data/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
 
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /data/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /data/app/oracle/diag/tnslsnr/DSJ-RTB-4T-349/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.162.4.68)(PORT=2345)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.162.4.68)(PORT=2345)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                05-JUL-2018 14:41:06
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Password or Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /data/app/oracle/diag/tnslsnr/DSJ-RTB-4T-349/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.162.4.68)(PORT=2345)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
6,更换主机并做连接测试
[oracle@test02 ~]$ sqlplus scott/scott@10.162.4.68:2345/dwca
 
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 5 14:53:25 2018
 
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
SQL>

免费领取阿里云1888元代金券大礼包

 

阿里云新老用户均可领取!
自领取后:限时7天使用!

阿里云服务器2折优惠:低至293元/年

 

 

突发性能实例t5 1核1G:293元/年

突发性能实例t5 1核2G:459元/年

突发性能实例t5 2核4G:798元/年

共享型xn4实例1核1G内存:394元/年

共享型n4实例1核2G内存:653元/年

计算网络增强型实例2核4G内存:1566元/年

计算网络增强型实例4核8G内存:2991元/年

点此查看2折活动详情

阿里云高性能云服务器

 

 

网络增强型云服务器:2核4G ¥720元/年

高频应用云服务器:8核16G ¥4109元/年

本地SSD型云服务器:4核16G ¥6218.40元/年

大数据型云服务器:8核32G ¥11375.00元/年

GPU异构云服务器:16核40G ¥15563.00元/年

新用户满立减:每满1000立减50

 

1、到阿里云官网选购产品
2、加入到购物车
3、结算时立享满减

注意:新用户首次购买时必须先加到购物车,然后一起结算才享受此优惠。

腾讯云CVM云服务器22.07元起

 

 

腾讯云1核1G:22.07元/月、794.73元/3年

腾讯云2核2G:36.48元/月、1313.35元/3年

腾讯云2核4G:43.01元/月、1548.5元/3年

腾讯云4核8G:178.5元/月、6426元/3年