Dr. Alex Dong's Blog

windows 10 下安装 oracle 11g r2 em

1 Oracle Enterprise Manager与Oracle Database Control

OEM是一个统称,是Oracle提供的图形化企业级管理工具的统称。具体有三种可用的工具:

1.1 Database Control

它用于管理一个数据库(可以是RAC集群数据库),具有实时管理和监视的功能,运行调度作业功能,告警功能。

1.2 Application Server Control

用于管理一个或者多个应用服务器实例。

1.3 Grid Control

Grid Control可以管理多个数据库和应用服务器,还可以管理计算机节点,支持通过第三方插件管理第三方产品。

在Oracle9i以及之前,OEM是以C/S架构出现的,从10g开始,使用B/S架构,使得管理员无需安装客户端即可直接通过浏览器进行管理。本文专注于Database Control这个工具,Database Control无需单独安装,在安装oracle的时候,它是自动一起安装的,但是必须经过仔细的配置才能使用。

2 Oracle Database Control 目录结构与工作原理


分析任何软件都需要从静态和动态两个方面着手,静态对应的是软件安装后的物理目录和文件布局;动态对应的是软件运行时各个部分之间的交互过程和内存布局。

2.1 目录结构

Database Control在10g和11g中的目录结构有细微差异,本文以11g为基础说明。

在安装完oracle 11g之后,$ORACLE_HOME目录下会有专门为Database Control提供服务的目录,如上图所示。其中oc4j是oracle container for j2ee的缩写,是oracle专用的j2ee容器与tomcat类似。

2.2 工作原理

从本质上说,Database Control本身就是一个j2EE应用,只是这个应用的功能很单一,就是管理Oracle数据库。它运行在oracle为其定制的j2EE容器中,使用其管理的oracle数据库来存放自身数据,使用代理进程来收集数据库之外的系统信息。

单纯从程序角度来说,Database Control其实本身与其管理的oracle数据库(称之为目标数据库)并无关联,完全可以使用单独的数据库(如单独的oracle数据库或者mysql数据库)来存放自身数据,也可以运行在单独机器的符合j2EE标准的容器中(如Tomcat)。但是Oracle公司考虑到效率和配置,为其定制了专门的容器,并且本身使用目标数据库来存放管理数据,而且运行在目标数据库实例所在的机器上。

Database Control的工作原理如下图所示。

Database Control自身使用的管理数据都存放到SYSMAN这个模式下。

了解了工作原理,其配置就容易理解了。与部署其他的j2EE程序一样,需要从数据和程序文件两个方面进行。从本质上说,所有这些操作都可以通过手工来一一完成,但是无论是建立大量的配置文件还是创建大量的数据表,纯手工方式都会很低效,也容易出错。所以Oracle公司为部署Database Control提供了专门的工具软件。

如果使用OUI来安装Oracle可以在安装阶段配置Database Control,在安装完成后还可以通过DBCA来配置,这些都是好用的GUI工具,但是本文的目的是在纯命令行下进行配置,所以上述方式不可用。

为了应对命令行模式下的配置,ORACLE公司为Database Control专门提供了配置助手emca(Enterprise manager Configuration Assistant)。

3 使用EMCA配置Database Control

3.1 数据准备

使用的命令是:

emca -repos create

3.2 安装错误汇总

配置: ORA-12541: TNS: 无监听程序

oracle.sysman.assistants.util.sqlEngine.SQLFatalErrorException: ORA-12541: TNS: 无监听程序

    at oracle.sysman.assistants.util.sqlEngine.SQLEngine.executeImpl(SQLEngine.java:1655)
    at oracle.sysman.assistants.util.sqlEngine.SQLEngine.executeSql(SQLEngine.java:1903)
    at oracle.sysman.emcp.ParamsManager.checkListenerStatusForDBControl(ParamsManager.java:3230)
    at oracle.sysman.emcp.EMReposConfig.unlockMGMTAccount(EMReposConfig.java:1001)
    at oracle.sysman.emcp.EMReposConfig.invoke(EMReposConfig.java:346)
    at oracle.sysman.emcp.EMReposConfig.invoke(EMReposConfig.java:158)
    at oracle.sysman.emcp.EMConfig.perform(EMConfig.java:253)
    at oracle.sysman.assistants.util.em.EMConfiguration.run(EMConfiguration.java:583)
    at oracle.sysman.assistants.util.em.EMConfigStep.executeImpl(EMConfigStep.java:139)
    at oracle.sysman.assistants.util.step.BasicStep.execute(BasicStep.java:210)
    at oracle.sysman.assistants.util.step.BasicStep.callStep(BasicStep.java:251)
    at oracle.sysman.assistants.dbca.backend.PostDBConfigureStep.executeImpl(PostDBConfigureStep.java:269)
    at oracle.sysman.assistants.util.step.BasicStep.execute(BasicStep.java:210)
    at oracle.sysman.assistants.util.step.Step.execute(Step.java:140)
    at oracle.sysman.assistants.util.step.StepContext$ModeRunner.run(StepContext.java:2667)
    at java.lang.Thread.run(Thread.java:595)

