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

listener.ora  samples  shrept.lst  sqlnet.ora  tnsnames.ora

[oracle@oracle admin]$ vi listener.ora

 

# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/dbhome_1/network/admin/listener.ora

# 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))

    )

  )

 

~                                                                                    

"listener.ora" 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: please wait...

 

TNSLSNR for Linux: Version 10.2.0.1.0 - Production

System parameter file is /u01/app/oracle/product/10.2.0/dbhome_1/network/admin/listener.ora

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/admin/listener.ora

Listener Log File         /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

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.net.UnknownHostException: oracle: oracle

at java.net.InetAddress.getLocalHost(InetAddress.java:1191)

at oracle.sysman.emSDK.conf.TargetInstaller.getLocalHost(TargetInstaller.java:4977)

at oracle.sysman.emSDK.conf.TargetInstaller.main(TargetInstaller.java:3758)

Exception in getting local host

java.net.UnknownHostException: oracle: oracle

at java.net.InetAddress.getLocalHost(InetAddress.java:1191)

at oracle.sysman.emSDK.conf.TargetInstaller.getLocalHost(TargetInstaller.java:4977)

at oracle.sysman.emSDK.conf.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

 

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

 

Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 10.2.0.1.0 - Production

System parameter file is /u01/app/oracle/product/10.2.0/dbhome_1/network/admin/listener.ora

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=localhost.localdomain)(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:48:06

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/admin/listener.ora

Listener Log File         /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

 

 

[oracle@localhost ~]$ emctl start dbconsole

TZ set to US/Pacific

Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0 

Copyright (c) 1996, 2005 Oracle Corporation.  All rights reserved.

http://localhost.localdomain:1158/em/console/aboutApplication

Starting Oracle Enterprise Manager 10g Database Control ....................... started.

------------------------------------------------------------------

Logs are generated in directory /u01/app/oracle/product/10.2.0/dbhome_1/localhost.localdomain_orcl/sysman/log

 

总结:使用hostname命令改变主机名,监听是可以启动的,EM无法启动,重启就恢复了。

 

 

2.       静态改变主机名

我们要对比一下改network里的hostname和hosts里对应关系有什么影响

A.我们先改一下network里的hostname

[oracle@localhost ~]$ vi /etc/sysconfig/network

[oracle@localhost ~]$ vi /etc/sysconfig/network

[oracle@localhost ~]$ su -

Password:

[root@localhost ~]# vi /etc/sysconfig/network

将hostname改成oracle

NETWORKING=yes

NETWORKING_IPV6=no

HOSTNAME=oracle

~          

需要重启才能改过来

[oracle@oracle ~]$

那么我们启动监听

[oracle@oracle ~]$ lsnrctl start

 

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2011 02:05:47

 

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

 

Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 10.2.0.1.0 - Production

System parameter file is /u01/app/oracle/product/10.2.0/dbhome_1/network/admin/listener.ora

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 02:05:49

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/admin/listener.ora

Listener Log File         /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

 

启动EM

[oracle@oracle ~]$ emctl start dbconsole

TZ set to US/Pacific

Exception in getting local host

java.net.UnknownHostException: oracle: oracle

at java.net.InetAddress.getLocalHost(InetAddress.java:1191)

at oracle.sysman.emSDK.conf.TargetInstaller.getLocalHost(TargetInstaller.java:4977)

at oracle.sysman.emSDK.conf.TargetInstaller.main(TargetInstaller.java:3758)

Exception in getting local host

java.net.UnknownHostException: oracle: oracle

at java.net.InetAddress.getLocalHost(InetAddress.java:1191)

at oracle.sysman.emSDK.conf.TargetInstaller.getLocalHost(TargetInstaller.java:4977)

at oracle.sysman.emSDK.conf.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.

 

总结:监听可以启动,EM无法启动,那么我们这里监听的状态又使用的是127.0.0.1,而不是orale那,我们先改一下listener.ora看看

 

[oracle@oracle~]$vi/u01/app/oracle/product/10.2.0/dbhome_1/network/admin/listener.ora

 

# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/dbhome_1/network/admin/listener.ora

# 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))

    )

  )

 

