CentOS Oracle 报 Environment variable ORACLE_UNQNAME not defined 错误的解决办法

今天在 CentOS 上安装完 Oracle 后,通过命令 “emctl start dbconsole” 启动管理控制台时,报了 “Environment variable ORACLE_UNQNAME not defined” 的错误。问题原因是因为 Oracle 总是获取不到正确的 IP 地址(安装 Oracle 时获取的 IP 地址就是错误的),导致 em 出现问题,只需重新配置 emca 即可。折腾了好久,最后终于把问题给解决了。

环境描述

操作系统: CentOS 6.5

IP:         192.168.132.41

域:         mycompany.com.cn

主机名: hemw-pc

Oracle:11gR2,安装目录为 /opt/oracle/11g

问题分析

刚开始按照网上的解决方案使用命令“emca -config dbcontrol db -repos create” 重新创建 em,输入完对应的信息时,到最后确认时获取到的 IP 地址总是不正确(Local hostname 应该是 192.168.132.41 才对):

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

You have specified the following settings

Database ORACLE_HOME ................ /opt/oracle/11g

Local hostname ................ 192.168.64.61
Listener ORACLE_HOME ................ /opt/oracle/11g
Listener port number ................ 1521
Database SID ................ orcl
Email address for notifications ...............
Outgoing Mail (SMTP) server for notifications ............... 

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

因为获取到的 hostname 值不正确,导致一直无法创建成功,提示如下错误

Could not complete the configuration. Refer to the log file at /opt/oracle/cfgtoollogs/emca/orcl/emca_2015_03_10_17_19_30.log for more details.

解决方案

经过各种尝试和折腾后,最终还是把问题给搞定了,步骤如下:

1. 停止监听器

$ lsnrctl stop

2. 停止 oracle 数据库

$ sqlplus "sys / as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 10 17:16:45 2015

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Enter password: 

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown

3. 修改 $ORACLE_HOME/network/admin/listener.ora,将文件内容中 HOST 的值改为正确的 IP(192.168.132.41),如:

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.132.41)(PORT = 1521))
    )
  )

4. 修改 $ORACLE_HOME/network/admin/tnsnames.ora,将文件内容中 HOST 的值改为正确的 IP(192.168.132.41),如:

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.132.41)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

5. 修改 /etc/sysconfig/network,将文件内容改为:

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=hemw-pc

因为修改完这个文件后需要重启操作系统才会生效,所以在不重启操作系统的情况下需要同时执行一下:# hostname hemw-pc

6. 修改 /etc/hosts,在文件的最后新增如下内容:

192.168.132.41 hemw-pc hemw-pc.mycompany.com.cn

7. 启动数据库

SQL> startup

8. 启动监听

$ lsnrctl start

9. 删除早期DBCONSOLE创建的用户:

sql>drop role MGMT_USER;
sql>drop user MGMT_VIEW cascade;
sql>drop user sysman cascade;

10. 删除早期DBCONSOLE创建的对象:

sql>drop PUBLIC SYNONYM MGMT_TARGET_BLACKOUTS;
sql>drop public synonym SETEMVIEWUSERCONTEXT;

11. 重新创建DBCONSOLE:(如果是在windows下,要先到注册表删除DBCONSOLE的服务,重启电脑)

$emca -config dbcontrol db -repos create

如果提示创建失败,输出类似 “Could not complete the configuration. Refer to the log file at /opt/oracle/cfgtoollogs/emca/orcl/emca_*.log for more details.” 的错误信息,请查看对应的日志文件, 日志文件的最后一行内容如果是 “ORA-00955: name is already used by an existing object”,如:

CREATE PUBLIC SYNONYM MGMT_AVAILABILITY FOR MGMT_AVAILABILITY
                      *
ERROR at line 1:
ORA-00955: name is already used by an existing object

则需要执行一次重建的命令:

$emca -config dbcontrol db -repos recreate

在执行上面命令的过程中需要根据提示输入对应的数据库信息及 SYS、DBSNMP 和 SYSMAN 的登录密码,最后输入 Y 进行确认,如:

STARTED EMCA at Mar 10, 2015 10:03:17 PM
EM Configuration Assistant, Version 11.2.0.0.2 Production
Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Enter the following information:
Database SID: orcl
Listener port number: 1521
Listener ORACLE_HOME [ /opt/oracle/11g ]:
Password for SYS user:
Password for DBSNMP user:
Password for SYSMAN user:
Email address for notifications (optional):
Outgoing Mail (SMTP) server for notifications (optional):

12. 检查 em 的状态

$ emctl status dbconsole

Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
Copyright (c) 1996, 2009 Oracle Corporation.  All rights reserved.
https://hemw-pc:1158/em/console/aboutApplication
Oracle Enterprise Manager 11g is running.
------------------------------------------------------------------
Logs are generated in directory /opt/oracle/11g/hemw-pc_orcl/sysman/log

至此,问题已经解决完毕。

附:emca 常用命令

创建一个 em 资料库:emca -repos create

重建一个 em 资料库:emca -repos recreate

删除一个 em 资料库:emca -repos drop