解决方案:

将服务端的 \product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora 的

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

改为:

(ADDRESS = (PROTOCOL = TCP)(HOST =计算机名)(PORT = 1521))然后重启 11gClientListener 服务

配置: exception caught in copyFile:

解决方案:

Windows 命令行必须以系统管理员权限运行

CONFIG: ORA-00955: name is already used by an existing object

由于有可能之前安装过EM, 在安装EMCA过程中有可能报如下错误

CONFIG: ORA-00955: name is already used by an existing object

解决方案:

drop已经创建的对象:

DROP PUBLIC SYNONYM MGMT_SEVERITY;
DROP PUBLIC SYNONYM MGMT_SEVERITY_ARRAY;
DROP PUBLIC SYNONYM MGMT_SEVERITY_OBJ;
DROP PUBLIC SYNONYM MGMT_AVAILABILITY;
DROP PUBLIC SYNONYM MGMT_CURRENT_AVAILABILITY;
DROP PUBLIC SYNONYM MGMT_CURRENT_METRICS;
DROP PUBLIC SYNONYM MGMT_CURRENT_METRIC_ERRORS;
DROP PUBLIC SYNONYM MGMT_CURRENT_SEVERITY;
DROP PUBLIC SYNONYM MGMT_SEVERITY_OBJ;
DROP PUBLIC SYNONYM MGMT_GUID_ARRAY;
DROP PUBLIC SYNONYM MGMT_GUID_OBJ;
DROP PUBLIC SYNONYM MGMT_METRICS;
DROP PUBLIC SYNONYM MGMT_METRICS_RAW;
DROP PUBLIC SYNONYM MGMT_METRICS_COMPOSITE_KEYS;
DROP PUBLIC SYNONYM MGMT_METRICS_1HOUR;
DROP PUBLIC SYNONYM MGMT_METRICS_1DAY;
DROP PUBLIC SYNONYM MGMT_METRIC_ERRORS;
DROP PUBLIC SYNONYM MGMT_METRIC_COLLECTIONS;
DROP PUBLIC SYNONYM MGMT_METRIC_THRESHOLDS;
DROP PUBLIC SYNONYM MGMT_TARGET;
DROP PUBLIC SYNONYM MGMT_TARGETS;
DROP PUBLIC SYNONYM MGMT_TARGET_PROPERTIES;
DROP PUBLIC SYNONYM MGMT_TARGET_MEMBERSHIPS;
DROP PUBLIC SYNONYM MGMT_TARGET_BLACKOUTS;
DROP PUBLIC SYNONYM MGMT_TYPE_PROPERTIES;
DROP PUBLIC SYNONYM MGMT_CURRENT_METRICS;
DROP PUBLIC SYNONYM MGMT_CURRENT_METRIC_ERRORS;
DROP PUBLIC SYNONYM MGMT_STRING_METRIC_HISTORY;
DROP PUBLIC SYNONYM MGMT_LONG_TEXT;
DROP PUBLIC SYNONYM MGMT_COLLECTION_PROPERTIES;
DROP PUBLIC SYNONYM MGMT_DELTA;
DROP PUBLIC SYNONYM MGMT_DELTA_IDS;
DROP PUBLIC SYNONYM MGMT_DELTA_ID_VALUES;
DROP PUBLIC SYNONYM MGMT_DELTA_ENTRY;
DROP PUBLIC SYNONYM MGMT_DELTA_ENTRY_VALUES;
DROP PUBLIC SYNONYM MGMT_DELTA_VALUE;
DROP PUBLIC SYNONYM MGMT_DELTA_VALUES;
DROP PUBLIC SYNONYM MGMT_NAME_VALUE;
DROP PUBLIC SYNONYM MGMT_NAME_VALUES;
DROP PUBLIC SYNONYM MGMT_JOB;
DROP PUBLIC SYNONYM MGMT_JOBS;
DROP PUBLIC SYNONYM MGMT_JOB_EXECPLAN;
DROP PUBLIC SYNONYM MGMT_JOB_EXECUTION;
DROP PUBLIC SYNONYM MGMT_JOB_EXEC_SUMMARY;
DROP PUBLIC SYNONYM MGMT_JOB_OUTPUT;
DROP PUBLIC SYNONYM MGMT_JOB_PARAMETER;
DROP PUBLIC SYNONYM MGMT_JOB_SCHEDULE;
DROP PUBLIC SYNONYM MGMT_JOB_TARGET;
DROP PUBLIC SYNONYM MGMT_AVAILABILITY;
DROP PUBLIC SYNONYM MGMT_ADMIN;
DROP PUBLIC SYNONYM MGMT_GLOBAL;
DROP PUBLIC SYNONYM MGMT_LOG;
DROP PUBLIC SYNONYM MGMT_CREDENTIAL;
DROP PUBLIC SYNONYM MGMT_PREFERENCES;
DROP PUBLIC SYNONYM MGMT_PAF_PROCS_LATEST;
DROP PUBLIC SYNONYM MGMT_PAF_JOBS;
DROP PUBLIC SYNONYM MGMT_PAF$PROCEDURES;
DROP PUBLIC SYNONYM MGMT_PAF$APPLICATIONS;
DROP PUBLIC SYNONYM MGMT_PAF$INSTANCES;
DROP PUBLIC SYNONYM MGMT_PAF$STATES;
DROP PUBLIC SYNONYM SMP_EMD_AVAIL_OBJ;
DROP PUBLIC SYNONYM SMP_EMD_TARGET_OBJ;
DROP PUBLIC SYNONYM SMP_EMD_TARGET_OBJ_ARRAY;
DROP PUBLIC SYNONYM SMP_EMD_DELETE_REC_ARRAY;
DROP PUBLIC SYNONYM EMD_MNTR;
DROP PUBLIC SYNONYM SMP_EMD_NVPAIR;
DROP PUBLIC SYNONYM SMP_EMD_NVPAIR_ARRAY;
DROP PUBLIC SYNONYM SMP_EMD_STRING_ARRAY;
DROP PUBLIC SYNONYM SMP_EMD_STRING_ARRAY_ARRAY;
DROP PUBLIC SYNONYM SMP_EMD_INTEGER_ARRAY;
DROP PUBLIC SYNONYM SMP_EMD_INTEGER_ARRAY_ARRAY;
DROP PUBLIC SYNONYM ECM_UTIL;
DROP PUBLIC SYNONYM MGMT_USER;
DROP PUBLIC SYNONYM MGMT_VIEW_UTIL;
DROP PUBLIC synonym SETEMVIEWUSERCONTEXT;
DROP PUBLIC SYNONYM MGMT_MESSAGES;
DROP ROLE MGMT_USER;
DROP USER MGMT_VIEW CASCADE;
DROP USER SYSMAN CASCADE;

