我們在使用Oracle時, 可以利用Oracle自帶的EM(Enterprise Manager)來更方便的管理我們的數據庫。但是有時候我們的em卻有時候無法連接,造成這個問題的原因有好多,例如沒有正確的配置hostname,或者操作系統的防火牆問題等等。如果出現了問題,我們能否快速的重建em呢?答案是肯定的。我們可以通過Oracle官方文檔來參照。但是如果我們對於em裡面如此多的配置命令和選項比較頭大的時候,你就可以參照此文來重新創建EM。
首先需要設置好環境變量ORACLE_HOSTNAME
export ORACLE_HOSTNAME=testbox.localdomain
然後再執行:
emca -config dbcontrol db -repos recreate
如果這個方法不行的話,你可以手動先drop掉你當前的repo
emca -deconfig dbcontrol db -repos drop
然後再重新創建
emca -config dbcontrol db -repos create
此間過程比較長,大概需要十分鐘左右來創建。然後你就可以看到如下提示:
[oracle@testbox j2ee]$ emca -config dbcontrol db -repos create STARTED EMCA at Jul 1, 2014 10:50:24 PM EM Configuration Assistant, Version 11.2.0.3.0 Production Copyright (c) 2003, 2011, Oracle. All rights reserved. Enter the following information: Database SID: erin Listener ORACLE_HOME [ /u01/app/oracle/product/11.2.0/db_1 ]: 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 ................ /u01/app/oracle/product/11.2.0/db_1 Local hostname ................ testbox.localdomain Listener ORACLE_HOME ................ /u01/app/oracle/product/11.2.0/db_1 Listener port number ................ 1521 Database SID ................ erin Email address for notifications ............... Outgoing Mail (SMTP) server for notifications ............... ----------------------------------------------------------------- Do you wish to continue? [yes(Y)/no(N)]: yes Jul 1, 2014 10:50:43 PM oracle.sysman.emcp.EMConfig perform INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/erin/emca_2014_07_01_22_50_24.log. Jul 1, 2014 10:50:44 PM oracle.sysman.emcp.EMReposConfig createRepository INFO: Creating the EM repository (this may take a while) ... Jul 1, 2014 10:55:39 PM oracle.sysman.emcp.EMReposConfig invoke INFO: Repository successfully created Jul 1, 2014 10:55:42 PM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository INFO: Uploading configuration data to EM repository (this may take a while) ... Jul 1, 2014 10:57:43 PM oracle.sysman.emcp.EMReposConfig invoke INFO: Uploaded configuration data successfully Jul 1, 2014 10:57:45 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole INFO: Securing Database Control (this may take a while) ... Jul 1, 2014 10:58:17 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole INFO: Database Control secured successfully. Jul 1, 2014 10:58:17 PM oracle.sysman.emcp.util.DBControlUtil startOMS INFO: Starting Database Control (this may take a while) ... Jul 1, 2014 10:58:44 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration INFO: Database Control started successfully Jul 1, 2014 10:58:44 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration INFO: >>>>>>>>>>> The Database Control URL is https://testbox.localdomain:5500/em <<<<<<<<<<< Jul 1, 2014 10:58:48 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: /u01/app/oracle/product/11.2.0/db_1/testbox.localdomain_erin/sysman/config/emkey.ora. 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 1, 2014 10:58:48 PM
標注的紅色部分就是我們的em的訪問地址。