Oracle 11g r2自带OEM
OEM常用的命令语法:
emctl start console 启动EM console服务,使用前需要先设置ORACLE_SID环境变量
emctl stop console 停止EM console服务,使用前需要先设置ORACLE_SID环境变量
emctl status console 查看EM console服务状态,使用前需要先设置ORACLE_SID环境变量
emca -repos create创建一个EM资料库
emca -repos recreate重建一个EM资料库
emca -repos drop删除一个EM资料库
emca -config dbcontrol db配置数据库的 Database Control
emca -deconfig dbcontrol db删除数据库的 Database Control配置
emca -reconfig ports 重新配置db control和agent的端口
注:通过查看$ORACLE_HOME/install/portlist.ini 文件可以知道当前dbcontrol正在使用的端口,默认dbcontrol http端口1158,agent端口3938。如果要重新配置端口,可以使用如下命令:
emca -reconfig ports -dbcontrol_http_port 1159
emca -reconfig ports -agent_port 3939
使用命令行工具emctl可以启动/停止console服务,察看服务状态等。
我们看下11g r2第一次使用OEM的步骤:
首先看下oem状态:
[oracle@nc65tst02-was-slave-oracle ~]$ emctl status dbconsole
Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name.
需要设置环境变量ORACLE_UNQNAME:
vi ~/.bash_profile
在最后添加:export ORACLE_UNQNAME=$ORACLE_SID
[oracle@nc65tst02-was-slave-oracle ~]$ emctl status dbconsole
OC4J Configuration issue. /u01/app/oracle/product/11.2.0/dbhome_1/oc4j/j2ee/OC4J_DBConsole_nnntst02-was-slave-oracle.mycom.com_orcl not found.
对于上面报错,需要做下配置:
emca -config dbcontrol db
Enter the following information:
Database SID: orcl
Listener port number: 1521
Listener ORACLE_HOME [ /u01/app/oracle/product/11.2.0/dbhome_1 ]:
......
Do you wish to continue? [yes(Y)/no(N)]: Y
.........
Error securing Database Control. Database Control has been brought-up in non-secure mode. To secure the Database Control execute the following command(s):
1) Set the environment variable ORACLE_UNQNAME to Database unique name
2) /u01/app/oracle/product/11.2.0/dbhome_1/bin/emctl stop dbconsole
3) /u01/app/oracle/product/11.2.0/dbhome_1/bin/emctl config emkey -repos -sysman_pwd < Password for SYSMAN user >
4) /u01/app/oracle/product/11.2.0/dbhome_1/bin/emctl secure dbconsole -sysman_pwd < Password for SYSMAN user >
5) /u01/app/oracle/product/11.2.0/dbhome_1/bin/emctl start dbconsole
To secure Em Key, run /u01/app/oracle/product/11.2.0/dbhome_1/bin/emctl config emkey -remove_from_repos -sysman_pwd < Password for SYSMAN user >
再次查看状态,成功:
[oracle@nc65tst02-was-slave-oracle ~]$ emctl status dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0
Copyright (c) 1996, 2013 Oracle Corporation. All rights reserved.
http://nc65tst02-was-slave-oracle.yonyou.com:1158/em/console/aboutApplication
EM Daemon is not running.
------------------------------------------------------------------
Logs are generated in directory /u01/app/oracle/product/11.2.0/dbhome_1/nnntst02-was-slave-oracle.mycom.com_orcl/sysman/log
打开浏览器,输入URL: http://192.168.228.129:1158/em
用任意数据库用户密码登录即可: