作为命令行忠有用户,server端软件的运维都倾向于使用命令或 脚本完毕,非常讨厌资源占用非常大的GUI。Oracle数据库作为重要的server端软件。其安装运维自然也全然支持纯命令行方式。虽然同一时候提供了OUI这个GUI安装程序。至于纯命令行下静默安装Oracle11g。本人之前写过具体的博文。有须要的请參考之,博文地址http://blog.csdn.net/smstong/article/details/7352036。依照这篇博文安装的数据库全然可用。本文算是对前面这篇博文的一个补充,就是在数据库安装完毕的基础上安装配置Oracle Enterprise Manager,使得管理员在厌倦单纯sqlplus的情况下,能够使用浏览器来管理Oracle数据库。

1 Oracle Enterprise Manager与Oracle Database Control

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

(1)Database Control

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

(2)Application Server Control

用于管理一个或者多个应用server实例。

(3)Grid Control

Grid Control能够管理多个数据库和应用server,还能够管理计算机节点,支持通过第三方插件管理第三方产品。

在Oracle9i以及之前,OEM是以C/S架构出现的。从10g開始。使用B/S架构,使得管理员无需安装client就可以直接通过浏览器进行管理。本文专注于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这个模式下。

了解了工作原理,其配置就easy理解了。

与部署其它的j2EE程序一样,须要从数据和程序文件两个方面进行。

从本质上说。全部这些操作都能够通过手工来一一完毕,可是不管是建立大量的配置文件还是创建大量的数据表。纯手工方式都会非常低效,也easy出错。所以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

它的作用是为Database Control在数据库中创建必要的用户(模式)(sysman, dbsnmp等)和模式对象(存储过程。表,索引等等)。emca本身是一个脚本文件。终于调用的是java程序来完毕实际的工作。

因为在创建对象的过程中,须要以sysman用户身份调用Oracle数据库提供的一些函数或过程,所以必须要确保sysman拥有相关的权限。这也是配置中一般会出问题的地方。

须要注意的是emca首先以sys身份创建sysman账户。然后以sysman账户进行兴许对象的创建。然后这两者之间是连续的,没有给我们改动sysman权限的机会。所以我们要在执行emca之前把sysman须要的权限赋予public账户,这样当sysman账户被创建后自己主动就会有相应的权限了。

那么到底须要赋予sysman那些权限呢?答案是非常多。我的方法是,首先执行emca,假设权限有问题emca就会爆粗,然后依据错误日志找到缺少的权限。之后把这个权限赋给public,然后emca -repos recreate。

以下给出一个排错的样例:

[oracle@db001 ~]$ emca -repos recreate;

STARTED EMCA at Jul 10, 2014 4:18:24 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: xgdb
Listener port number: 1521
Password for SYS user:
Password for SYSMAN user:
Password for SYSMAN user:
Do you wish to continue? [yes(Y)/no(N)]: y
Jul 10, 2014 4:18:37 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /oracle/cfgtoollogs/emca/xgdb/emca_2014_07_10_16_18_24.log.
Jul 10, 2014 4:18:37 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...
Jul 10, 2014 4:19:44 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Jul 10, 2014 4:19:44 PM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Jul 10, 2014 4:21:53 PM oracle.sysman.emcp.EMReposConfig invoke
SEVERE: Error creating the repository
Jul 10, 2014 4:21:53 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Refer to the log file at /oracle/cfgtoollogs/emca/xgdb/emca_repos_create_<date>.log for more details.
Jul 10, 2014 4:21:53 PM oracle.sysman.emcp.EMConfig perform
SEVERE: Error creating the repository
Refer to the log file at /oracle/cfgtoollogs/emca/xgdb/emca_2014_07_10_16_18_24.log for more details.
Could not complete the configuration. Refer to the log file at /oracle/cfgtoollogs/emca/xgdb/emca_2014_07_10_16_18_24.log for more details.

上面是一个出错的样例,从红色部分看出,创建数据失败,依据提供的信息。查看日志文件:

