在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,那么也会遇到一些问题。

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

  1. Linux下启动Oracle服务和监听程序步骤

    Linux下启动Oracle服务和监听程序启动和关闭步骤整理如下: 1.安装oracle: 2.创建oracle系统用户: 3./home/oracle下面的.bash_profile添加几个环境变量 ...

  2. Linux下安装oracle遇到启动监听服务器启动失败

    1.发现监听服务器没有启动,则  lsntctl start 启动监听服务器: 2.发现TNS-12555问题: 3.查找TNS-12555错误,找到一个满意的答案: chmod  777 /var/ ...

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

    oracle数据库是重量级的,其管理非常复杂,将其在linux平台上的启动和关闭步骤整理一下. 安装完毕oracle以后,需要创建oracle系统用户,并在/home/oracle下面的.bash_p ...

  4. Linux下启动Oracle服务和监听程序

    $ su – oracle $ sqlplus / nolog sql> conn / as sysdba sql> startup                 #启动Oracle,需 ...

  5. Linux中安装Oracle11g后出现监听的问题及解决办法

    软件安装: 参考文章: linux安装Oracle11G 错误如下: [oracle@iz2f570bi1k56uz admin]$ lsnrctl start LSNRCTL for Linux: ...

  6. linux下oracle数据库服务和监听的启动停止

    oracle数据库是重量级的,其管理非常复杂,将其在linux平台上的启动和关闭步骤整理一下. 安装完毕oracle以后,需要创建oracle系统用户,并在/home/oracle下面的.bash_p ...

  7. 配置Oracle数据库和监听随Linux系统自启动【转】

     配置Oracle数据库和监听随Linux系统自启动     在某些情况下需要在Linux操作系统上提供一种无人值守的随机启动Oracle的功能,目的也许仅仅是为了帮助那些对Oracle细节非常不关心 ...

  8. Linux下的启动oracle服务 启动监听 开放端口操作

    尝试登录oracle 使用root用户将没有sqlplus命令 [root@localhost ~]# sqlplus /nolog bash: sqlplus: 未找到命令...     [root ...

  9. 如何让oracle DB、监听和oem开机启动(dbstart)

    如何让oracle DB.监听和oem开机启动(dbstart) 让oracle DB.监听和oem开机启动(dbstart) Oracle提供了伴随操作系统自动重启的功能,在Windows中,可以修 ...

随机推荐

  1. java的各种类型转换汇总

    java类型转换 Integer String Long Float Double Date 1如何将字串 String 转换成整数 int? A. 有两个方法: 1). int i = Intege ...

  2. Mysql存储过程(四)——异常处理

    http://blog.csdn.net/crazylaa/article/details/5368421 有时候,不希望存储过程抛出错误中止执行,而是希望返回一个错误码. MySQL 支持异常处理, ...

  3. Mybatis if test中字符串比较

    <if test=" name=='你好' "> <if> 这样会有问题,换成 <if test=' name=="你好" '&g ...

  4. java入门必备单词

    ① anchor 锚 锚点 ② administrator 管理员 ③ application 应用程序 ④ align 对齐 ⑤ attribute 属性 ⑥ access 访问 ⑦ break 暂 ...

  5. 【FOL】万里长征第一步

    准备了好久了,中间断断续续看了些资料,也写了几个小demo练手,今天正式开始. 因为要模拟debug和release环境,手上资源又很缺,必须把一些已经拼好的图片进行切割,网络上找了半天倒是有几个切图 ...

  6. tomcat 5.5、6、7各版本的web-app标准

    刚把上周说的公司内各工程的web.xml给统一了,顺便看了下每个tomcat版本对应的标准servlet版本,如下: The XSD version is preferred since JSP 2. ...

  7. 完整的定时任务解决方案Spring集成+定时任务本身管理+DB持久化+集群

    完整的定时任务解决方案Spring集成+定时任务本身管理+DB持久化+集群 maven依赖 <dependency> <groupId>org.quartz-scheduler ...

  8. AngularJs学习第一课 Hello World

    首先先介绍一下:AngularJS是干什么的. AngularJS是为了克服HTML在构建应用上的不足而设计的.HTML是一门很好的为静态文本展示设计的声明式语言,但要构建WEB应用的话它就显得乏力了 ...

  9. 以【猫叫、老鼠跑、主人醒】为例子,使用 javascript 来实现 观察者模式 (有在线演示)

    “猫叫.老鼠跑.主人醒”是一个很古老的话题了,大家也都有各自的想法和解决方案.我也是看了很多,一开始的时候是相当的迷糊,这个怎么就是面试题了?考的是啥呀,和编程有关系吗?又是猫又是老鼠的,晕死了.后来 ...

  10. Code First :使用Entity. Framework编程(4) ----转发 收藏

    第4章 对关系使用默认规则与配置 在第3章,你已经掌握了默认规则与配置对属性以及其在数据库映射的字段的影响.在本章,我们把焦点放在类之间的关系上面.这包括类在内存如何关联,还有数据库中的外键维持等.你 ...