4.5 使用EM管理实例
从Oracle 10g开始,Oracle提供了网页形式的管理工具,叫做Database Control。我们可以在使用dbca创建数据库时,指定安装Database Control;也可以在安装完数据库以后,通过调用emca来创建Database Control。
使用emca时,先调用emca -repos create来创建repository,所谓repository就是存放Database Control在管理数据库所用到的信息的多个表,如下所示。
[oracle@book ~]$ emca -repos create STARTED EMCA at Sep 4, 2007 5:06:42 PM EM Configuration Assistant, Version 10.2.0.1.0 Production Copyright (c) 2003, 2005, Oracle. All rights reserved. Enter the following information: Database SID: ora10g 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 Sep 4, 2007 5:06:53 PM Oracle.sysman.emcp.EMConfig perform ...... Enterprise Manager configuration completed successfully FINISHED EMCA at Sep 4, 2007 5:12:17 PM
在创建repository时,上面粗体显示的部分是要我们输入的信息,包括SID、监听器所监听的端口号、用户sys和用户sysman(用户sysman是repository的属主)的密码,并让我们确定创建repository。创建repository完毕以后,调用emca -config dbcontrol db命令来创建Database Control。
[oracle@book ~]$ emca -config dbcontrol db STARTED EMCA at Sep 4, 2007 5:13:16 PM EM Configuration Assistant, Version 10.2.0.1.0 Production Copyright (c) 2003, 2005, Oracle. All rights reserved. Enter the following information: Database SID: ora10g Listener port number: 1521 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 ...... ----------------------------------------------------------------- Do you wish to continue? [yes(Y)/no(N)]: y Sep 4, 2007 5:13:39 PM Oracle.sysman.emcp.EMConfig perform ...... Enterprise Manager configuration completed successfully FINISHED EMCA at Sep 4, 2007 5:15:58 PM
如果要重建Database Control,则先使用emca -deconfig dbcontrol db命令删除配置:
[oracle@book ~]$ emca -deconfig dbcontrol db STARTED EMCA at Sep 4, 2007 5:00:09 PM EM Configuration Assistant, Version 10.2.0.1.0 Production Copyright (c) 2003, 2005, Oracle. All rights reserved. Enter the following information: Database SID: prod Do you wish to continue? [yes(Y)/no(N)]: yes …… Enterprise Manager configuration completed successfully FINISHED EMCA at Sep 5, 2007 5:00:46 PM
然后使用emca -repos drop命令删除repository:
[oracle@ocm ~]$ emca -repos drop STARTED EMCA at Sep 4, 2007 5:01:10 PM EM Configuration Assistant, Version 10.2.0.1.0 Production Copyright (c) 2003, 2005, Oracle. All rights reserved. Enter the following information: Database SID: prod Listener port number: 1521 Password for SYS user: Password for SYSMAN user: Do you wish to continue? [yes(Y)/no(N)]: y …… Enterprise Manager configuration completed successfully FINISHED EMCA at Sep 5, 2007 5:05:19 PM
全部配置删除完毕以后,再次执行创建Database Contorl的命令即可。安装完Database Control以后,我们就可以开始使用它了。
启动Database Control的命令如下所示:
[oracle@book ~]$ emctl start dbconsole TZ set to PRC Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0 Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved. http://book.us.oracle.com:1158/em/console/aboutApplication Starting Oracle Enterprise Manager 10g Database Control ........................ started. ------------------------------------------------------------------ Logs are generated in directory /u01/app/oracle/product/10.2.0/db_1/book.us.Oracle.com_ ora10g/sysman/log
关闭Database Control的命令如下所示:
[oracle@book ~]$ emctl stop dbconsole TZ set to PRC Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0 Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved. http://book.us.oracle.com:1158/em/console/aboutApplication Stopping Oracle Enterprise Manager 10g Database Control ... ... Stopped.
查看Database Control状态的命令如下所示:
[oracle@book ~]$ emctl status dbconsole TZ set to PRC Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0 Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved. http://book.us.oracle.com:1158/em/console/aboutApplication Oracle Enterprise Manager 10g is running. ------------------------------------------------------------------ Logs are generated in directory /u01/app/oracle/product/10.2.0/db_1/book.us.Oracle.com_ ora10g/sysman/log
默认情况下,Database Control的访问路径为http://主机名:1158/em。其中1158为端口号。登录界面如图4-1所示。
图4-1 Database Control登录界面
单击“Login”按钮以后,进入数据库的主页,如图4-2所示。
在主页上,名为Performance的标签页上包含对数据库性能进行监控的方法;名为Administration的标签页上包含管理数据库相关的方法;名为Maintenance的标签页上包含对数据库进行备份或恢复操作的方法。
图4-2 Database主页
图4-3 其他属性页接口