313 Jul 10, 2014 4:19:44 PM oracle.sysman.emcp.EMReposConfig createRepository
314 CONFIG: Spooling to /oracle/cfgtoollogs/emca/xgdb/emca_repos_create_2014_07_10_16_19_44.log
315 Jul 10, 2014 4:19:44 PM oracle.sysman.emcp.EMReposConfig createRepository
316 INFO: Creating the EM repository (this may take a while) ...
317 Jul 10, 2014 4:21:53 PM oracle.sysman.emcp.EMReposConfig createRepository
318 CONFIG: ORA-04063: package body "SYSMAN.MGMT_LOGIN_ASSISTANT" has errors
319 ORA-06508: PL/SQL: could not find program unit being called:

这里已经能看出大概的错误是SYSMAN.MGMT_LOGIN_ASSISTANT这个包编译有问题了,为了获取具体错误,继续查看提示的日志文件。

PL/SQL procedure successfully completed.

Commit complete.

BEGIN
*
ERROR at line 1:
ORA-04063: package body "SYSMAN.MGMT_LOGIN_ASSISTANT" has errors
ORA-06508: PL/SQL: could not find program unit being called:
"SYSMAN.MGMT_LOGIN_ASSISTANT"

这就能确定确实是这个包的问题了,那么到底为什么这个包编译失败呢?此时,sysman账户已经建立,我们以sysman账户登入sqlplus。然后手动编译这个包。看看错误到底在哪里。

执行 SQL> alter package mgmt_login_assistant compile body;

此时会报错,继续查看出错原因:

SQL> show errors;

显示 函数ENCRYPT invalid。

这说明magmt_login_assistant这个包依赖ENCRYPT函数,而ENCRYPT函数自身有问题。

那么继续看看ENCRYPT函数到底什么问题。

SQL> alter function encrypt compile;

Warning: Function altered with compilation errors.

SQL> show errors;
Errors for FUNCTION ENCRYPT:
9/5 PL/SQL: Statement ignored
10/22 PLS-00201: identifier 'SYS.UTL_I18N' must be declared

可见错误在于ENCRYPT函数依赖于SYS.UTL_I18N这个包,而这个包没有声明。事实上是sysman用户没有执行权限。

找到了错误根源。解决就easy多了,以sys账户登录,然后赋予public角色执行SYS.UTL_I18N这个包的权限。

SQL>  grant execute on UTL_I18N to public;

Grant succeeded.

然后又一次以sysman登录。并编译ENCRYPT函数成功,继续编译MGMT_LOGIN_ASSISTANT也成功了,这说明找到了问题所在。总结一下上面的依赖情况:

SYSMAN.MGMT_LOGIN_ASSISTANT包 < SYSMAN.ENCRYPT函数 < SYS.UTL_I18N包。

然后退出sql,又一次执行 emca -repos recreate。假设还是报错,请依照上面查找问题的思路解决这个问题,直到成功。

[oracle@db001 ~]$ emca -repos recreate;

STARTED EMCA at Jul 10, 2014 4:37:11 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: xgdb
Listener port number: 1521
Password for SYS user:
Password for SYSMAN user: Do you wish to continue? [yes(Y)/no(N)]: y
Jul 10, 2014 4:37:24 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /oracle/cfgtoollogs/emca/xgdb/emca_2014_07_10_16_37_11.log.
Jul 10, 2014 4:37:25 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...
Jul 10, 2014 4:38:28 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Jul 10, 2014 4:38:29 PM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Jul 10, 2014 4:42:47 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully created
Enterprise Manager configuration completed successfully
FINISHED EMCA at Jul 10, 2014 4:42:47 PM

3.2 配置文件布局

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

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