~                                                                                    

<cle/product/10.2.0/dbhome_1/network/admin/listener.ora" 20L, 525C 1,1           All

把HOST = localhost.localdomain 改成HOST = oracle重启监听

 

[oracle@oracle ~]$ lsnrctl stop

 

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2011 02:12:05

 

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))

The command completed successfully

[oracle@oracle ~]$ lsnrctl start

 

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2011 02:12:29

 

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

 

Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 10.2.0.1.0 - Production

System parameter file is /u01/app/oracle/product/10.2.0/dbhome_1/network/admin/listener.ora

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)))

Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle)(PORT=1521)))

TNS-12545: Connect failed because target host or object does not exist

 TNS-12560: TNS:protocol adapter error

  TNS-00515: Connect failed because target host or object does not exist

   Linux Error: 11: Resource temporarily unavailable

 

Listener failed to start. See the error message(s) above...

 

启动失败

 

B.我们下面只更改hosts文件不更改network看看是什么情况

          

 [oracle@localhost ~]$ 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

~                                                    

这里值得注意的是hosts文件配置是分三部分 ip 主机名 别名

那么主机名和别名有什么区别?我们做个试验

将主机名改成123 别名改成456 看看有什么效果?包括监听及EM

[oracle@localhost ~]$ su -

Password:

[root@localhost ~]#

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1               123 456

::1             localhost6.localdomain6 localhost6

 

重启后

[oracle@localhost ~]$

[oracle@localhost ~]$ lsnrctl start

 

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2011 02:26:35

 

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

 

Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 10.2.0.1.0 - Production

System parameter file is /u01/app/oracle/product/10.2.0/dbhome_1/network/admin/listener.ora

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)))

Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))

TNS-12545: Connect failed because target host or object does not exist

 TNS-12560: TNS:protocol adapter error

  TNS-00515: Connect failed because target host or object does not exist

   Linux Error: 11: Resource temporarily unavailable

 

Listener failed to start. See the error message(s) above...

 

 

监听启动失败了,那么我们改一下listener试试,先改成456试试

 

# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/dbhome_1/network/admin/listener.ora

# 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 = 456)(PORT = 1521))

    )

  )

 

~                                                                                    

 

[oracle@localhost ~]$ lsnrctl start

 

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2011 02:29:46

 

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

 

Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNS-12537: TNS:connection closed

 TNS-12560: TNS:protocol adapter error

  TNS-00507: Connection closed

   Linux Error: 29: Illegal seek

 

 

监听启动失败,那么改成123那

[oracle@localhost ~]$ lsnrctl start

 

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2011 02:30:58

 

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

 

Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNS-12537: TNS:connection closed

 TNS-12560: TNS:protocol adapter error

  TNS-00507: Connection closed

   Linux Error: 29: Illegal seek            

 

 

总结:说明只改hosts文件也是不行的,监听起不来,那么我们把network里的hostname也改一下,改成123试试

 

[oracle@123 ~]$ lsnrctl start

 

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2011 02:40:22

 

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

 

Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNS-12537: TNS:connection closed

 TNS-12560: TNS:protocol adapter error

  TNS-00507: Connection closed

   Linux Error: 29: Illegal seek

 

现在是listener和hosts和network都是123还是无法启动监听

 

把hosts里的456改成localhost试试

 

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1               123 localhost

::1             localhost6.localdomain6 localhost6

 

[oracle@123 ~]$ lsnrctl start

 

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2011 02:44:06

 

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

 

Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 10.2.0.1.0 - Production

System parameter file is /u01/app/oracle/product/10.2.0/dbhome_1/network/admin/listener.ora

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=0.0.0.123)(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 02:44:07

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/admin/listener.ora

Listener Log File         /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.123)(PORT=1521)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

 

 

