Oracle … as usual

Oracle by Laurent Leturgez

Monthly Archives: June 2012

Useful emcli commands in EM Cloud Control 12c

If like me, you are addicted to command line, this post will help you to realize useful operation in EM Cloud Control 12c using emcli tool rather than GUI.

You can use emcli when you need to implement batch scripts on your Oracle Management Server (OMS).

  • Login to EM
$ emcli login -username=sysman
Enter password :
Login successful

OR

$ emcli login -username=sysman -password=XXXXXX
Login successful
  • Synchronize emcli with the OMS
$ emcli sync
Synchronized successfully
  • Logout EM
$ emcli logout
Logout successful
  • List all the targets already promoted
$ emcli get_targets
Status  Status           Target Type           Target Name
 ID
-9      n/a              group                 OFM
1       Up               host                  xxxdb-prod3.mydomain.com
1       Up               host                  xxxdb-prod2.mydomain.com
1       Up               host                  xxxlgc-prod2.mydomain.com
1       Up               host                  xxxdb-prod1.mydomain.com
1       Up               j2ee_application      /EMGC_GCDomain/GCDomain/EMGC_OMS1/e
                                               mgc
1       Up               j2ee_application      /EMGC_GCDomain/GCDomain/EMGC_OMS1/O
                                               CMRepeater
1       Up               j2ee_application      /EMGC_GCDomain/GCDomain/EMGC_OMS1/e
                                               mpbs
-9      n/a              metadata_repository   /EMGC_GCDomain/GCDomain/EMGC_ADMINS
                                               ERVER/mds-sysman_mds
-9      n/a              metadata_repository   /EMGC_GCDomain/GCDomain/EMGC_ADMINS
                                               ERVER/mds-owsm
1       Up               oracle_apache         /EMGC_GCDomain/instance1/ohs1
1       Up               oracle_apm            /EMGC_GCDomain/GCDomain/EMGC_OMS1/o
                                               racle.security.apm(11.1.1.3.0)
1       Up               oracle_beacon         EM Management Beacon
1       Up               oracle_em_service     EM Console Service
1       Up               oracle_em_service     EM Jobs Service
1       Up               oracle_emd            xxxdb-prod1.mydomain.com:1830
1       Up               oracle_emd            xxxdb-prod3.mydomain.com:1830
1       Up               oracle_emd            xxxlgc-prod2.mydomain.com:3872
1       Up               oracle_emd            xxxdb-prod2.mydomain.com:1830
1       Up               oracle_emrep          Management Services and Repository
-9      n/a              oracle_home           agent12g1_9_xxxlgc-prod2
-9      n/a              oracle_home           WebLogicServer10_3_5_0_0_xxxlgc-pro
                                               d2
-9      n/a              oracle_home           oms12g1_3_xxxlgc-prod2
-9      n/a              oracle_home           webtier12g1_20_xxxlgc-prod2
-9      n/a              oracle_ias_farm       EMGC_GCDomain
1       Up               oracle_oms            xxxlgc-prod2.mydomain.com:4889_Managem
                                               ent_Service
1       Up               oracle_oms_console    xxxlgc-prod2.mydomain.com:4889_Managem
                                               ent_Service_CONSOLE
1       Up               oracle_oms_pbs        xxxlgc-prod2.mydomain.com:4889_Managem
                                               ent_Service_PBS
-9      n/a              weblogic_domain       /EMGC_GCDomain/GCDomain
1       Up               weblogic_j2eeserver   /EMGC_GCDomain/GCDomain/EMGC_OMS1
1       Up               weblogic_j2eeserver   /EMGC_GCDomain/GCDomain/EMGC_ADMINSERVER
  • Delete a specific target
$ emcli delete_target -name="/wlstest_wlstest/wlstest/myServer_jvm" -type="java_virtual_machine"
  • Delete an agent and its targets
$ emcli delete_target -name="xxxlgc-prod2.mydomain.com:3872" -type="oracle_emd" -delete_monitored_targets
  • Follow a plugin deployment (on the OMS / on an agent)
-- Oracle Database plugin
$ emcli get_plugin_deployment_status -plugin_id=oracle.sysman.db
-- Oracle Fusion Middleware plugin
$ emcli get_plugin_deployment_status -plugin_id=oracle.sysman.emas
-- My Oracle Support plugin
$ emcli get_plugin_deployment_status -plugin_id=oracle.sysman.mos
  • Import an update (for example: a plugin update) into the software library.
$ emcli import_update -file="p14018177_112000_Generic.zip" -omslocal
  • Deploy a plugin on the OMS
$ emcli deploy_plugin_on_server -plugin=oracle.sysman.db -sys_password=XXXXX
  • Deploy a plugin on EM agent(s)
$ emcli deploy_plugin_on_agent -plugin="oracle.sysman.db"  -agent_names="xxxdb-prod1.mydomain.com:3872;xxxdb-prod2.mydomain.com:3872"
  • List available agents in the library
$ emcli get_supported_platforms
Getting list of platforms ...
Check the logs at /home/oracle/agent.log
About to access self-update code path to retrieve the platforms list..
Getting Platforms list ...
-----------------------------------------------
Version = 12.1.0.1.0
 Platform = Linux x86-64
-----------------------------------------------
Version = 12.1.0.1.0
 Platform = Linux x86
-----------------------------------------------
Version = 12.1.0.1.0
 Platform = IBM AIX on POWER Systems (64-bit)
-----------------------------------------------
Version = 12.1.0.1.0
 Platform = Microsoft Windows (32-bit)
-----------------------------------------------
Version = 12.1.0.1.0
 Platform = Microsoft Windows (64-bit)
-----------------------------------------------
Platforms list displayed successfully
  • Download an agent from the library (used for agentDeploy.sh script method)
$ emcli get_agentimage -destination=/home/oracle -platform="Microsoft Windows x64 (64-bit)" -version="12.1.0.1.0"
Platform:Microsoft Windows x64 (64-bit)
Destination:/home/oracle
 === Partition Detail ===
Space free : 11 GB
Space required : 1 GB
Check the logs at /home/oracle/get_agentimage_2012-06-11_15-18-09-PM.log
Setting property ORACLE_HOME to:/u02/Middleware/oms
calling pulloneoffs with arguments:/u02/Middleware/oms/u02/softLibrary/32/C0C9BF40C6A36668E0439D33010AE58512.1.0.1.0windows_x64
Check this logs for more information: /u02/Middleware/oms/sysman/prov/agentpush/logs
  • Set monitoring credentials for a specific target (example given for an Oracle database instance)
$ emcli set_credential -target_type=oracle_database -target_name="prod1" -credential_set=DBCredsMonitoring -user=sysman -column="Role:SYSDBA;UserName:sys;password:XXXXX" -monitoring