◎ 劉 波,李留亮
(中糧工程科技(鄭州)有限公司,河南 鄭州 450053)
在某糧庫管理信息系統(tǒng)的開發(fā)過程中,Oracle數(shù)據(jù)庫常會因各種情況出現(xiàn)Enterprise Manager配置失敗的問題。本文主要論述該問題的解決辦法和在Enterprise Manager配置過程中常用的命令。
在本項目中,服務(wù)器的操作系統(tǒng)為Windows 2008 X64 Server SP2標準版,數(shù)據(jù)庫的版本為Oracle 10.2.0.1.0。在對數(shù)據(jù)庫的安裝和管理過程中經(jīng)常會出現(xiàn)以下錯誤信息:
“由于以下錯誤,Enterprise Manager配置失敗
啟動Database Control時出錯
有關(guān)詳細資料,請參閱D:oracleproduct10.2.0db_1cfgtoollogsdbcaoradbemConfig.log中的日志文件
您可以以后通過手動運行D:oracleproduct10.2.0db_1inemca腳本,重新使用Enterprise Manager配置此數(shù)據(jù)庫。”
查詢關(guān)于此問題的解決,并多次給Oracle技術(shù)支持打電話溝通,確定是由于Enterprise Manager Database Control組件和CA證書授權(quán)造成的,當(dāng)安裝此版本的數(shù)據(jù)庫的時間超過CA證書的授權(quán)日期時都會出現(xiàn)該問題,官方的解決方案是打補丁Patch 8350262。具體操作步驟如下。
首先要檢查創(chuàng)建的數(shù)據(jù)庫是否完全打開,步驟如下:
(1)執(zhí)行以下命令: sqlplus / as sysdba,會看到如下顯示:
連接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
如果能登陸數(shù)據(jù)庫,再執(zhí)行以下命令:startup,會看到下面的顯示:
SQL> startup
ORA-01081: 無法啟動已在運行的 ORACLE - 請首先關(guān)閉它
(2)再執(zhí)行以下命令:select * from dual; 會看到下面的顯示:
SQL> select * from dual;
D
X
此時表示數(shù)據(jù)庫能正常訪問。
要關(guān)閉電腦上的防火墻,包括Windows防火墻和安裝的其他防火墻。
然后要停止所有服務(wù),步驟如下:
(1)運行以下命令:emctl stop dbconsole
(2)如果報錯或顯示服務(wù)未運行,在windows任務(wù)管理器中找到進程“java.exe”,選定該進程,并點“結(jié)束進程”按鈕來終止該進程。
按名稱排序,如果有多個java.exe,則全部要終止。
重建Em repository的步驟如下:
(1)emca -deconfig dbcontrol db
不管成功還是失敗,都可以。如果是失敗可能表示在之前配置信息已被刪除。
(2)emca -repos drop
會看到以下信息:
EMCA 開始于 2013-5-12 11:49:46
EM Configuration Assistant, 10.2.0.1.0 正式版
版權(quán)所有 (c) 2003, 2005, Oracle。保留所有權(quán)利。
再輸入以下信息:
數(shù)據(jù)庫 SID:(輸入你要創(chuàng)建數(shù)據(jù)庫的SID)
監(jiān)聽程序端口號:(輸入監(jiān)聽程序的端口號1521)
SYS 用戶的口令:(輸入你想創(chuàng)建的SYS用戶的口令)
SYSMAN 用戶的口令:(輸入你想創(chuàng)建的SYSMAN用戶的口令)
是否繼續(xù)? [是(Y)/否(N)]:輸入Y
2013-5-12 11:51:01 oracle.sysman.emcp. EMConfig perform
信息:正在將此操作記錄到 C:appandyzhangcfgtoollogsemcaTJMISemca_2013_05_111_49_43.log。
2013-5-12 11:51:03oracle.sysman.emcp.ParamsManager checkListenerStatusForDBCorol
警告:初始化 SQL 連接時出錯。無法執(zhí)行SQL操作
2013-5-12 11:51:03 oracle.sysman.emcp.EMReposConfig invoke
信息:正在刪除EM資料檔案庫(此操作可能需要一段時間)...
2013-5-12 11:51:22 oracle.sysman.emcp.EMReposConfig invoke
信息:已成功刪除資料檔案庫
已成功完成 Enterprise Manager 的配置
EMCA結(jié)束于2013-5-12 11:51:22
(3)檢查以下2個目錄及文件是否存在,如果存在進行手動刪除,以防止殘留文件:
%ORACLE_HOME%oc4jj2ee下是否有OC4J_DBConsole_localhost_TJMIS目錄
%ORACLE_HOME%下是否有MISServer2_TJMIS目錄
(1)執(zhí)行以下命令:emca -repos create,會看到以下信息:
EMCA開始于2013-5-12 11:52:15
EM Configuration Assistant, 10.2.0.1.0 正式版
版權(quán)所有(c) 2003, 2005, Oracle。保留所有權(quán)利。
輸入以下信息:
數(shù)據(jù)庫 SID:(輸入你要創(chuàng)建數(shù)據(jù)庫的SID)
監(jiān)聽程序端口號:(輸入監(jiān)聽程序的端口號1521)
SYS 用戶的口令:(輸入你想創(chuàng)建的SYS用戶的口令)
SYSMAN 用戶的口令:(輸入你想創(chuàng)建的SYSMAN用戶的口令)
是否繼續(xù)? [是(Y)/否(N)]:輸入Y
2013-5-12 11:52:29 oracle.sysman.emcp.EMConfig perform
信息: 正在將此操作記錄到C:appandyzhangcfgtoollogsemcaTJMISemca_2013_05_12_11_52_14.log。
2013-5-12 11:52:30 oracle.sysman.emcp.EMReposConfig createRepository
信息:正在創(chuàng)建 EM 資料檔案庫(此操作可能需要一段時間)...
2013-5-12 12:02:15 oracle.sysman.emcp.EMReposConfig invoke
信息:已成功創(chuàng)建資料檔案庫
已成功完成Enterprise Manager的配置
EMCA 結(jié)束于 2013-5-12 12:02:16
(2)執(zhí)行以下命令:emca -config dbcontrol db
這步很關(guān)鍵,因此命令一定要執(zhí)行成功,并且會看到以下信息:
EMCA開始于2013-5-12 12:02:49
EM Configuration Assistant, 10.2.0.1.0正式版
版權(quán)所有(c)2003, 2005, Oracle。保留所有權(quán)利。
輸入以下信息:
數(shù)據(jù)庫SID:(輸入你要創(chuàng)建數(shù)據(jù)庫的SID)
監(jiān)聽程序端口號:(輸入監(jiān)聽程序的端口號1521)
SYS 用戶的口令:(輸入你想創(chuàng)建的SYS用戶的口令)
DBSNMP 用戶的口令:(輸入你想創(chuàng)建的DBSNMP用戶的口令)
SYSMAN 用戶的口令:(輸入你想創(chuàng)建的SYSMAN用戶的口令)
通知的電子郵件地址(可選):
通知的發(fā)件(SMTP)服務(wù)器(可選):
已指定以下設(shè)置
數(shù)據(jù)庫ORACLE_HOME ................ D:oracleproduct10.2.0db_1
本地主機名 ................ localhost
監(jiān)聽程序 ORACLE_HOME ................ D:oracleproduct10.2.0db_1
監(jiān)聽程序端口號 ................ 1521
數(shù)據(jù)庫 SID ................ TJMIS
通知的電子郵件地址 ...............
通知的發(fā)件 (SMTP) 服務(wù)器 ...............
是否繼續(xù)? [是(Y)/否(N)]:輸入Y
2013-5-12 12:03:12 oracle.sysman.emcp.EMConfig perform
信息:正在將此操作記錄到D:oracleproduct10.2.0db_1cfgtoollogsemcaTJMISemca_2013_05_12_02_48.log。
2013-5-12 12:03:28 oracle.sysman.emcp.EMRepos Config uploadConfigDataToRepository
信息:正在將配置數(shù)據(jù)上載到 EM 資料檔案庫 (此操作可能需要一段時間)...
2013-5-12 12:04:57 oracle.sysman.emcp.EMReposConfig invoke
信息:已成功上載配置數(shù)據(jù)
2013-5-12 12:05:20 oracle.sysman.emcp.util.DBControlUtil configureSoftwareLib
信息:軟件庫已配置成功。
2013-5-12 12:05:20 oracle.sysman.emcp.EMDBPost Config configureSoftwareLibrary
信息:正在部署預(yù)配檔案...
2013-5-12 12:07:20 oracle.sysman.emcp.EMDBPost Config configureSoftwareLibrary
信息:預(yù)配檔案部署成功。
2013-5-12 12:07:20 oracle.sysman.emcp.util.DBControlUtil secureDBConsole
信息:正在保護 Database Control (此操作可能需要一段時間)...
2013-5-12 12:07:44 oracle.sysman.emcp.util.DBControlUtil secureDBConsole
信息:已成功保護 Database Control。
2013-5-12 12:07:44 oracle.sysman.emcp.util.DBControlUtil startOMS
信息:正在啟動 Database Control (此操作可能需要一段時間)...
2013-5-12 12:12:03 oracle.sysman.emcp.EMDBPost Config performConfiguration
信息:已成功啟動 Database Control
2013-5-12 12:12:07 oracle.sysman.emcp.EMDBPost Config performConfiguration
信息 ! : >>>>>>> Database Control URL 為 https://localhost:1158/em <<<<<<<<
2013-5-12 12:12:30 oracle.sysman.emcp.EMDBPost Config invoke
警告:
************************ WARNING************************
管理資料檔案庫已置于安全模式下, 在此模式下將對 Enterprise Manager 數(shù)據(jù)進行加密。
加密密鑰已放置在文件D:oracleproduct10.2.0db_1localhost_TJMIS/sysman/config/emkey.ora 中。請務(wù)必備份此文件,因為如果此文件丟失,則加密數(shù)據(jù)將不可用。
***********************************************************
已成功完成Enterprise Manager的配置
EMCA結(jié)束于2013-5-12 12:12:30
檢查是否安裝成功,查看%ORACLE_HOME%oc4jj2ee下是否有OC4J_DBConsole_localhost_TJMIS目錄,執(zhí)行以下命令:
cd %ORACLE_HOME%oc4jj2ee
dir OC4J_DBConsole_localhost_TJMIS
應(yīng)該看到以下信息:
驅(qū)動器C中的卷是System
卷的序列號是3C9A-7D79
D:oracleproduct10.2.0db_1oc4jj2eeOC4J_DBConsole_localhost_ TJMIS 的目錄
2013-05-12 12:05
2013-05-12 12:05
2013-05-12 12:05
2013-05-12 12:08
2013-05-12 12:07
2013-05-12 12:04
2013-05-12 12:08
2013-05-12 12:05
2013-05-12 12:08
2013-05-12 12:08
0個文件 0字節(jié)
10個目錄167,630,336,000可用字節(jié)
(1)把您的補丁解壓到%ORACLE_HOME%OPatch8350262目錄下
(2)進入到%ORACLE_HOME%OPatch8350262目錄
cd %ORACLE_HOME%OPatch8350262
執(zhí)行dir命令,大概會看到以下信息:
C:appandyzhangproduct11.2.0dbhome_1OPatch8350262>dir
驅(qū)動器C中的卷是System
卷的序列號是3C9A-7D79
D:oracleproduct10.2.0db_1OPatch8350262的目錄
2013-05-12&! nbsp; 12:06
2013-05-12 12:06
2013-05-12 12:06
2013-05-12 12:06
2010-10-07 02:46 1,069 killDBConsole
2010-10-07 02:46 4,640 killDBConsole.pl
2010-10-05 07:57 3,278 README.txt
3個文件 8,987字節(jié)
4個目錄 167,824,171,008 可用字節(jié)
(3)先卸載您之前打過的補丁
%ORACLE_HOME%OPatchopatch rollback -id 8350262
(4)再重新安裝一遍
結(jié)束java.exe進程,并執(zhí)行命令:emctl stop dbconsole
然后運行:%ORACLE_HOME%OPatchopatch apply
會看到一些提示,提示安裝成功,請確認,如果有錯誤或警告,請屏幕拷貝或抓圖。
執(zhí)行以下命令:emctl secure dbconsole –reset
會看到以下顯示:
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2007 Oracle Corporation. All rights reserved.
https://myhost:5501/em/console/aboutApplication
Enter Enterprise Manager Root Password :
DBCONSOLE already stopped... Done.
Agent is already stopped... Done.
Securing dbconsole... Started.
Checking Repository... Done.
Checking Em Key... Done.
Checking Repository for an existing Enterprise Manager Root Key...
WARNING! An Enterprise Manager Root Key already exists in the Repository. This operation will replace your Enterprise Manager Root Key.
All existing Agents that use HTTPS will need to be reconfigured if you proceed. Do you wish to continue and overwrite your Root Key
(Y/N) ? 輸入Y
Are you sure ? Reset of the Enterprise Manager Root Key will mean that you will need to reconfigure each Agent that is associated with this OMS before they will be able to upload any data to it. Monitoring of Targets associated with these Agents wi! ll be unavailable until after they are reconfigured.
(Y/N) ? 輸入Y
Generating Enterprise Manager Root Key (this takes a minute)... Done.Fetching Root Certificate fromthe Repository... Done.
Updating HTTPS port in emoms. properties file...Done.
Generating Java Keystore... Done.
Securing OMS ... Done.
Generating Oracle Wallet Password for Agent.... Done.
Generating wallet for Agent ... Done.
Copying the wallet for agent use... Done.
Storing agent key in repository... Done.
Storing agent key for agent ... Done.
Configuring Agent...
Configuring Agent for HTTPS in DBCONSOLE mode...Done.
EMD_URL set in /myhost/myhost/sysman/config/emd.properties
Done.
Configuring Key store.. Done.
Securing dbconsole... Sucessful.
或是:
D:oracleproduct10.2.0db_1oc4jj2ee>emctl secure dbconsole -reset
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
https://localhost:1158/em/console/aboutApplication
Please enter repository password:
********
DBCONSOLE successfully stopped... Done.Agent is already stopped... Done.Securing dbconsole... Started.
Please enter repository schema password:Securing dbconsole... Sucessful.
DBCONSOLE successfully restarted... Done.
執(zhí)行以下命令,啟動Database Control服務(wù):emctl start dbconsole
會看到以下顯示:
D:oracleproduct10.2.0db_1oc4jj2ee>emctl start dbconsole
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
https://localhost:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ...OracleDBConsoleorcl
服務(wù)正在啟動..................
OracleDBConsoleorcl 服務(wù)已經(jīng)啟動成功。
重新確認em頁面是否可以訪問:
https://localhost:1158/em/ 或者http://localhost:1158/em/
這時可以發(fā)現(xiàn)Enterprise Manager已經(jīng)配置成功,可進入OEM。
通過解決Enterprise Manager配置失敗的問題,可以總結(jié)出在Enterprise Manager配置時常用的命令,如下:
emca -config dbcontrol db -repos create 創(chuàng)建em資料庫,并配制Database Control
emca -deconfig dbcontrol db -repos drop 取消配置Database Control,并刪除em資料庫
emca -repos create 創(chuàng)建一個EM資料庫
emca -repos recreate 重建一個EM資料庫
emca -repos drop 刪除一個EM資料庫
emca -config dbcontrol db 配置數(shù)據(jù)庫的 Database Control
emca -deconfig dbcontrol db 刪除數(shù)據(jù)庫的 Database Control配置
emctl start dbconsole 先設(shè)置ORACLE_SID環(huán)境變量后,啟動EM console服務(wù)
emctl stop dbconsole 先設(shè)置ORACLE_SID環(huán)境變量后,停止EM console服務(wù)
emctl status dbconsole 先設(shè)置ORACLE_SID環(huán)境變量后,查看EM console服務(wù)的狀態(tài)
以上方法雖然操作較復(fù)雜,但最終可解決該問題。在用該方法配置時,輸入的命令參數(shù)不正確時常會報錯,且發(fā)生錯誤時要根據(jù)錯誤提示和日志分析錯誤原因,再根據(jù)錯誤原因解決錯誤,才能徹底解決問題。
參考文獻:
[1]路 川,胡欣杰.Oracle 10g寶典[M].北京:電子工業(yè)出版社,2010.