解决Oracle的EM无法启动
启动EM,提示localhost_oracledb not found.
[oracle@oracledb ~]$ emctl start dbconsole
EM Configuration issue. /app/oracle/product/11.2.0/db_1/localhost_oracledb not found.
只好重新配置EM
(1)重新创建em资料库
需输入数据库SID,sys、sysman密码。
[oracle@oracledb ~]$ emca -repos recreate
STARTED EMCA at Oct 31, 2021 1:14:56 AM
EM Configuration Assistant, Version 11.2.0.3.0 Production
Copyright (c) 2003, 2011, Oracle. All rights reserved.
Enter the following information:
Database SID: oracledb
Listener port number: 1521
Password for SYS user:
Password for SYSMAN user:
----------------------------------------------------------------------
WARNING : While repository is dropped the database will be put in quiesce mode.
----------------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: y
Oct 31, 2021 1:15:22 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /app/oracle/cfgtoollogs/emca/oracledb/emca_2021_10_31_01_14_56.log.
Oct 31, 2021 1:15:23 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...
Oct 31, 2021 1:17:08 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Oct 31, 2021 1:17:09 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Oct 31, 2021 1:23:29 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully created
Enterprise Manager configuration completed successfully
FINISHED EMCA at Oct 31, 2021 1:23:29 AM
(2)配置数据库
SYSMAN 和 DBSNMP 帐号的初始密码为: oem_temp
email可选项直接回车。过程需要等待一会。
[oracle@oracledb ~]$ emca -config dbcontrol db
STARTED EMCA at Oct 31, 2021 1:35:17 AM
EM Configuration Assistant, Version 11.2.0.3.0 Production
Copyright (c) 2003, 2011, Oracle. All rights reserved.
Enter the following information:
Database SID: oracledb
Listener port number: 1521
Listener ORACLE_HOME [ /app/oracle/product/11.2.0/db_1 ]: Y
Password for SYS user:
Password for DBSNMP user:
Oct 31, 2021 1:36:18 AM oracle.sysman.emcp.util.GeneralUtil initSQLEngineLoacly
WARNING: ORA-28000: the account is locked
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 ................ /app/oracle/product/11.2.0/db_1
Local hostname ................ localhost
Listener ORACLE_HOME ................ Y
Listener port number ................ 1521
Database SID ................ oracledb
Email address for notifications ...............
Outgoing Mail (SMTP) server for notifications ...............
-----------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: y
Oct 31, 2021 1:36:45 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /app/oracle/cfgtoollogs/emca/oracledb/emca_2021_10_31_01_35_16.log.
Oct 31, 2021 1:36:51 AM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
INFO: Uploading configuration data to EM repository (this may take a while) ...
Oct 31, 2021 1:38:25 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Oct 31, 2021 1:38:26 AM oracle.sysman.emcp.ParamsManager getLocalListener
WARNING: Error retrieving listener for localhost
Oct 31, 2021 1:38:27 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) ...
Oct 31, 2021 1:38:35 AM oracle.sysman.emcp.util.PlatformInterface executeCommand
WARNING: Error executing /app/oracle/product/11.2.0/db_1/bin/emctl secure dbconsole -host localhost -sid oracledb
Oct 31, 2021 1:38:35 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
WARNING: Error securing Database control.
Oct 31, 2021 1:38:35 AM oracle.sysman.emcp.EMDBPostConfig setWarnMsg
INFO: 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) /app/oracle/product/11.2.0/db_1/bin/emctl stop dbconsole
3) /app/oracle/product/11.2.0/db_1/bin/emctl config emkey -repos -sysman_pwd < Password for SYSMAN user >
4) /app/oracle/product/11.2.0/db_1/bin/emctl secure dbconsole -sysman_pwd < Password for SYSMAN user >
5) /app/oracle/product/11.2.0/db_1/bin/emctl start dbconsole
To secure Em Key, run /app/oracle/product/11.2.0/db_1/bin/emctl config emkey -remove_from_repos -sysman_pwd < Password for SYSMAN user >
Oct 31, 2021 1:38:35 AM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Oct 31, 2021 1:38:41 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Oct 31, 2021 1:38:42 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>>>>>>> The Database Control URL is http://localhost:1158/em <<<<<<<<<<<
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) /app/oracle/product/11.2.0/db_1/bin/emctl stop dbconsole
3) /app/oracle/product/11.2.0/db_1/bin/emctl config emkey -repos -sysman_pwd < Password for SYSMAN user >
4) /app/oracle/product/11.2.0/db_1/bin/emctl secure dbconsole -sysman_pwd < Password for SYSMAN user >
5) /app/oracle/product/11.2.0/db_1/bin/emctl start dbconsole
To secure Em Key, run /app/oracle/product/11.2.0/db_1/bin/emctl config emkey -remove_from_repos -sysman_pwd < Password for SYSMAN user >
[oracle@oracledb ~]$
(3)开机启动项
在/etc/rc.local增加su - oracle -c ‘emctl start dbconsole’,设置开机启动,如下所示:
[root@oracledb ~]# cat /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
su - oracle -c 'dbstart'
su - oracle -c 'lsnrctl start'
su - oracle -c 'emctl start dbconsole'
(4)日常管理
- 手工启动em
先设置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
(5) 常用命令
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的端口,默认端口在1158
emctl start console启动EM console服务,使用前需要先设置ORACLE_SID环境变量
emctl stop console停止EM console服务,使用前需要先设置ORACLE_SID环境变量