Tuesday, July 24, 2012

Export Transfer Monitor Template Between OMSs


Requirements
To be able to export a monitoring template from an Oracle Enterprise Manager Repository so that it can be imported into another OEM Repository the Enterprise Manager Command Line Utility (emcli) must be installed and operational.

Steps

1.       Templates Available for Export, name must match exactly as indicated in OEM.
You can see a list via OEM Console or you can query the OEM repository database. 

Example:

SQL> SELECT TEMPLATE_NAME,TARGET_TYPE FROM MGMT_TEMPLATES;

TEMPLATE_NAME
----------------------------------------------------------------
TARGET_TYPE
----------------------------------------------------------------
Listner
oracle_listener

Prod DEV and TEST Databases
oracle_database

Production
oracle_database

Project Database Hosts
host

CPE Databases
oracle_database

2.       Select the template you want to extract and put into another OEM environment.

3.       Export the Template you want to put in the other OEM environment using the emcli utility.

Examples:

emcli export_template -name="Listner" -target_type=oracle_listener -output_file=/home/oracle/templates/Listener.template

emcli export_template -name='Prod DEV and TEST Databases' -target_type=oracle_database -output_file=/home/oracle/templates/prod_dev_and_test_databases.template

emcli export_template -name='Production' -target_type=oracle_database -output_file=/home/oracle/templates/Production.template

emcli export_template -name='Project Database Hosts' -target_type=host -output_file=/home/oracle/templates/Project_Database_hosts.template

emcli export_template -name='CPE Databases' -target_type=oracle_database -output_file=/home/oracle/templates/CPE_Databases.template

4.       Transfer the file created by the export of the template to the new OEM environment

5.       Import the template into the new OEM environment. 

Example:

emcli import_template -files="Listener.template;prod_dev_and_test_databases.template;Production.template;Project_Database_hosts.template;CPE_Databases.template"

OEM Grid Control Custom Target Properties


This procedure will walk through the requirements and steps to add and remove custom target properties as well as describe how to script populating the values for the target properties.  This procedure describes for the Oracle Enterprise Manager Grid Control 11g, while the steps are similar for earlier versions the EMCLI syntax may vary.  The custom target properties can be found for a target from the Grid Control Console in the target home page:

1.       Navigate to the Target homepage
2.       In the Related Links section, click 'Target Properties'

Requirements
To be able to add a custom target property or to script population of the target property the Oracle Enterprise Manager Command Line Interface (EM CLI) client must be installed.  The EM CLI OMS extensions are installed when the OMS is installed, but the client may require additional installation.
EMCLI Installation Requirements
·         Java version 1.6.0_25 or greater
·         Workstation running Solaris, Linux, HPUX, Tru64, AIX, or Windows with NTFS (client installation)

** See Oracle Documentation if installation is required.

Adding a Target Property
From the command line you will use the Oracle Command Line Interface (EM CLI) to add a target property, there is no way to add a target property from the Oracle Enterprise Manager Grid Control Console Interface.
1.       Log into server operating system where the Oracle Management Server is installed.
2.       From the operating system command line check the that emcli is installed
a.       emcli  (ensure that the emcli is in the PATH)
3.       Add a target property, example shows the addition of a target property to all database targets called URL.
a.       emcli add_target_property -target_type="oracle_database" -property="URL"
Note: You can use wild cards for target type to add to add a property to all target types
emcli add_target_property -target_type="*" -property="URL"

4.       Login to the OEM Grid Control GUI Console and navigate to an Oracle Database target properties.
a.       Navigate to the Target homepage
b.      In the Related Links section, click 'Target Properties'
c.       Check the property has been added.

Script Setting Target Property Value
You can set the target property value using the GUI console by going to the target home page then going to the Related Links Section “Target Properties”, however you may have a need to set the values through a process.  Again the EMCLI is required to be able to do this.

1.       Log into server operating system where the Oracle Management Server is installed.
2.       From the operating system command line check the that emcli is installed
a.       emcli
3.       Set the target property value, example shown shows an update to the URL target property of a database target called GRDPRD.
a.       emcli set_target_property_value -property_records="GRDPRD:oracle_database:URL:
www.mydatabase.com/GRDPRD"
4.       Login to the OEM Grid Control GUI Console and navigate to an Oracle Database target properties to check.
a.       Navigate to the Target homepage
b.      In the Related Links section, click 'Target Properties'
c.       Check the property value has been updated/changed

Remove Target Property
From the command line you will use the Oracle Command Line Interface (EM CLI) to remove a target property, there is no way to remove a target property from the Oracle Enterprise Manager Grid Control Console Interface.  ** Note: Cannot Remove Oracle Supplied Target properties.

1.       Log into server operating system where the Oracle Management Server is installed.

2.       From the operating system command line check the that emcli is installed
a.       emcli

3.       Remove a target property, example shows the removal of a target property from all database targets called URL
a.       emcli remove_target_properties –target_type="oracle_database" –property="URL"

