Linux hostname对Oracle实例以及监听的影响

    在Linux平台中,对hostname的修改,是否对ORACLE数据库实例或监听进程有影响呢?如果有影响,又要如何解决问题呢?另外/etc/hosts下相关内容的修改,是否也会影响实例或监听呢?这里涉及的场景非常多,当然关系也非常复杂,我们下面通过几个例子来测试验证一下。

    如下所示,服务器/etc/hosts 与/etc/sysconfig/network的原始配置信息如下

[root@test ~]# more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
#::1            localhost6.localdomain6 localhost6
127.0.0.1       localhost.localdomain localhost
192.168.27.134  test test 
[root@test ~]# 
 
 
[root@test ~]# more /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=test
GATEWAY=192.168.27.1
[root@test ~]# 

 

 

1: 首先假设有个需求,需要修改hostname,使之变成test.edution.com(加上域名部分), 那么此时是否有问题呢?我们先修改/etc/sysconfig/network下的HOSTNAME,然后重启服务器

[root@test ~]# more  /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=test.eduction.com
GATEWAY=192.168.27.1
 
[root@test ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
#::1            localhost6.localdomain6 localhost6
127.0.0.1       localhost.localdomain localhost
192.168.27.134  test test

 

然后我们重启数据库实例后,并没有任何问题,但是重启监听的时候遇到下面错误:

[oracle@test ~]$ sqlplus / as sysdba
 
SQL*Plus: Release 10.2.0.5.0 - Production on Sat Jun 18 16:42:21 2016
 
Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.
 
Connected to an idle instance.
 
SQL> startup
ORACLE instance started.
 
Total System Global Area 1509949440 bytes
Fixed Size                  2096472 bytes
Variable Size            1392509608 bytes
Database Buffers           67108864 bytes
Redo Buffers               48234496 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected from Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
[oracle@test ~]$ lsnrctl start
 
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 18-JUN-2016 16:42:47
 
Copyright (c) 1991, 2010, Oracle.  All rights reserved.
 
Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
 
TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test.eduction.com)(PORT=1521)))
 
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12535: TNS:operation timed out
 TNS-12560: TNS:protocol adapter error
  TNS-00505: Operation timed out
   Linux Error: 110: Connection timed out
[oracle@test ~]$ 

 

出现这个问题时,必须修改/etc/hosts下主机名的部分,使之与/etc/sysconfig/network下的HOSTNAME一致,上面错误就能解决。如下红色部分所示:

[root@test ~]# more /etc/sysconfig/network

NETWORKING=yes

NETWORKING_IPV6=no

HOSTNAME=test.eduction.com

GATEWAY=192.168.27.1

[root@test ~]# more /etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

#::1 localhost6.localdomain6 localhost6

127.0.0.1 localhost.localdomain localhost

192.168.27.134 test.eduction.com test

[root@test ~]#

 

由于这里测试,我修改了域名,如果服务器真实域名部分跟/etc/resolv.conf一致,那么数据库实例启动过程中,监控告警日志,就会发现告警日志里面会出现大量ORA-07445 & ORA-00108错误

 

2:修改/etc/sysconfig/network下的hostname并使之生效,如下所示

[oracle@kerry ~]$ more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
#::1            localhost6.localdomain6 localhost6
127.0.0.1       localhost.localdomain localhost
192.168.27.134  test.eduction.com  test 
[oracle@kerry ~]$ more /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=kerry.eduction.com
GATEWAY=192.168.27.1

 

数据库实例启动并没有任何问题,但是监听启动出现上面一样的错误。 如果域名使用真实的域名,则会遇到另外一种情况,告警日志里面也会出现下面错误

Errors in file /u01/app/oracle/admin/SCM2/bdump/scm2_ora_4494.trc:

ORA-07445: exception encountered: core dump [kslgetl()+120] [SIGSEGV] [Address not mapped to object] [0x000000210] [] []

ORA-00108: failed to set up dispatcher to accept connection asynchronously

关于这个,可以参考官方文档ORA-07445: [kslgetl()+80] Followed by ORA-108: failed to set up dispatcher to accept connection asynchronously (文档 ID 1298804.1)

 

