当前位置:首页 > 数据库 > Oracle

[oralce拾遗]oracle修改监听IP地址

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

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

===============================

修改hosts文件

  1. 打开cmd,输入hostname,记下主机名
  2. 用记事本打开c:windowssystem32driversetchosts 文件,添加主机名
            
                # Copyright (c) 1993-2009 Microsoft Corp.
                #
                # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
                #
                # This file contains the mappings of IP addresses to host names. Each
                # entry should be kept on an individual line. The IP address should
                # be placed in the first column followed by the corresponding host name.
                # The IP address and the host name should be separated by at least one
                # space.
                #
                # Additionally, comments (such as these) may be inserted on individual
                # lines or following the machine name denoted by a ‘#‘ symbol.
                #
                # For example:
                #
                #      102.54.94.97     rhino.acme.com          # source server
                #       38.25.63.10     x.acme.com              # x client host
                # localhost name resolution is handled within DNS itself.
                #    127.0.0.1       localhost
                #    ::1             localhost
    [主机IP]          [主机名]
        

==========================

修改oracle监听文件

1、打开listener.ora,文件在F:appyoungproduct11.2.0dbhome_1NETWORKADMIN 目录下,将里面的localhost换为自己的主机名。

            
                # listener.ora Network Configuration File: F:appyoungproduct11.2.0dbhome_1networkadminlistener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = F:appyoungproduct11.2.0dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:F:appyoungproduct11.2.0dbhome_1binoraclr11.dll")
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = Young-PC)(PORT = 1521))//Young-PC原为localhost
) ) ADR_BASE_LISTENER = F:appyoung
        

2、修改tnsnames.ora,目录同上,也将localhost更改为主机名。

            
                # tnsnames.ora Network Configuration File: F:appyoungproduct11.2.0dbhome_1networkadmintnsnames.ora
# Generated by Oracle configuration tools.

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = Young-PC)(PORT = 1521))//Young-PC原为localhost


ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Young-PC)(PORT = 1521))//Young-PC原为localhost
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
        

3、重启tnslsnr。

打开cmd,输入以下命令。

            lsnrctl stop
lsnrctl start
lsnrctl stat
        

技术分享

=============================

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

原文:http://blog.csdn.net/young_kim1/article/details/50402034


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!