4.       Login to the OEM Grid Control GUI Console and navigate to an Oracle Database target properties.
a.       Navigate to the Target homepage
b.      In the Related Links section, click 'Target Properties'
c.       Check the property has been removed.

Monday, February 13, 2012

ASM Move ASM Disk from one disk group to another, when using ASMlib rename the ASM Disk

1. determine the disk group asm disk that you want to move, this SQL will provide a list of the ASM diskgroups and their associated disks, ensure that you use the size values to determine that if you remove a disk from the disk group that you have enough free space to do so.

set linesize 100
set pagesize 1000
select dg.name, d.name, d.label, dg.type, d.path, d.state, d.OS_MB, d.TOTAL_MB, d.FREE_MB
from v$asm_disk d, v$asm_diskgroup dg
where dg.group_number = d.group_number
order by dg.name, d.name ;


2. Select the disk to remove, in this case we will select RECO3 to remove from the RECO Disk Group.

set head off
set linesize 100

set pagesize 1000
select dg.name, d.name, d.label, dg.type, d.path, d.state, d.OS_MB, d.TOTAL_MB, d.FREE_MB
from v$asm_disk d, v$asm_diskgroup dg
where dg.group_number = d.group_number
   and dg.name = 'RECO'
order by dg.name, d.name ;

RECO RECO1 RECO1 EXTERN
ORCL:RECO1
NORMAL 24999 24999 15606

RECO RECO2 RECO2 EXTERN
ORCL:RECO2
NORMAL 24999 24999 15605


RECO RECO3 RECO3 EXTERN
ORCL:RECO3
NORMAL 24999 24999 15607


3. Remove the ASM disk from the disk group

SQL> alter diskgroup RECO drop disk RECO3 ;

Diskgroup altered.


4. monitor the disk group rebal operation that removes the disk until complete.

SQL> select * from v$asm_operation;

GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATE EST_MINUTES
------------ ----- ---- ---------- ---------- ---------- ---------- ---------- -----------
ERROR_CODE
--------------------------------------------
3 REBAL RUN 1 1 570 10189 903 10

1 row selected.


SQL> select * from v$asm_operation;

no rows selected


5. ensure the disk is no longer part of the diskgroup

set linesize 100
set pagesize 1000
select dg.name, d.name, d.label, dg.type, d.path, d.state, d.OS_MB, d.TOTAL_MB, d.FREE_MB
from v$asm_disk d, v$asm_diskgroup dg
where dg.group_number = d.group_number
and dg.name = 'RECO'
order by dg.name, d.name ;

NAME NAME LABEL TYPE
------------------------------ ------------------------------ ------------------------------- ------
PATH
----------------------------------------------------------------------------------------------------
STATE OS_MB TOTAL_MB FREE_MB
-------- ---------- ---------- ----------
RECO RECO1 RECO1 EXTERN
ORCL:RECO1
NORMAL 24999 24999 10912

RECO RECO2 RECO2 EXTERN
ORCL:RECO2
NORMAL 24999 24999 10909


6. To rename the ASM disk removed to match the disk names of the disk group you are putting the disk into
in this example we are taking the disk from RECO (disk RECO3) and putting into the DATA disk group, some may want to rename the ASM disk from RECO03 to DATA5 to match the new diskgroup
** DATA4 Name is already used as an ASM disk name, but not and ASM lib disk name.

set linesize 100
set pagesize 1000
select dg.name, d.name, d.label, dg.type, d.path, d.state, d.OS_MB, d.TOTAL_MB, d.FREE_MB
from v$asm_disk d, v$asm_diskgroup dg
where dg.group_number = d.group_number
and dg.name = 'DATA'
order by dg.name, d.name ;


NAME NAME LABEL TYPE
------------------------------ ------------------------------ ------------------------------- ------
PATH
----------------------------------------------------------------------------------------------------
STATE OS_MB TOTAL_MB FREE_MB
-------- ---------- ---------- ----------
DATA DATA1 DATA1 EXTERN
ORCL:DATA1
NORMAL 24999 24999 8192


DATA DATA2 DATA2 EXTERN
ORCL:DATA2
NORMAL 24999 24999 8193

DATA DATA3 DATA3 EXTERN
ORCL:DATA3
NORMAL 24999 24999 8195

DATA DATA4 STAGEASMDATA4 EXTERN
ORCL:STAGEASMDATA4
NORMAL 24995 24995 8192


7. Ensure the name we want to use is not used in an ASM Name already.

set linesize 100
set pagesize 1000
column disk_group_name format a20
column disk_file_path format a30
column disk_file_name format a20
column disk_file_fail_group format a20
SELECT
NVL(a.name, '[CANDIDATE]') disk_group_name
, b.path disk_file_path
, b.name disk_file_name
, b.failgroup disk_file_fail_group
FROM
v$asm_diskgroup a RIGHT OUTER JOIN v$asm_disk b USING (group_number)
ORDER BY
a.name;

