Oracle修改监听IP地址

oracle 11g断网安装时,没有检测net的功能,所以安装完后,netstat -an 发现自动监听的是127.0.0.1:1521,这样安装完成后,其他的主机根本无法连接,是什么原因呢?

排错后发现,是主机名的问题:

1 在cmd中,输入hostname 发现主机名

2 在文件夹:c:\windows\system32\drivers\etc  修改hosts文件:

源文件为:

# 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       主机名

在最后一行加入

本机IP    主机名

保存即可

使用lsnrctl stat查看监听状态
此时监听的还是 127.0.0.1:1521这个IP
修改监听文件 listener.ora 文件在 D:\app\Administrator\product\11.2.0\dbhome_1\network\admin 目录下,注释部分的主机名原为Localhost
# listener.ora Network Configuration File: D:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
 
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:D:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
    )
  )
 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = WIN-ASA0GB1AV61)(PORT = 1521))//WIN-ASA0GB1AV61原为localhost
) ) ADR_BASE_LISTENER = D:\app\Administrator
把其中的localhost换成自己的主机名
再修改主机名文件 tnsnames.ora
# tnsnames.ora Network Configuration File: D:\app\Administrator\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
 
LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = WIN-ASA0GB1AV61)(PORT = 1521))//WIN..原为localhost
 
 
ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )
 
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = WIN-ASA0GB1AV61)(PORT = 1521))//WIN..原为localhost
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
同样把localhost换成自己的主机名
再用lsnrctl.ora检测,发现监听IP地址变为:192.168.1.251:1521 0.0.0.0 (192.168.1.251为本主机IP)
成功!
本文转自博客园xingoo的博客,原文链接:Oracle修改监听IP地址,如需转载请自行联系原博主。
上一篇:ElasticStack常用工具:ElasticSearch、Kibana、Beats、Logstash


下一篇:阿里云 Linux 内核优化实战(sysctl.conf 和 ulimits )