监听启动成功,EM无法启动提示找不到对应的文件,那么我们就知道hosts里的别名就需要用localhost。

先我们把hosts和network的hostname都改成nag_oracle,listener.ora也改成nag_oracle

看一下状态准备解决EM启动不了的问题

[oracle@nag_oracle ~]$ lsnrctl start

 

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2011 02:56:23

 

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

 

Starting /u01/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 10.2.0.1.0 - Production

System parameter file is /u01/app/oracle/product/10.2.0/dbhome_1/network/admin/listener.ora

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=nag_oracle)(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 02:56:25

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/admin/listener.ora

Listener Log File         /u01/app/oracle/product/10.2.0/dbhome_1/network/log/listener.log

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=nag_oracle)(PORT=1521)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

 

[oracle@nag_oracle ~]$ emctl start dbconsole

TZ set to US/Pacific

OC4J Configuration issue. /u01/app/oracle/product/10.2.0/dbhome_1/oc4j/j2ee/OC4J_DBConsole_nag_oracle_orcl not found.

 

 

二.             恢复启动EM

从上面的试验我们可看出,只要hosts和network里的hostname对应监听是可以启动的,即使改变ip,我们listener里host配置的是hostname而不是ip,多用对启动监听没有什么影响。

那么我们改变了主机名后对什么文件产生了影响导致EM无法启动了那,从上面我们可以看出一个路径提示找不到/u01/app/oracle/product/10.2.0/dbhome_1/oc4j/j2ee/OC4J_DBConsole_nag_oracle_orcl not found.

下面我们列出改变主机名后需要更改的文件及路径

1.      listener.ora 启动监听用的,tnsname.ora

2.      /u01/app/oracle/product/10.2.0/dbhome_1 也就是ORACLE-HOEM\下的

原主机名_实例的目录,把主机名修改一下

 

3.      /u01/app/oracle/product/10.2.0/dbhome_1/oc4j/j2ee/ 下

OC4J_DBConsole_原主机名_实例名   

    下面我们分别修改一下

 

 

[oracle@nag_oracle admin]$ ls

listener.ora  samples  shrept.lst  sqlnet.ora  tnsnames.ora

[oracle@nag_oracle admin]$ pwd

/u01/app/oracle/product/10.2.0/dbhome_1/network/admin

[oracle@nag_oracle admin]$ vi tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/dbhome_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

ORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST =nag_oracle)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

 

EXTPROC_CONNECTION_DATA =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))

    )

    (CONNECT_DATA =

      (SID = PLSExtProc)

      (PRESENTATION = RO)

    )

"tnsnames.ora" 23L, 530C 

 

 

[oracle@nag_oracle admin]$ cd /u01/app/oracle/product/10.2.0/dbhome_1/

[oracle@nag_oracle dbhome_1]$ pwd

/u01/app/oracle/product/10.2.0/dbhome_1

[oracle@nag_oracle dbhome_1]$ ls

assistants   has               localhost.localdomain_orcl  oracore      root.sh.old

bin          hs                log                         oraInst.loc  slax

cdata        install           md                          ord          sqlj

cfgtoollogs  install.platform  mesg                        oui          sqlnet.log

clone        inventory         mgw                         owm          sqlplus

config       javavm            network                     perl         srvm

crs          jdbc              nls                         plsql        sysman

css          jdk               oc4j                        precomp      uix

ctx          jlib              odbc                        racg         wwg

dbs          jre               olap                        rdbms        xdk

demo         ldap              OPatch                      relnotes

diagnostics  lib               opmn                        root.sh

 

[oracle@nag_oracle dbhome_1]$ mv localhost.localdomain_orcl/ nag_oracle_orcl/

[oracle@nag_oracle dbhome_1]$ ls

 

assistants   demo              jlib             nls          owm          sqlj

bin          diagnostics       jre              oc4j         perl         sqlnet.log