3: 如果屏蔽/etc/hosts下的localhost部分,如下所示,此时有可能会影响监听

 

[root@kerry ~]# more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
#::1            localhost6.localdomain6 localhost6
#127.0.0.1       localhost.localdomain localhost
192.168.27.134  kerry.eduction.com  kerry 
[root@kerry ~]# 
 
 
[oracle@kerry ~]$ lsnrctl start
 
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 18-JUN-2016 17:45:37
 
Copyright (c) 1991, 2010, Oracle.  All rights reserved.
 
Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
 
TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=kerry.eduction.com)(PORT=1521)))
 
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12547: TNS:lost contact
 TNS-12560: TNS:protocol adapter error
  TNS-00517: Lost contact
   Linux Error: 104: Connection reset by peer

这是因为我没有在$ORACLE_HOME/network/admin下配置listener.ora,所以在注释或删除了/etc/hosts下localhost部分后就会出现这个错误,因为在没有listener.ora下的情况下,都会使用默认值(如下官方文档描述),监听进程会使用本机配置127.0.0.1注册监听服务,所以会出现上面错误信息,官方文档关于这方面的描述如下所示:

 

Oracle Net Listener Configuration Overview

Note:

Oracle Database 10g and later databases require a version 10 or later listener. Earlier versions of the listener are not supported for use with Oracle Database 10g and later databases. However, you can use a version 10 listener with previous versions of Oracle Database.

A listener is configured with one or more listening protocol addresses, information about supported services, and parameters that control its runtime behavior. The listener configuration is stored in a configuration file named listener.ora.

Because all of the configuration parameters have default values, it is possible to start and use a listener with no configuration. This default listener has a name of LISTENER, supports no services on startup, and listens on the following TCP/IP protocol address:

(ADDRESS=(PROTOCOL=tcp)(HOST=host_name)(PORT=1521))

Supported services, that is, the services to which the listener forwards client requests, can be configured in the listener.ora file or this information can be dynamically registered with the listener. This dynamic registration feature is called service registration. The registration is performed by the PMON process—an instance background process—of each database instance that has the necessary configuration in the database initialization parameter file. Dynamic service registration does not require any configuration in the listener.ora file.

 

解决方案两种:

1:在$ORACLE_HOME/network/admin/下配置listener.ora文件。则屏蔽或删除/etc/hosts下127.0.0.1后,监听不会有任何问题。

2:在配置文件/etc/hosts下增加localhost(红色部分所示)也能解决这个问题。

[root@kerry ~]# more /etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

#::1 localhost6.localdomain6 localhost6

#127.0.0.1 localhost.localdomain localhost

192.168.27.134 kerry.eduction.com kerry localhost

[root@kerry ~]#

具体可以参考官方文档Starting TNS Listener or LSNRCTL Start Yields TNS-12541, Linux Error: 111: Connection Refused (文档 ID 343295.1)

 

  另外,我们这里也忽略了lisnter.ora里面的配置,如果该配置文件使用的是hostname而不是IP,那么也会遇到一些问题。

时间: 2024-11-29 21:35:02

Linux hostname对Oracle实例以及监听的影响的相关文章

【不积跬步,无以致千里】Linux下启动Oracle服务和监听程序

  oracle数据库是重量级的,其管理非常复杂,将其在linux平台上的启动和关闭步骤整理一下.   安装完毕oracle以后,需要创建oracle系统用户,并在/home/oracle下面的.bash_profile添加几个环境变量:ORACLE_SID,ORACLE_BASE,ORACLE_HOME.比如:   export ORACLE_SID=test  export ORACLE_BASE=oracle_install_dir export ORACLE_HOME=xxx   启动步

连接oracle数据库出现oracle ORA-12526: TNS: 监听程序: 所有适用例程都处于受限模式

