命令列介面下使用emca安裝配置Oracle Database Control實戰____Oracle

來源:互聯網
上載者:User

http://blog.csdn.net/smstong/article/details/37659397



作為命令列忠實使用者,伺服器端軟體的營運都傾向於使用命令或 指令碼完成,非常討厭資源佔用很大的GUI。Oracle資料庫作為重要的伺服器端軟體,其安裝營運自然也完全支援純命令列方式,儘管同時提供了OUI這個GUI安裝程式。至於純命令列下靜默安裝Oracle11g,本人之前寫過詳細的博文,有需要的請參考之,博文地址http://blog.csdn.net/smstong/article/details/7352036。按照這篇博文安裝的資料庫完全可用。本文算是對前面這篇博文的一個補充,就是在資料庫安裝完成的基礎上安裝配置Oracle Enterprise Manager,使得管理員在厭倦單純sqlplus的情況下,可以使用瀏覽器來管理Oracle資料庫。 1 Oracle Enterprise Manager與Oracle Database Control

OEM是一個統稱,是Oracle提供的圖形化企業級管理工具的統稱。具體有三種可用的工具:

(1)Database Control

它用於管理一個資料庫(可以是RAC叢集資料庫),具有即時管理和監視的功能,運行調度作業功能,警示功能。

(2)Application Server Control

用於管理一個或者多個應用伺服器執行個體。

(3)Grid Control

Grid Control可以管理多個資料庫和應用伺服器,還可以管理電腦節點,支援通過第三方外掛程式管理第三方產品。


在Oracle9i以及之前,OEM是以C/S架構出現的,從10g開始,使用B/S架構,使得管理員無需安裝用戶端即可直接通過瀏覽器進行管理。本文專註於Database Control這個工具,Database Control無需單獨安裝,在安裝oracle的時候,它是自動一起安裝的,但是必須經過仔細的配置才能使用。 2 Oracle Database Control 目錄結構與工作原理 分析任何軟體都需要從靜態和動態兩個方面著手,靜態對應的是軟體安裝後的物理目錄和檔案布局;動態對應的是軟體運行時各個部分之間的互動過程和記憶體布局。 2.1 目錄結構

Database Control在10g和11g中的目錄結構有細微差異,本文以11g為基礎說明。


在安裝完oracle 11g之後,$ORACLE_HOME目錄下會有專門為Database Control提供服務的目錄,如上圖所示。其中oc4j是oracle container for j2ee的縮寫,是oracle專用的j2ee容器與tomcat類似。 2.2 工作原理 從本質上說,Database Control本身就是一個j2EE應用,只是這個應用的功能很單一,就是管理Oracle資料庫。它運行在oracle為其定製的j2EE容器中,使用其管理的oracle資料庫來存放自身資料,使用代理進程來收集資料庫之外的系統資訊。
單純從程式角度來說,Database Control其實本身與其管理的oracle資料庫(稱之為目標資料庫)並無關聯,完全可以使用單獨的資料庫(如單獨的oracle資料庫或者mysql資料庫)來存放自身資料,也可以運行在單獨機器的符合j2EE標準的容器中(如Tomcat)。但是Oracle公司考慮到效率和配置,為其定製了專門的容器,並且本身使用目標資料庫來存放管理資料,而且運行在目標資料庫執行個體所在的機器上。
Database Control的工作原理如下圖所示。


Database Control自身使用的管理資料都存放到SYSMAN這個模式下。

瞭解了工作原理,其配置就容易理解了。與部署其他的j2EE程式一樣,需要從資料和程式檔案兩個方面進行。從本質上說,所有這些操作都可以通過手工來一一完成,但是無論是建立大量的設定檔還是建立大量的資料表,純手工方式都會很低效,也容易出錯。所以Oracle公司為部署Database Control提供了專門的工具軟體。


如果使用OUI來安裝Oracle可以在安裝階段配置Database Control,在安裝完成後還可以通過DBCA來配置,這些都是好用的GUI工具,但是本文的目的是在純命令列下進行配置,所以上述方式不可用。