cdata        has               ldap             odbc         plsql        sqlplus

cfgtoollogs  hs                lib              olap         precomp      srvm

clone        install           log              OPatch       racg         sysman

config       install.platform  md               opmn         rdbms        uix

crs          inventory         mesg             oracore      relnotes     wwg

css          javavm            mgw              oraInst.loc  root.sh      xdk

ctx          jdbc              nag_oracle_orcl  ord          root.sh.old

dbs          jdk               network          oui          slax

 

[oracle@nag_oracle j2ee]$ cd /u01/app/oracle/product/10.2.0/dbhome_1/oc4j/j2ee

[oracle@nag_oracle j2ee]$ ls

deploy_db.ini  isqlplus           OC4J_DBConsole

home           oc4j_applications  OC4J_DBConsole_localhost.localdomain_orcl

[oracle@nag_oracle j2ee]$ mv OC4J_DBConsole_localhost.localdomain_orcl OC4J_DBConsole_nag_oracle_orcl

[oracle@nag_oracle j2ee]$ ls

deploy_db.ini  isqlplus           OC4J_DBConsole

home           oc4j_applications  OC4J_DBConsole_nag_oracle_orcl

[oracle@nag_oracle j2ee]$

 

重新配置EM

/*重新配置dbcosole
emca -repos drop
emca -repos create
emca -config dbcontrol db
emctl start dbconsole

[oracle@nag_oracle ~]$ emca -repos drop

 

STARTED EMCA at Feb 26, 2011 3:28:27 AM

EM Configuration Assistant, Version 10.2.0.1.0 Production

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

 

Enter the following information:

Database SID: orcl

Listener port number: 1521

Password for SYS user: 

Password for SYSMAN user: 

 

Do you wish to continue? [yes(Y)/no(N)]: y

Feb 26, 2011 3:28:42 AM oracle.sysman.emcp.EMConfig perform

INFO: This operation is being logged at /u01/app/oracle/product/10.2.0/dbhome_1/cfgtoollogs/emca/orcl/emca_2011-02-26_03-28-26-AM.log.

Feb 26, 2011 3:28:43 AM oracle.sysman.emcp.EMReposConfig dropRepository

INFO: Dropping the EM repository (this may take a while) ...

Feb 26, 2011 3:31:09 AM oracle.sysman.emcp.EMReposConfig invoke

INFO: Repository successfully dropped

Enterprise Manager configuration completed successfully

FINISHED EMCA at Feb 26, 2011 3:31:09 AM

 

删除的过程需要填写

Database SID: orcl

Listener port number: 1521

 

及sys和SYSMAN的密码

删除需要运行几分钟

然后重新创建

[oracle@nag_oracle ~]$ emca -repos create

 

STARTED EMCA at Feb 26, 2011 3:34:40 AM

EM Configuration Assistant, Version 10.2.0.1.0 Production

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

 

Enter the following information:

Database SID: orcl

Listener port number: 1521

Password for SYS user: 

Password for SYSMAN user: 

 

Do you wish to continue? [yes(Y)/no(N)]: y

Feb 26, 2011 3:34:57 AM oracle.sysman.emcp.EMConfig perform

INFO: This operation is being logged at /u01/app/oracle/product/10.2.0/dbhome_1/cfgtoollogs/emca/orcl/emca_2011-02-26_03-34-40-AM.log.

Feb 26, 2011 3:34:57 AM oracle.sysman.emcp.EMReposConfig createRepository

INFO: Creating the EM repository (this may take a while) ...

Feb 26, 2011 3:39:43 AM oracle.sysman.emcp.EMReposConfig invoke

INFO: Repository successfully created

Enterprise Manager configuration completed successfully

FINISHED EMCA at Feb 26, 2011 3:39:43 AM

 

重新配置 dbcontrol db 中间会要求输入几个用户的密码

使用sysdba修改一下密码即可,或是提前修改

需要输入密码的用户:sys、DBSNMP、SYSMAN

Email可以不输入,直接敲回车即可

[oracle@nag_oracle ~]$ emca -config dbcontrol db

 

STARTED EMCA at Feb 26, 2011 3:40:42 AM

EM Configuration Assistant, Version 10.2.0.1.0 Production

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

 

Enter the following information:

Database SID: orcl

Database Control is already configured for the database orcl

You have chosen to configure Database Control for managing the database orcl

This will remove the existing configuration and the default settings and perform a fresh configuration

Do you wish to continue? [yes(Y)/no(N)]: y

Listener port number: 1521

Password for SYS user: 

Password for DBSNMP user: 

Password for DBSNMP user: Invalid username/password.

Password for DBSNMP user: 

Password for SYSMAN user: 

Email address for notifications (optional):

Outgoing Mail (SMTP) server for notifications (optional):

-----------------------------------------------------------------

 

You have specified the following settings

 

Database ORACLE_HOME ................ /u01/app/oracle/product/10.2.0/dbhome_1

 

Database hostname ................ nag_oracle

Listener port number ................ 1521

Database SID ................ orcl

Email address for notifications ...............

Outgoing Mail (SMTP) server for notifications ...............

 

-----------------------------------------------------------------

Do you wish to continue? [yes(Y)/no(N)]: y

Feb 26, 2011 3:42:45 AM oracle.sysman.emcp.EMConfig perform

INFO: This operation is being logged at /u01/app/oracle/product/10.2.0/dbhome_1/cfgtoollogs/emca/orcl/emca_2011-02-26_03-40-42-AM.log.

Feb 26, 2011 3:42:46 AM oracle.sysman.emcp.DatabaseChecks performReposChecks

WARNING: 'shared_pool_size' must be greater than or equal to 80 MB. 

Feb 26, 2011 3:42:47 AM oracle.sysman.emcp.util.DBControlUtil stopOMS

INFO: Stopping Database Control (this may take a while) ...

Feb 26, 2011 3:43:24 AM oracle.sysman.emcp.util.DBControlUtil startOMS

INFO: Starting Database Control (this may take a while) ...

Feb 26, 2011 3:45:20 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration

INFO: Database Control started successfully

Feb 26, 2011 3:45:20 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration

INFO: >>>>>>>>>>> The Database Control URL is http://nag_oracle:1158/em <<<<<<<<<<<

Enterprise Manager configuration completed successfully

FINISHED EMCA at Feb 26, 2011 3:45:20 AM

 

 

启动EM

[oracle@nag_oracle ~]$ emctl start dbconsole

TZ set to US/Pacific

Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0 

Copyright (c) 1996, 2005 Oracle Corporation.  All rights reserved.

http://nag_oracle:1158/em/console/aboutApplication

 - An instance of Oracle Enterprise Manager 10g Database Control is already running.

会提示已经启动了

[oracle@nag_oracle ~]$ firefox

 

把地址输入即可访问http://nag_oracle:1158/em/console/aboutApplication

 

注意:如果上述的方法还是无法启动,可以参照下面的方法,手动删除一些信息再创建

 

同样适用于windows,unix,linux其他原因导致DBCONSOLE无法正常启动。
1,修改DBSNMP密码:
重新配置DBCONSOLE,需要输入DBSNMP密码,但任何密码都会显示错误,需要预先修改。
sql>alter user dbsnmp identified by xxx;
2,删除早期DBCONSOLE创建的用户:
sql>drop role MGMT_USER;
sql>drop user MGMT_VIEW cascade;
sql>drop user sysman cascade;
3,删除早期DBCONSOLE创建的对象:
sql>drop PUBLIC SYNONYM MGMT_TARGET_BLACKOUTS;
sql>drop public synonym SETEMVIEWUSERCONTEXT;

4. emca -config dbcontrol db -repos recreate

 

 

 

注:静态修改主机名后,监听要正常启动,hosts和network中的主机名必须同时修改,而且必须一致