服务器被重启之后连接出错,登陆服务器 sqlplus可以连接,但是jdbc以及sqldeveloper连接报错 ORA-12526 .   网上搜索到:   今天使用PL/SQL远程连接oracle数据库出现oracle ORA-12526: TNS: 监听程序: 所有适用例程都处于受限模式. 查了下原来之前改字符集时执行了:ALTER SYSTEM ENABLE RESTRICTED SESSION: 导致受限 解决办法:使用系统管理员身份运行以下一段代码 ALTER SYSTEM DISAB

ORACLE RAC的监听配置简介

Oracle RAC 监听器的配置与单实例稍有不同,但原理和实现方法基本上是相同的.在Oracle中 tns进程用于为指定网络地址上的一个或多个Oracle 实例提供服务注册,并响应来自客户端对该服务提出的连接请求.一旦连接请求到达,并派生出一个服务器进程建立服务器与用户端之间的连接(专有服务器dedicated server)或转发服务请求(共享服务器模式shared server).如果监听器知道多于一个实例提供所请求的服务,则可能会根据客户端与服务器端相关配置将请求定位到较低负载的实例为其

Oracle中静态监听导致的ORA-12523错误

今天配置完共享服务器模式之后发现登录过程中报错ORA-12523,排查错误之后发现是静态监听惹的祸. 本机之上有两个监听,一个静态监听1521端口,一个动态监听1526端口. LISTENER= (DESCRIPTION=  (ADDRESS_LIST=    (ADDRESS=(PROTOCOL=tcp)(HOST=jp)(PORT=1521))    (ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))) LSNR2= (DESCRIPTION=  (ADDRESS_

Oracle中“无监听程序”和“协议适配器错误”的解决方法

一.发现问题 有些杀毒程序会清掉一些oracle注册表信息或删除oracle的bin目录下的一些.exe文件,导致数据库无法启动,下面来分析一下最常见的问题. 二.无监听程序 1.什么是监听器(LISTENER) 监听器是建立在服务端的,用于监听客户端向数据库服务器端提出的连接请求. 配置文件在\db_1\NETWORK\ADMIN\listener.ora. 2.本地服务名(Tnsname) 本地服务名是建立在客户端的,需要连哪些服务器数据库,就将该数据库服务端的信息配置. 配置文件在\db_

【oracle】动态监听与静态监听

本机客户端以sysdba身份登陆oracle数据库后 用shutdown immediate成功的关闭了数据库. 可是startup的时候,却提示 ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务 查看listener.ora配置文件后,发现配置的动态监听. 动态监听会时时反应数据库的状态 依赖pmon进程的动态注册,而不像静态监听需要加载listener.ora文件的sid_list_listener部分.之所以无法再启动数据库,是由于数据库关闭后,监听器已经注销了此

Linux用netstat查看服务及监听端口

[root@localhost ~]# netstat -nlp netstat命令各个参数说明如下: -t : 指明显示TCP端口 -u : 指明显示UDP端口 -l : 仅显示监听套接字(所谓套接字就是使应用程序能够读写与收发通讯协议(protocol)与资料的程序) -p : 显示进程标识符和程序名称,每一个套接字/端口都属于一个程序. -n : 不进行DNS轮询(可以加速操作) 即可显示当前服务器上所有端口及进程服务,于grep结合可查看某个具体端口及服务情况 [root@localho

Oracle 11g RAC 环境下单实例非缺省监听及端口配置

      如果在Oracle 11g RAC环境下使用dbca创建单实例数据库后,Oracle会自动将其注册到缺省的1521端口及监听器.大多数情况下我们使用的为非缺省监听器以及非缺省的监听端口.而且在Oracle 11g RAC环境中,对于集群监听器的配置由grid用户来接管了.基于这种情形的单实例非缺省监听及端口该如何配置呢?本文给出了解决方案,并且使用了静态及动态两种注册方法.              关于单实例下非缺省监听及端口的配置可以参考下面的文章.实际上参照下列文章依旧可以完成

oracle中一次监听不能启动实例

登录测试环境发现一个节点监听异常 root@xxxxdbb:/ #crsctl status res -t -------------------------------------------------------------------------------- NAME           TARGET  STATE        SERVER                   STATE_DETAILS ----------------------------------------