Monday, December 3, 2012

Create Blackout using Emcli




Mostly We used to login to the Enterprise Manager to create blackout which will be slow when we are trying to access Client EM from Local machine.

##########################
## Easier Way to Create A blackout Using EMCLI :
##########################

Logon to the server where database is running and set the Agent envionment .

##########################
## Server Blackout
##########################

emcli create_blackout -name="Blackout_Name" -reason="reboot due to memory errors" -add_targets="server01:host" -schedule="duration:-1" 

##########################
## Server & and its associated databases Blackout
##########################

Use propagate_targets to blackout the host and its associated oracle services (database, agent, asm, etc.)

emcli create_blackout -name="Blackout_Name" -reason="reboot due to memory errors" -add_targets="server01:host" -schedule="duration:-1"  -propagate_targets

##########################
## Single Database Blackout
##########################

emcli create_blackout -name="Blackout_Name" -add_targets="db_name:oracle_database" -schedule="duration:30"

##########################
## Multiple Database Blackout
##########################

emcli create_blackout -name="Blackout_Name"-reason="Failover" -add_targets="db1_name:oracle_database;db2_name:oracle_database" -schedule="duration:30"

##########################
## Blackout for RAC Database
##########################

emcli create_blackout -name="Blackout_Name"-reason="Failover" -add_targets="instance_name:oracle_database;cluster_name:rac_database" -schedule="duration:30"

##########################
## Unlimited Blackout
##########################

emcli create_blackout -name="Blackout_Name"-reason="Failover" -add_targets="instance_name:oracle_database;cluster_name:rac_database" -schedule="frequency:once;duration:-1"

If we give duration = "-1" then it denotes that unlimited Duration

##########################
## Show List of Targets in the Blackout
##########################

emcli get_blackout_targets -name=Blackout_Name

agent11g @ myserver03:/u01/home/oracle/admin/scripts
> emcli get_blackout_targets -name=Blackout_Name
Target Name  Target Type      Status       Status ID
mydb_2     oracle_database  In Blackout  1
mydb1_2   oracle_database  In Blackout  1
mydb2_2     oracle_database  In Blackout  1
mydb3_2     oracle_database  In Blackout  1

##########################
## Check Whether database is in blackout
##########################

emcli get_blackouts -target=mydb_1:oracle_database

agent11g @ myserver03:/u01/home/oracle
> emcli get_blackouts -target=mydb_1:oracle_database
Name                              Created By  Status   Status ID  Next Start           Duration  Reason  Frequency  Repeat  Start Time           End Time  Previous End
 TZ Region        TZ Offset

Blackout_name     SYSMAN      Started  4          2012-08-28 16:42:19  -00:01    none    once       none    2012-08-28 16:42:19  none      none      
 America/Chicago  +00:00

If the above command produces output like above then db is under blackout. If no output then db is not under blackout

##########################
## Blackout Details
##########################

emcli get_blackout_details  -name=failover_03-dec-2012

agent11g @ myserver03:/u01/home/oracle/admin/scripts
> emcli get_blackout_details  -name=failover_03-dec-2012
Status             Status ID  Run Jobs  Next Start           Duration  Reason    Frequency  Repeat  Days  Months  Start Time           End Time  TZ Region   TZ Offset
Start In Progress  1          no        2012-12-03 04:35:24  -00:01    Failover  once       none    none  none    2012-12-03 04:35:24  none      US/Central  +00:00
agent11g @ myserver03:/u01/home/oracle/admin/scripts

##########################
## Stop Blackout
##########################

emcli stop_blackout -name="Blackout_name"

agent11g @ myserver03:/u01/home/oracle
>emcli stop_blackout -name="Blackout_name"
Blackout "Blackout-Aug 28  2012 4:42:11 PM" stopped successfully

##########################
## Delete Blackout
##########################

emcli delete_blackout -name=Blackout_name

7 comments:

Anonymous said...

Hello, Do you know how to create an agent´s blackout?

Thanks.

Sri said...

Hi,

You can use the below option to blackout the server and its associated databases. ( Agent monitors all the databases configured in the server. So placing an agent in blackout is same as below).

##########################
## Server & and its associated databases Blackout
##########################

Use propagate_targets to blackout the host and its associated oracle services (database, agent, asm, etc.)

emcli create_blackout -name="Blackout_Name" -reason="reboot due to memory errors" -add_targets="server01:host" -schedule="duration:-1" -propagate_targets

Anonymous said...

Is there a way blackout any/all databases from the oms server using command line option

Anonymous said...

How much time typically it takes to create blackout say for 4 node RAC DB?

Sri said...

It will take almost same amount of time for a one node rac. Not more than 15 seconds

Anonymous said...

What is the maximum number of targets I can put in the '-add_targets=' option?

Sri said...


I've not checked the maximum limit and i don't think its mentioned as per Oracle Documentation.

But i hope it should be unlimited, Please let me know if you got time to test with numerous targets.