使用emca命令列配置EM並通過瀏覽器訪問EM示例

還不算暈發表於2013-11-15
EM是Oracle Enterprise Manager簡稱,本文涉及操作及命令:
配置EM-建立刪除重建:    emca -config dbcontrol db -repos recreate|drop|create
啟動、關閉、檢視EM狀態     emctl start|stop|status dbconsole
環境:OEL5.7,ORACLE 11.2.0.4,VBOX虛擬機器
配置EM前檢查事項:1.確定監聽已經啟動並正常執行,2.檢查主機名 3.檢查主機名與IP對應已經寫入/etc/hosts,4.密碼檔案進行確認無誤,5.檢查EM需要用到的三個使用者:SYS DBSNMP,SYSMAN的密碼以及是否能登陸,6.可以提前將 $ORACLE_HOSTNAME變數(與主機名一致即可)寫入.bash_profile.這個引數不寫有時也可以,保險起見還是寫上吧。7.可使用SYS使用者通過服務名登陸資料庫測試一下。

1.環境檢查步驟-檢查結果類似以下即可:

[oracle@bys3 admin]$ lsnrctl status   監聽狀態正常
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 16-NOV-2013 22:34:50
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bys3.bys.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                15-NOV-2013 12:26:43
Uptime                    1 days 10 hr. 8 min. 6 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/diag/tnslsnr/bys3/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bys3.bys.com)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "bys3" has 1 instance(s).
  Instance "bys3", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@bys3 admin]$ cat /etc/hosts   IP與主機名對應無誤
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               bys3.bys.com bys3
::1             localhost6.localdomain6 localhost6
192.168.1.211   bys3.bys.com
檢視已經註冊的資訊:select comp_name from dba_registry;
[oracle@bys3 dbhome_1]$ cd network/admin/
[oracle@bys3 admin]$ ls
listener.ora  samples  shrept.lst  tnsnames.ora
[oracle@bys3 admin]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin
[oracle@bys3 admin]$ cat tnsnames.ora  
bys3 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = bys3)
    )
  )
[oracle@bys3 dbs]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@bys3 dbs]$ ls ora*   密碼檔案格式正常
orapwbys3
[oracle@bys3 admin]$ sqlplus sys/oraclesys@bys3 as sysdba  使用服務名可以正常登陸--可驗證密碼是否正確、監聽、TNSNAMES.ORA是否正常
SQL*Plus: Release 11.2.0.4.0 Production on Sat Nov 16 22:38:17 2013
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@ bys3>conn bys/bys@bys3
Connected.
BYS@ bys3>exit
[oracle@bys3 ~]$ cat .bash_profile   --增加ORACLE_HOSTNAME環境變數,只擷取兩條
ORACLE_HOSTNAME=bys3.bys.com
export ORACLE_HOSTNAME
[oracle@bys3 ~]$ hostname
bys3.bys.com
[oracle@bys3 ~]$ echo $ORACLE_HOSTNAME
bys3.bys.com
BYS@ bys3>select username,account_status from dba_users;
USERNAME                       ACCOUNT_STATUS
------------------------------ --------------------------------
BYS                            OPEN
MGMT_VIEW                      OPEN
SYS                            OPEN
SYSTEM                         OPEN
DBSNMP                         OPEN
SYSMAN                         OPEN
OUTLN                          EXPIRED & LOCKED
DIP                            EXPIRED & LOCKED
ORACLE_OCM                     EXPIRED & LOCKED
APPQOSSYS                      EXPIRED & LOCKED
10 rows selected.
BYS@ bys3>conn dbsnmp/oraclesys    --測試下使用者的密碼是否正確使用者是否已經解鎖。
Connected.
DBSNMP@ bys3>conn system/oraclesys
Connected.
SYSTEM@ bys3>conn sysman/oraclesys     --測試下使用者的密碼是否正確使用者是否已經解鎖。
Connected.
##########################################################################

2.通過emca來配置EM的相關引數

開始執行重建EM操作:
[oracle@bys3 ~]$ emca -config dbcontrol db -repos recreate     如果已經存在有EM,用recreate 關鍵字。