DISK_GROUP_NAME DISK_FILE_PATH     DISK_FILE_NAME FILE_FAIL_GROUP
--------------- ------------------ -------------- ---------------DATA            ORCL:STAGEASMDATA4 DATA4          DATA4
DATA            ORCL:DATA1         DATA1          DATA1
DATA            ORCL:DATA2         DATA2          DATA2
DATA            ORCL:DATA3         DATA3          DATA3
OCR_VOTE        ORCL:OCR_VOTE01    OCR_VOTE01     OCR_VOTE01
OCR_VOTE        ORCL:OCR_VOTE03    OCR_VOTE03     OCR_VOTE03
OCR_VOTE        ORCL:OCR_VOTE02    OCR_VOTE02     OCR_VOTE02
RECO            ORCL:RECO2         RECO2          RECO2
RECO            ORCL:RECO1         RECO1          RECO1

** As we see here the ASMlib name and DISKFILE NAME do not match, this will cause as disk name issue so we have to give our new disk a different name to avoid a duplicate name in the ASM instance.
In our case we will use DATA5 as it is not used already.


8. When using ASM lib you can rename the disk using ASM lib best to do as root, when using OS level, check the OS level name and change it there for most operating systems there is no change need unless the device name changes. When using the OS check the device name which would be the disk path as they can be name when using multi path so use the configuration there to rename.

[root]# /etc/init.d/oracleasm querydisk -p RECO3
Disk "RECO3" is a valid ASM disk
/dev/sdk1: LABEL="RECO3" TYPE="oracleasm"

[root]# /etc/init.d/oracleasm force-renamedisk RECO3 DATA5
Renaming disk "RECO3" to "DATA5": [ OK ]


9. list the disks if using ASMlib, to ensure the disk is renamed.

[root]# /etc/init.d/oracleasm listdisks
DATA1
DATA2
DATA3
DATA5
OCR_VOTE01
OCR_VOTE02
OCR_VOTE03
RECO1
RECO2
STAGEASMDATA4


10. Ensure disk is a candidate disk now to be added to a diskgroup.

set linesize 100
set pagesize 1000
column disk_group_name format a20
column disk_file_path format a30
column disk_file_name format a20
column disk_file_fail_group format a20
SELECT
NVL(a.name, '[CANDIDATE]') disk_group_name
, b.path disk_file_path
, b.name disk_file_name
, b.failgroup disk_file_fail_group
FROM
v$asm_diskgroup a RIGHT OUTER JOIN v$asm_disk b USING (group_number)
ORDER BY
a.name;

DISK_GROUP_NAME DISK_FILE_PATH DISK_FILE_NAME FILE_FAIL_GROUP
--------------- ------------------ -------------- ---------------
DATA ORCL:STAGEASMDATA4 DATA4 DATA4
DATA ORCL:DATA1 DATA1 DATA1
DATA ORCL:DATA2 DATA2 DATA2
DATA ORCL:DATA3 DATA3 DATA3
OCR_VOTE ORCL:OCR_VOTE01 OCR_VOTE01 OCR_VOTE01
OCR_VOTE ORCL:OCR_VOTE03 OCR_VOTE03 OCR_VOTE03
OCR_VOTE ORCL:OCR_VOTE02 OCR_VOTE02 OCR_VOTE02
RECO ORCL:RECO2 RECO2 RECO2
RECO ORCL:RECO1 RECO1 RECO1
[CANDIDATE] ORCL:DATA5


9. Add disk to disk to group, in our case disk DATA4 to diskgroup DATA

SQL> alter diskgroup DATA add disk 'ORCL:DATA5' ;

Diskgroup altered.


10. Monitor Rebal operation that is bringing in the new disk


SQL> select * from v$asm_operation;

GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATE EST_MINUTES
------------ ----- ---- ---------- ---------- ---------- ---------- ---------- -----------
ERROR_CODE
--------------------------------------------
1 REBAL RUN 1 1 682 13467 987 12

SQL> select * from v$asm_operation;

no rows selected


11. Ensure the disk is now part of the diskgroup

set linesize 100
set pagesize 1000
select dg.name, d.name, d.label, dg.type, d.path, d.state, d.OS_MB, d.TOTAL_MB, d.FREE_MB
from v$asm_disk d, v$asm_diskgroup dg
where dg.group_number = d.group_number
and dg.name = 'DATA'
order by dg.name, d.name ;

NAME NAME LABEL TYPE
------------------------------ ------------------------------ ------------------------------- ------
PATH
----------------------------------------------------------------------------------------------------
STATE OS_MB TOTAL_MB FREE_MB
-------- ---------- ---------- ----------
DATA DATA1 DATA1 EXTERN
ORCL:DATA1
NORMAL 24999 24999 11525

DATA DATA2 DATA2 EXTERN
ORCL:DATA2
NORMAL 24999 24999 11525

DATA DATA3 DATA3 EXTERN
ORCL:DATA3
NORMAL 24999 24999 11525

DATA DATA4 STAGEASMDATA4 EXTERN
ORCL:STAGEASMDATA4
NORMAL 25995 25995 11985

DATA DATA5 DATA5 EXTERN
ORCL:DATA5
NORMAL 24999 24999 11527