配置数据库的 Database Control:emca -config dbcontrol db

删除数据库的 Database Control配置:emca -deconfig dbcontrol db

重新配置db control的端口,默认端口在1158

emca -reconfig ports

emca -reconfig ports -dbcontrol_http_port 1160

emca -reconfig ports -agent_port 3940

先设置 ORACLE_SID 环境变量后,启动 em console服务:emctl start dbconsole

先设置 ORACLE_SID 环境变量后,停止em console服务:emctl stop dbconsole

先设置 ORACLE_SID 环境变量后,查看 em console服务的状态:emctl status dbconsole

配置 dbconsole 的步骤

emca -repos create

emca -config dbcontrol db

emctl start dbconsole

重新配置 dbconsole 的步骤

emca -repos drop

emca -repos create

emca -config dbcontrol db

emctl start dbconsole

参考资料:

http://soulful.blog.51cto.com/468033/449934

http://czhwin.iteye.com/blog/1847366

时间: 2024-10-11 05:27:51

CentOS Oracle 报 Environment variable ORACLE_UNQNAME not defined 错误的解决办法的相关文章

解决oracle报Environment variable ORACLE_UNQNAME not d

解决oracle报Environment variable ORACLE_UNQNAME not defined重新配置em即可,还有Oracle_SID环境变量一定要记得设置.1,修改DBSNMP密码:重新配置DBCONSOLE,需要输入DBSNMP密码,但任何密码都会显示错误,需要预先修改好.C:\Users\Administrator>sqlplus /nolog SQL*Plus: Release 11.2.0.1.0 Production on 星期二 10月 16 19:24:32

Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name

今天在安装的测试环境下想启动一下OEM,结果启动的时候报了一个错如下: Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name. 按照错误提示是需要设置一下ORACLE_UNQNAME的,所以su - oracle 编辑配置文件如下: soure .bash_profile 使文件生效,在重新启动OEM,结果又报了另外一个错误, OC4J Configur

在idea启动tomcat出现The JAVA_HOME environment variable is not defined correctly的解决

情况:某套代码是用jdk 1.6编译,然后电脑的JAVA_HOME系统变量配的是jdk1.7的,在tomcat启动时报错 The JAVA_HOME environment variable is not defined correctly,中文意思是JAVA_HOME定义不正确,去系统变量看指向的是jdk 1.7,当然不正确了,那如何为这个tomcat单独指定一个JAVA_HOME? 方法: Tomcat的jre配置,原来是 改成jdk路径(也就是去掉jre) PS:在myeclipse里to

Eclipse打开Android项目报Parsing Data for android-21 failed错误的解决办法(转载)

转载:http://segmentfault.com/blog/hongliang/1190000000739285 今天手贱,用android命令打开SDK Manager下载了最新的Android 5.0 SDK: 结果用Eclipse打开cocos2d-x的proj.android项目就各种报错,第一个典型的错误是启动Eclipse后Eclipse自己就报Parsing Data for android-21 failed错误,没理会它,继续打开项目,发现libcocos2dx项目无法生成

CentOS Linux时出现GPT分区不能引导错误的解决办法

PS:服务器型号Dell R720,此机器之前安装的Win 2008R2时采用了GPT分区,导致CentOS 无法读取(但CentOS 6.x默认就支持GPT),解决过程如下: 问题:图形界面安装到分区时 Your boot partition is on a disk using the GPT partitioning Scheme but this machines cannot boot using GPT. 处理步骤: 1种 parted -s /dev/sda mklabel msd

关于Android Studio中启动模拟器时,报VT-x is disabled in BIOS错误的解决办法

有时候在Android Studio中启动一个模拟器去运行程序的时候,会出现下面的错误提示:"Intel HAXM is required to run this AVD,VT-x is disabled in BIOS". 接下来我来说说解决的办法: 1. 首先在SDK Manager中检查是否安装Download Intel x86 Emulator Accelerator (HAXM installer),如果没有安装,则在SDK Manager中下载安装Download Int

Sublime Text 2报“Decode error - output not utf-8”错误的解决办法

[Decode error - output not utf-8] [Decode error - output not utf-8] 应该怎么办? 这是因为python配置的编译环境的编码不正确,因为默认的Sublime Text 2的编码是UTF-8. 很简单,解决办法如下: [解决办法]修改Python.sublime-build配置文件,添加如下行: "encoding":"cp936" (注意在上一行结束加逗号)(如图所示)

CentOS下编译php时的一些典型错误及解决办法.

configure: error: xml2-config not found. Please check your libxml2 installation.yum install libxml2-devel configure: error: Cannot find OpenSSL'syum install openssl-devel configure: error: Please reinstall the libcurl distribution - easy.h should be

oracle em启动失败--ORACLE_UNQNAME not defined

客户的服务器启动不了em 报错Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name. 需要做的比对 1,oracle 目录下的TNS .LSN配置文件hostname 2,linux  /etc/hosts 里的hostname 3,oracle 用户下 .bash_profile 或者是 .bashrc 能配置hostname的地方是否都一致 我出现的