為了應對命令列模式下的配置,ORACLE公司為Database Control專門提供了配置助手emca(Enterprise manager Configuration Assistant)。 3 使用EMCA配置Database Control 3.1 配置資料

使用的命令是: emca -repos create

它的作用是為Database Control在資料庫中建立必要的使用者(模式)(sysman, dbsnmp等)和模式對象(預存程序,表,索引等等)。emca本身是一個指令檔,最終調用的是java程式來完成實際的工作。由於在建立對象的過程中,需要以sysman使用者身份調用Oracle資料庫提供的一些函數或過程,所以必須要確保sysman擁有相關的許可權。這也是配置中通常會出問題的地方。


需要注意的是emca首先以sys身份建立sysman賬戶,然後以sysman賬戶進行後續對象的建立。然後這兩者之間是連續的,沒有給我們修改sysman許可權的機會。所以我們要在運行emca之前把sysman需要的許可權賦予public賬戶,這樣當sysman賬戶被建立後自動就會有相應的許可權了。


那麼到底需要賦予sysman那些許可權呢。答案是很多。我的方法是,首先運行emca,如果許可權有問題emca就會爆粗,然後根據錯誤記錄檔找到缺少的許可權,之後把這個許可權賦給public,然後emca -repos recreate。

下面給出一個排錯的例子:

[plain]  view plain copy [oracle@db001 ~]$ emca -repos recreate;      STARTED EMCA at Jul 10, 2014 4:18:24 PM   EM Configuration Assistant, Version 11.2.0.0.2 Production   Copyright (c) 2003, 2005, Oracle.  All rights reserved.      Enter the following information:   Database SID: xgdb   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   Jul 10, 2014 4:18:37 PM oracle.sysman.emcp.EMConfig perform   INFO: This operation is being logged at /oracle/cfgtoollogs/emca/xgdb/emca_2014_07_10_16_18_24.log.   Jul 10, 2014 4:18:37 PM oracle.sysman.emcp.EMReposConfig invoke   INFO: Dropping the EM repository (this may take a while) ...   Jul 10, 2014 4:19:44 PM oracle.sysman.emcp.EMReposConfig invoke   INFO: Repository successfully dropped   Jul 10, 2014 4:19:44 PM oracle.sysman.emcp.EMReposConfig createRepository   INFO: Creating the EM repository (this may take a while) ...   Jul 10, 2014 4:21:53 PM oracle.sysman.emcp.EMReposConfig invoke   SEVERE: Error creating the repository   Jul 10, 2014 4:21:53 PM oracle.sysman.emcp.EMReposConfig invoke   INFO: Refer to the log file at /oracle/cfgtoollogs/emca/xgdb/emca_repos_create_<date>.log for more details.   Jul 10, 2014 4:21:53 PM oracle.sysman.emcp.EMConfig perform   SEVERE: Error creating the repository   Refer to the log file at /oracle/cfgtoollogs/emca/xgdb/emca_2014_07_10_16_18_24.log for more details.   Could not complete the configuration. Refer to the log file at /oracle/cfgtoollogs/emca/xgdb/emca_2014_07_10_16_18_24.log for more details.  
上面是一個出錯的例子,從紅色部分看出,建立資料失敗,根據提供的資訊,查看記錄檔:

[plain]  view plain copy 313 Jul 10, 2014 4:19:44 PM oracle.sysman.emcp.EMReposConfig createRepository   314 CONFIG: Spooling to /oracle/cfgtoollogs/emca/xgdb/emca_repos_create_2014_07_10_16_19_44.log   315 Jul 10, 2014 4:19:44 PM oracle.sysman.emcp.EMReposConfig createRepository   316 INFO: Creating the EM repository (this may take a while) ...   317 Jul 10, 2014 4:21:53 PM oracle.sysman.emcp.EMReposConfig createRepository   318 CONFIG: ORA-04063: package body "SYSMAN.MGMT_LOGIN_ASSISTANT" has errors   319 ORA-06508: PL/SQL: could not find program unit being called:   這裡已經能看出大概的錯誤是SYSMAN.MGMT_LOGIN_ASSISTANT這個包編譯有問題了,為了擷取詳細錯誤,繼續查看提示的記錄檔。

[plain]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.