0
点赞
收藏
分享

微信扫一扫

使用emca命令行配置EM并通过浏览器访问EM示例

艾米吖 2023-07-24 阅读 63


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    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是通过监听连接到实例的。--监听就不演示了,详细参考:

 [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.使用浏览器访问监听截图



举报

相关推荐

0 条评论