STARTED EMCA at Nov 14, 2013 4:25:58 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: bys3        ---例項名
Listener port number: 1521     ---監聽執行的埠
Listener ORACLE_HOME [ /u01/app/oracle/product/11.2.0/dbhome_1 ]:       ---這裡是ORACLE_HOME的值,確認不誤直接回車就行
Password for SYS user:                                          ---SYS使用者的密碼
Password for DBSNMP user:  
Password for SYSMAN user:  
Email address for notifications (optional):                    --EMAIL可以不填寫,應該是用來傳送報警資訊的。
Outgoing Mail (SMTP) server for notifications (optional):
-----------------------------------------------------------------
You have specified the following settings
Database ORACLE_HOME ................ /u01/app/oracle/product/11.2.0/dbhome_1
Local hostname ................ bys3.bys.com
Listener ORACLE_HOME ................ /u01/app/oracle/product/11.2.0/dbhome_1
Listener port number ................ 1521
Database SID ................ bys3
Email address for notifications ...............
Outgoing Mail (SMTP) server for notifications ...............
-----------------------------------------------------------------
----------------------------------------------------------------------
WARNING : While repository is dropped the database will be put in quiesce mode.
----------------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: y                          ---這裡確認上面彙總資訊無誤後輸入:Y,就開始配置了,需要幾分鐘時間。
Nov 14, 2013 4:27:04 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u01/cfgtoollogs/emca/bys3/emca_2013_11_14_16_25_58.log.  EM建立時的日誌位置
Nov 14, 2013 4:27:06 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...       刪除EM
Nov 14, 2013 4:27:09 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Nov 14, 2013 4:27:09 PM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...   建立EM用時3分鐘
Nov 14, 2013 4:31:17 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully created
Nov 14, 2013 4:31:24 PM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
INFO: Uploading configuration data to EM repository (this may take a while) ...     更新註冊資訊吧,用時兩分鐘
Nov 14, 2013 4:33:09 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Nov 14, 2013 4:33:15 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) ...
Nov 14, 2013 4:33:56 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Database Control secured successfully.
Nov 14, 2013 4:33:56 PM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Nov 14, 2013 4:35:19 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Nov 14, 2013 4:35:20 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>>>>>>> The Database Control URL is https://bys3.bys.com:1158/em <<<<<<<<<<<
Nov 14, 2013 4:35:43 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/dbhome_1/bys3.bys.com_bys3/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                  --可以看到這條語句,表明EM配置成功
FINISHED EMCA at Nov 14, 2013 4:35:43 PM
##########################################################################

3.檢視EM狀態

[oracle@bys3 ~]$ emctl status dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
https://bys3.bys.com:1158/em/console/aboutApplication
Oracle Enterprise Manager 11g is not running.
------------------------------------------------------------------
Logs are generated in directory /u01/app/oracle/product/11.2.0/dbhome_1/bys3.bys.com_bys3/sysman/log

4.啟動EM

啟動EM成功後一般還需要以下兩條設定就可以通過瀏覽器訪問:--通過瀏覽器訪問EM截圖見最後的圖。
1.需要關閉相應防火牆,如通過域名訪問則需要配置相應的條目。
2.啟動監聽並確認例項已經註冊進監聽,因為EM是通過監聽連線到例項的。
--監聽就不演示了,詳細參考:http://blog.csdn.net/q947817003/article/category/1617485
[oracle@bys3 ~]$ emctl status dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
https://bys3.bys.com:1158/em/console/aboutApplication
Oracle Enterprise Manager 11g is not running.
------------------------------------------------------------------
Logs are generated in directory /u01/app/oracle/product/11.2.0/dbhome_1/bys3.bys.com_bys3/sysman/log
[oracle@bys3 ~]$ emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
https://bys3.bys.com:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ......... started.
------------------------------------------------------------------
Logs are generated in directory /u01/app/oracle/product/11.2.0/dbhome_1/bys3.bys.com_bys3/sysman/log

5.停止EM

[oracle@bys3 ~]$ emctl stop dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
https://bys3.bys.com:1158/em/console/aboutApplication

Stopping Oracle Enterprise Manager 11g Database Control ... ...  Stopped.         

6.使用瀏覽器訪問監聽截圖

相關文章