Oracle修改监听IP地址

运维 数据库运维
在局域网中远程连接oracle时,一直提示拒绝连接,在确定防火墙关闭,oracle服务器监听端口开启的情况下,可能的错误就是oracle的监听IP地址不是预设的那样,而是本地的127.0.0.1。排错过程不再细说,这里只分享由于主机名不正确而导致oracle拒绝连接的解决办法。

在局域网中远程连接oracle时,一直提示拒绝连接,在确定防火墙关闭,oracle服务器监听端口开启的情况下,可能的错误就是oracle的监听IP地址不是预设的那样,而是本地的127.0.0.1。

排错过程不再细说,这里只分享由于主机名不正确而导致oracle拒绝连接的解决办法。

一、修改hosts文件

打开cmd,输入hostname,记下主机名 用记事本打开c:\windows\system32\drivers\etc\hosts 文件,添加主机名。

  1. <code class="hljs vala"># Copyright (c) 1993-2009 Microsoft Corp. 
  2.  
  3. # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. 
  4.  
  5. # This file contains the mappings of IP addresses to host names. Each 
  6. # entry should be kept on an individual line. The IP address should 
  7. # be placed in the first column followed by the corresponding host name
  8. # The IP address and the host name should be separated by at least one 
  9. space
  10. # Additionally, comments (such as these) may be inserted on individual 
  11. # lines or following the machine name denoted by a '#' symbol. 
  12.  
  13. For example: 
  14.  
  15. #      102.54.94.97     rhino.acme.com          # source server 
  16. #       38.25.63.10     x.acme.com              # x client host 
  17.   
  18. # localhost name resolution is handled within DNS itself. 
  19. #    127.0.0.1       localhost 
  20. #    ::1             localhost 
  21.     [主机IP]          [主机名]</code> 

二、修改oracle监听文件

1、打开listener.ora

文件在F:\app\young\product\11.2.0\dbhome_1\NETWORK\ADMIN 目录下,将里面的localhost换为自己的主机名。 

  1. <code class="hljs vala"><code class="hljs tex"># listener.ora Network Configuration File: F:\app\young\product\11.2.0\dbhome_1\network\admin\listener.ora 
  2. # Generated by Oracle configuration tools. 
  3.   
  4. SID_LIST_LISTENER = 
  5.   (SID_LIST = 
  6.     (SID_DESC = 
  7.       (SID_NAME = CLRExtProc) 
  8.       (ORACLE_HOME = F:\app\young\product\11.2.0\dbhome_1) 
  9.       (PROGRAM = extproc) 
  10.       (ENVS = "EXTPROC_DLLS=ONLY:F:\app\young\product\11.2.0\dbhome_1\bin\oraclr11.dll"
  11.     ) 
  12.   ) 
  13.   
  14. LISTENER = 
  15.   (DESCRIPTION_LIST = 
  16.     (DESCRIPTION = 
  17.       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) 
  18.       (ADDRESS = (PROTOCOL = TCP)(HOST = Young-PC)(PORT = 1521))//Young-PC原为localhost 
  19. ) ) ADR_BASE_LISTENER = F:\app\young</code></code> 

2、修改tnsnames.ora

目录同上,也将localhost更改为主机名。

  1. <code class="hljs vala"><code class="hljs tex"><code class="hljs tex"># tnsnames.ora Network Configuration File: F:\app\young\product\11.2.0\dbhome_1\network\admin\tnsnames.ora 
  2. # Generated by Oracle configuration tools. 
  3.   
  4. LISTENER_ORCL = 
  5.   (ADDRESS = (PROTOCOL = TCP)(HOST = Young-PC)(PORT = 1521))//Young-PC原为localhost 
  6.    
  7. ORACLR_CONNECTION_DATA = 
  8.   (DESCRIPTION = 
  9.     (ADDRESS_LIST = 
  10.       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) 
  11.     ) 
  12.     (CONNECT_DATA = 
  13.       (SID = CLRExtProc) 
  14.       (PRESENTATION = RO) 
  15.     ) 
  16.   ) 
  17. ORCL = 
  18.   (DESCRIPTION = 
  19.     (ADDRESS = (PROTOCOL = TCP)(HOST = Young-PC)(PORT = 1521))//Young-PC原为localhost 
  20.     (CONNECT_DATA = 
  21.       (SERVER = DEDICATED) 
  22.       (SERVICE_NAME = orcl) 
  23.     ) 
  24.   )</code></code></code> 

3、重启tnslsnr。

打开cmd,输入以下命令。

  1. <code class="hljs vala"><code class="hljs tex"><code class="hljs tex"><code class="hljs sql">lsnrctl stop 
  2. lsnrctl start 
  3. lsnrctl stat</code></code></code></code> 

  

再次远程连接,已经可以连上了,成功。 

责任编辑:庞桂玉 来源: Oracle疑点通
相关推荐

2010-01-04 13:29:37

2022-10-10 08:05:23

IP地址节点

2011-08-25 11:22:02

修改IP地址Vista系统

2009-06-24 15:03:00

2023-10-12 07:18:25

IP地址服务器

2009-08-15 10:40:00

2015-07-10 09:08:52

IP地址IP地址冲突

2011-03-21 16:21:49

Oracle监听口令监听器

2009-07-19 09:21:52

oracle端口号IP访问

2015-09-28 09:58:24

网络IP地址IP

2012-04-25 14:31:12

2022-01-24 07:01:55

oracle数据库oracle监听

2010-06-08 14:09:11

IP协议地址

2013-06-13 11:29:26

IP地址规划IP地址企业IP规划

2010-07-07 17:09:24

IP地址协议

2009-11-18 18:28:27

Oracle监听器

2013-09-27 11:31:18

IP地址MAC地址

2022-05-24 06:14:41

动态服务静态服务oracle

2019-09-22 20:52:30

TCPIP中继

2011-06-03 09:25:16

IP
点赞
收藏

51CTO技术栈公众号