找不到对应数据库

这是由于TNS Listener改变所致。解决方案是修改pfile, 并且通过pfile启动Oracle

Pfile所在位置:

C:\app\用户名\admin\数据库名\pfile\init.ora.xxxxxxxxx

找到一下配置

###########################################
# Network Registration
###########################################
local_listener="(ADDRESS = Listen_ORCL)"

改为

###########################################
# Network Registration
###########################################
local_listener="(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))"

Pfile启动Oracle

startup pfile='C:\app\用户名\admin\数据库名\pfile\init.ora.xxxxxxxxx'

3.3 配置文件布局

使用emca -config dbcontrol db命令来创建必要的配置文件。这个操作一般不会出错,注意填正确各个账户的密码就可以了。

4 浏览器访问Database Control

登录地址和网上所说的不一样,网上一般Database Control登录地址是:

https://localhost:1158:em

实际的登录地址应该根据安装日志中提到的地址。安装日志所存地址是:

C:\app\用户名\cfgtoollogs\emca\数据库名\emcaxxxxxxxxxxxx.log

找最后一个log文件,即为最近安装日志。找到如下内容:

INFO: >>>>>>>>>>> The Database Control URL is https://192.168.1.15:5500/em <<<<<<<<<<<

笔者的登录地址是:

https://192.168.1.15:5500/em

使用sysman登录

登录效果如下

5. Database Controller服务基本操作

Database Controller 服务的操作使用emctl命令。请使用Oracle Server 带的该命令,如果你有安装Oracle客户端和服务端在同一台机器。emctl命令位于:

C:\app\用户名\product\11.2.0\dbhome_1\BIN

Data Controller服务状态查询

emctl status dbconsole

Data Controller服务启动

emctl start dbconsole

Data Controller服务关闭

emctl stop dbconsole
adminwindows 10 下安装 oracle 11g r2 em