首先我们要知道,在oracle中,什么文件里面有关于端口号的信息,路径如下:
X:\oracle_home\product\11.2.0\dbhome_2\NETWORK\ADMIN
到这个路径下我们可以发现有*.ora文件,那么其中listener.ora和tnsnames.ora这两个文件,就是我们这次需要改动的文件
先来看listener.ora
原内容
# listener.ora Network Configuration File: D:\oracle11g\product\11.2.0\dbhome_2\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\oracle11g\product\11.2.0\dbhome_2)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\oracle11g\product\11.2.0\dbhome_2\bin\oraclr11.dll")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
ADR_BASE_LISTENER = D:\oracle11g
以上是原文内容,我们的修改如下,红色加粗为修改部分
# listener.ora Network Configuration File: D:\oracle11g\product\11.2.0\dbhome_2\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\oracle11g\product\11.2.0\dbhome_2)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\oracle11g\product\11.2.0\dbhome_2\bin\oraclr11.dll")
)
(SID_DESC =
(GLOBAL_DBNAME = cisco)
(ORACLE_HOME = D:\oracle11g\product\11.2.0\dbhome_2)
(SID_NAME = cisco)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1522))
)
)
ADR_BASE_LISTENER = D:\oracle11g
下面就是在LISTENR里面修改你想要的端口号PORT=xxx
下面再看tnsnames.ora
原文内容
# tnsnames.ora Network Configuration File: D:\oracle11g\product\11.2.0\dbhome_2\network\admin\tnsnames.ora # Generated by Oracle configuration tools. CISCO = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = cisco) ) ) ORACLR_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (CONNECT_DATA = (SID = CLRExtProc) (PRESENTATION = RO) ) ) LISTENER_CISCO = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))修改后的
# tnsnames.ora Network Configuration File: D:\oracle11g\product\11.2.0\dbhome_2\network\admin\tnsnames.ora # Generated by Oracle configuration tools. CISCO = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = cisco) ) ) ORACLR_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (CONNECT_DATA = (SID = CLRExtProc) (PRESENTATION = RO) ) ) LISTENER_CISCO = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))可以发现基本没什么变化,只是在CISCO里面的端口号发生了变化,PORT改成与listener.ora文件里面端口号相对应的即可。
好了,修改完后,从services.msc里重启oracle监听器即可。