STARTED EMCA at Jul 10, 2014 4:47:43 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: xgdb
Listener port number: 1521
Listener ORACLE_HOME [ /oracle/11.2.0 ]:
Password for SYS user:
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 ................ /oracle/11.2.0 Local hostname ................ localhost
Listener ORACLE_HOME ................ /oracle/11.2.0
Listener port number ................ 1521
Database SID ................ xgdb
Email address for notifications ...............
Outgoing Mail (SMTP) server for notifications ............... -----------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: y
Jul 10, 2014 4:48:05 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /oracle/cfgtoollogs/emca/xgdb/emca_2014_07_10_16_47_43.log.
Jul 10, 2014 4:48:08 PM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
INFO: Uploading configuration data to EM repository (this may take a while) ...
Jul 10, 2014 4:49:06 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Jul 10, 2014 4:49:08 PM oracle.sysman.emcp.util.DBControlUtil configureSoftwareLib
INFO: Software library configured successfully.
Jul 10, 2014 4:49:08 PM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
INFO: Deploying Provisioning archives ...
Jul 10, 2014 4:49:34 PM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
INFO: Provisioning archives deployed successfully.
Jul 10, 2014 4:49:34 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) ...
Jul 10, 2014 4:50:11 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Database Control secured successfully.
Jul 10, 2014 4:50:11 PM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Jul 10, 2014 4:50:29 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Jul 10, 2014 4:50:29 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>>>>>>> The Database Control URL is https://localhost:1158/em <<<<<<<<<<<
Jul 10, 2014 4:50:34 PM oracle.sysman.emcp.EMDBPostConfig invoke
WARNING:
************************ WARNING ************************ Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted. The encryption key has been placed in the file: /oracle/11.2.0/localhost_xgdb/sysman/config/emkey.ora. Please ensure this file is backed up as the encrypted data will become unusable if this file is lost. ***********************************************************
Enterprise Manager configuration completed successfully
FINISHED EMCA at Jul 10, 2014 4:50:34 PM

4 浏览器訪问Database Control

上面配置以后,Database Control已经自己主动启动了。能够使用emctl status dbconsole查看状态。
[oracle@db001 ~]$ 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://localhost:1158/em/console/aboutApplication
Oracle Enterprise Manager 11g is running.
------------------------------------------------------------------
Logs are generated in directory /oracle/11.2.0/localhost_xgdb/sysman/log
[oracle@db001 ~]$

能够使用emctl stop dbconsole 停止Database Control。

能够使用emctl start dbconsole 启动Database Control。
[oracle@db001 ~]$ emctl stop dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved.
https://localhost:1158/em/console/aboutApplication
Stopping Oracle Enterprise Manager 11g Database Control ...
... Stopped.
[oracle@db001 ~]$ emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved.
https://localhost:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ........ started.
------------------------------------------------------------------
Logs are generated in directory /oracle/11.2.0/localhost_xgdb/sysman/log

确保Database Conrol启动后,使用浏览器訪问:https://IP:1158/em就可以。


