Linux下主机名的修改对oracle监听及EM的影响及恢复
一. 修改主机名及恢复监听
修改主机名分为动态和静态,动态是指不需要重启就能更改,但是重启无法保存,静态的意思需要修改配置文件,重启会被保存
1. 动态修改对监听的影响
查看当前的hostname
[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# hostname oracle
[root@localhost ~]# su –
查看network的hostname
[root@oracle ~]# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
查看hosts
[root@oracle ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1              localhost.localdomain localhost
::1            localhost6.localdomain6 localhost6
            先去启动一下监听看一下有什么变化
            [root@oracle ~]# su - oracle
[oracle@oracle ~]$
[oracle@oracle~]$cd/u01/app/oracle/product/10.2.0/dbhome_1/network/admin/
[oracle@oracle admin]$ pwd
/u01/app/oracle/product/10.2.0/dbhome_1/network/admin
[oracle@oracle admin]$ ls
a  samples  shrept.lst  a  a
[oracle@oracle admin]$ a
# a Network Configuration File: /u01/app/oracle/product/10.2.0/dbhome_1/network/a
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/dbhome_1)
      (PROGRAM = extproc)
    )
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    )
  )
~                                                                                   
"a" 20L, 525C           
[oracle@oracle ~]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2011 01:23:16
Copyright (c) 1991, 2005, Oracle.  All rights reserved.
Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr:
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/10.2.0/dbhome_1/network/a
Log messages written to /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                    LISTENER
Version                  TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                26-FEB-2011 01:23:17
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level              off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File  /u01/app/oracle/product/10.2.0/dbhome_1/network/a
Listener Log File        /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log
Listening
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for
The command completed successfully
监听状态host=127.0.0.1  变成了ip,hostname没有改变前启动监听
Host= localhost.localdomain
现在启动一下EM,看看可以不可以启动
[oracle@oracle admin]$ emctl start dbconsole
TZ set to US/Pacific
Exception in getting local host
java.UnknownHostException: oracle: oracle
    at LocalHost(InetAddress.java:1191)
    at LocalHost(TargetInstaller.java:4977)
    at f.TargetInstaller.main(TargetInstaller.java:3758)
Exception in getting local host
java.UnknownHostException: oracle: oracle
    at LocalHost(InetAddress.java:1191)
    at LocalHost(TargetInstaller.java:4977)
    at f.TargetInstaller.main(TargetInstaller.java:3758)开机时主机响
OC4J Configuration issue. /u01/app/oracle/product/10.2.0/dbhome_1/oc4j/j2ee/OC4J_DBConsole_null_orcl not found.
改了hostname EM已经无法启动
            重启一下linux看看启动监听和EM看看是什么效果
[oracle@nag_oracle ~]$ su -
Password:
[root@nag_oracle ~]#init 6
[oracle@localhost ~]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2011 01:48:03