命令行界面下使用emca安装配置Oracle Database Control实战的更多相关文章

  1. Linux下Kafka单机安装配置方法(图文)

    Kafka是一个分布式的.可分区的.可复制的消息系统.它提供了普通消息系统的功能,但具有自己独特的设计.这个独特的设计是什么样的呢 介绍 Kafka是一个分布式的.可分区的.可复制的消息系统.它提供了 ...

  2. Mysql在windows下的免安装配置步骤和重新安装的步骤

    windows下mysql免安装配置 1. 下载mysql免安装压缩包 下载mysql-5.6.22-winx64.zip 解压到本地D:\mysql-5.6.22-winx64 2. 修改配置文件 ...

  3. Linux下Kafka单机安装配置方法

    Kafka是一个分布式的.可分区的.可复制的消息系统.它提供了普通消息系统的功能,但具有自己独特的设计.这个独特的设计是什么样的呢? 首先让我们看几个基本的消息系统术语: •Kafka将消息以topi ...

  4. CentOS6下Haproxy的安装配置

    Haproxy 是一个开源的负载均衡和反向代理软件,其提供了高可用的网络服务.其一般是应用于web服务,但同时也能为SMTP和终端服务等提供可靠的支持. 1.下载安装haproxy wget ftp: ...

  5. 实验七:Xen环境下cirrOS的安装配置

    实验名称: Xen环境下cirrOS的安装配置 实验环境: 这里的cirrOS和实验六中的busybox的启动方式相同,唯一的区别就是我们使用的cirrOS镜像中,已经包含了根文件系统.内核文件以及r ...

  6. CentOS7下RabbitMQ服务安装配置

    参考文档: CentOS7下RabbitMQ服务安装配置 http://www.linuxidc.com/Linux/2016-03/129557.htm 在linux下安装配置rabbitMQ详细教 ...

  7. Linux环境下NodeJS的安装配置(HelloWorld)

    Linux环境下NodeJS的安装配置(HelloWorld) 最简单的环境安装,测试helloworld.给初学者!! 安装脚本,请仔细阅读逐行执行: #!/bin/bash #检查是否已经安装 r ...

  8. Windows和Centos下Docker的安装配置

    Windows和Centos下Docker的安装配置 windows环境下的安装(win10) 在Windows系统上需要利用toolbox来安装Docker,现在 Docker 有专门的 Win10 ...

  9. CentOS下使用yum安装配置和使用svn

    安装说明 系统环境:CentOS-6.3安装方式:yum install (源码安装容易产生版本兼容的问题)安装软件:系统自动下载SVN软件 检查已安装版本 ? 1 2 3 4 5 6 7 8 9 1 ...

随机推荐

  1. addEventListener和attachEvent二者绑定的执行函数中的this不相同【转载】

    yuanwen http://www.jb51.net/article/32511.htm 写 addEventListener 和 attachEvent 区别的博文不少,不过大部分都把重点放置于前 ...

  2. phpstorm php $post数据为空的原因

    今天拿PHPstoem 写了个PHP的表单插入数据,然后直接在里面一运行,就一直提示什么未定义,其实是因为$_PSOT[] 取不到值. 后面发现原来是直接用phpstorm 运行PHP的话,他会自带端 ...

  3. JMeter基础教程3:脚本录制篇

    对于一些JMeter初学者来说,录制脚本可能是最容易掌握的技能之一.虽然我不建议录制性能脚本(因为录制的脚本比较混乱,必须要通过二次处理才可正常使用),但有时做总比不做要好,是吧?下面我们详细介绍使用 ...

  4. riot.js教程【三】访问DOM元素、使用jquery、mount输入参数、riotjs标签的生命周期

    前文回顾 riot.js教程[二]组件撰写准则.预处理器.标签样式和装配方法 riot.js教程[一]简介 访问DOM元素 你可以通过this.refs对象访问dom元素 而且还有大量的属性简写方式可 ...

  5. Lucene搜索引擎例子demo

    一.导入相应的jar包 KAnalyzer3.2.0Stable.jar lucene-analyzers-3.0.1.jar lucene-core-3.0.1.jar lucene-highlig ...

  6. javaScript属性

    ------------------------------------行内样式------------------------------------ *基本标签html 网页的开始标记head 网 ...

  7. [转载] 高性能IO模型浅析

    转载自http://www.cnblogs.com/fanzhidongyzby/p/4098546.html 服务器端编程经常需要构造高性能的IO模型,常见的IO模型有四种: (1)同步阻塞IO(B ...

  8. [转载] 谷歌技术"三宝"之BigTable

    转载自http://blog.csdn.net/opennaive/article/details/7532589 2006年的OSDI有两篇google的论文,分别是BigTable和Chubby. ...

  9. Python之程序执行时间计算

    import datetime starttime = datetime.datetime.now() #long running endtime = datetime.datetime.now() ...

  10. 前端设计师如何提高UI界面中的阅读性

    阅读体验是ui设计中必不可少的一项,良好的设计应该都是可读的设计,如果信息都无法正常而清晰的传达,那么设计就失去了意义.设计的可读性和排版设计息息相关,这也就跟设计师的设计功底息息相关.下面简单介绍文 ...