Showing posts with label ASM. Show all posts
Showing posts with label ASM. Show all posts

Friday 18 March 2016

RENAMEDISK & DELETEDISK through ASMLIB in 11gR2

RENAME/DELETE DISKLABEL through ASMLIB

We can rename a DISKLABEL in asm through two ways


1)      RENAMING BY PROVIDING  DISKLABLE NAME

In the below example, we are rename a disk label by providing the CURRENT DISKLABEL name to NEW DISKLABEL name

[root@ nikhil]#  /etc/init.d/oracleasm force-renamedisk TEMP5 TEMP6
Renaming disk "TEMP5" to "TEMP6":                          [  OK  ]


 [root@nikhil]# oracleasm querydisk /dev/mapper/DISK_05
Device "/dev/mapper/DISK_05" is marked an ASM disk with the label "TEMP6"


2)      RENAMING BY PROVIDING THE DISK

In the below example, we are rename a disk label by providing the disk and new name to be allocated for the disk

[root@nikhil]#  /etc/init.d/oracleasm force-renamedisk /dev/mapper/DISK_05 TEMP5
Renaming disk "/dev/mapper/DISK_05" to "TEMP5":            [  OK  ]


[root@nikhil]# oracleasm querydisk /dev/mapper/DISK_05
Device "/dev/mapper/DISK_05" is marked an ASM disk with the label "TEMP5"


We can DELETE a DISKLABEL in asm through two ways


1)      DELETE ASM DISK LABEL BY PROVIDING  DISKLABEL NAME

In below example we are check the disk to find the DISKLABEL and we are deleting a disklabel by providing the disklabel name

[root@nikhil]# oracleasm querydisk /dev/mapper/DISK_05
Device "/dev/mapper/DISK_05" is marked an ASM disk with the label "TEMP5"

 [root@nikhil]# oracleasm deletedisk TEMP5
Clearing disk header: done
Dropping disk: done


2)      DELETE ASM DISK LABEL BY PROVIDING THE DISK


In below example, we are deleting a disklabel by providing the disk and we are check the disk status after deleting the disklabel

[root@nikhil]# oracleasm deletedisk /dev/mapper/DISK_05
Clearing disk header: done
Dropping disk: done

[root@nikhil]#  oracleasm querydisk /dev/mapper/DISK_05
Device "/dev/mapper/DISK_05" is not marked as an ASM disk



See Also                                                                                                                     See Also 
Moving Control Files in ASM                                               MovingTablespace Across DiskGroup

Disks Operations in ASM

Rebalance Disk Group

·         ASM rebalance a disk group automatically, whenever we add or remove disks form disk group.
·         Disk groups can be rebalanced manually using the REBALANCE clause of the ALTER DISKGROUP statement.
·         If the POWERclause is omitted the ASM_POWER_LIMIT parameter value is used.
Example :

SQL> ALTER DISKGROUP DATA_DG REBALANCE POWER 5;


Mount and Dismount The ASM DISKGROUP

Disk groups are mounted at ASM instance startup and unmounted at ASM instance shutdown. Manual mounting and dismounting can be accomplished using the ALTER DISKGROUP statement as seen below.

ALTER DISKGROUP ALL DISMOUNT;
ALTER DISKGROUP ALL MOUNT;
ALTER DISKGROUP disk_group_1 DISMOUNT;
ALTER DISKGROUP disk_group_1 MOUNT

How to Create DISK GROUP             

SQL> create diskgroup DATA_DG normal redundancy
Failgroup groupA disk ‘/devices/Disk1’, ‘/devices/Disk2’, ‘/devices/Disk3’,
Failgroup groupB disk ‘/devices/DiskD1’, ‘/devices/DiskD2’, ‘/devices/DiskD3’,
When oracle writes data to the disks in the first failure group Group 1, it also wites those extents to disk in the other failure group Group ‘D1’.

Important:
·                     When you don’t specify a FAILGROUP clause, the disk is in its own failure group.

Adding Disks to a Disk Group

ALTER DISKGROUP DATA_DG ADD DISK '/devices/DiskA1’,’/device/DiskB1';
Note:
· When a disk is added, it is formatted and then rebalanced.
·                     When you don’t specify a FAILGROUP clause, the disk is in its own failure group.
·                     When you don’t specify a REDUNDANCY clause, the disk is in its own failure group.
· If you don't specify the NAME clause, Oracle assigns its own system-generated names.
· If the disk already belongs to a disk group, the statement will fail.


Resize a  Disk

· Resize a specific disk.
ALTER DISKGROUP DATA_DG RESIZE DISK DISK1 SIZE 100G;

· Resize all disks in a disk group.
ALTER DISKGROUP DATA_DG RESIZE ALL SIZE 100G;

· Undrop Disk
The UNDROP DISKS clause of the ALTER DISKGROUP statement allows pending disk drops to be undone. It will not revert drops that have completed, or disk drops associated with the dropping of a disk group.
Example :  SQL> ALTER DISKGROUP disk_group_1 UNDROP DISKS;



Dropping Disks and Disk Groups

ALTER DISKGROUP DATA_DG DROP DISK DiskA1;
DROP DISKGROUP DATA_DG INCLUDING CONTENTS;

Note:

· DROP DISKGROUP statements requires the instance to be in MOUNT state.

· When a disk is dropped, the disk group is rebalanced by moving all of the file extents from the dropped disk to other disks in the disk group. The header on the dropped disk is then cleared.

· If you specify the FORCE clause for the drop operation, the disk is dropped even if Automatic Storage Management cannot read or write to the disk.

· You can also drop all of the disks in specified failure groups using the DROP DISKS IN FAILGROUP clause.


DISK STATUS in ASM

·                     UNPROTECTED - No mirroring or striping regardless of the redundancy setting.
·                      MIRROR - Two-way mirroring for normal redundancy and three-way mirroring for high redundancy. This attribute cannot be set for external redundancy.
·                     COARSE - Specifies lower granuality for striping. This attribute cannot be set for external redundancy.
·                     FINE - Specifies higher granularity for striping. This attribute cannot be set for external redundancy.

See Also                                                                                               See Also 
Rename Disk / Delete Disk in ASM                                                        Moving Control Files in ASM

MOVING CONTROLFILES IN ASM

MOVING CONTROLFILES TO DIFFERENT LOCATION IN ASM


1) BACKUP YOUR SPFILE and CONTROLFILE
SQL> !rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Mar 18 01:00:19 2016

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL1 (DBID=1291218066)

RMAN> backup spfile;

Starting backup at 18-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=49 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 18-MAR-16
channel ORA_DISK_1: finished piece 1 at 18-MAR-16
piece handle=+DATA/orcl1/backupset/2016_03_18/nnsnf0_tag20160318t094509_0.292.906803113 tag=TAG20160318T094509 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 18-MAR-16

RMAN> backup current controlfile;

Starting backup at 18-MAR-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 18-MAR-16
channel ORA_DISK_1: finished piece 1 at 18-MAR-16
piece handle=+DATA/orcl1/backupset/2016_03_18/ncnnf0_tag20160318t094558_0.293.906803163 tag=TAG20160318T094558 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 18-MAR-16

Starting Control File and SPFILE Autobackup at 18-MAR-16
piece handle=+DATA/orcl1/autobackup/2016_03_18/s_906803165.294.906803169 comment=NONE
Finished Control File and SPFILE Autobackup at 18-MAR-16

RMAN>


2) IDENTIFY THE CONTROLFILE LOCATION
RMAN> exit
Recovery Manager complete.

SQL> show parameter control_files

NAME                                        TYPE      VALUE
-------------------------------- ----------- ------------------------------
control_files                            string               +DATA/orcl1/controlfile/current.267.906768595       

                +DATA/orcl1/controlfile/current.272.906768603


3) SHUTDOWN YOUR DATABASE AND BRING IT IN NOMOUNT MODE

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  313860096 bytes
Fixed Size                                1336232 bytes
Variable Size                        142609496 bytes
Database Buffers               163577856 bytes
Redo Buffers                         6336512 bytes

SQL> alter system set control_files='+DATA’ scope=spfile;
System altered.


4) SHUTDOWN YOUR DATABASE & AGAIN START IN NOMOUNT
SQL> shutdown immediate
SQL>startup nomount

Note:  you need to specify your original copy of the control file for restoring

SQL> !  rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Mar 18 01:09:15 2016
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: ORCL1 (not mounted)

RMAN> restore controlfile from '+DATA/orcl1/autobackup/2016_03_18/s_906803165.294.906803169' ;

Starting restore at 18-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
output file name=+DATA/orcl1/controlfile/current.295.906803541
Finished restore at 18-MAR-16

RMAN> alter database mount;
Database altered.


SQL> show parameter control_files

NAME                                      TYPE        VALUE
-------------------------------  ----------- ------------------------------
control_files                            string       +DATA/orcl1/controlfile/current.295.906803541

SQL> alter database open;
Database altered.

SQL>



                                                                                                                                                See Also.. How to Move Tablespace within DISKS in ASM

                                                                                                                                                

Difference between CANDIDATE & PROVISIONED in ASM DISK

Disks that were discovered but that have not yet been assigned to a disk group have a header status of either CANDIDATE  or PROVISIONED.

CANDIDATE
Disk is not part of a disk group and may be added to a disk group with the ALTER DISKGROUP statement

PROVISIONED
Disk is not part of a disk group and may be added to a disk group with the ALTER DISKGROUP statement. The PROVISIONEDheader status is different from the CANDIDATE header status in that PROVISIONED implies that an additional platform-specific action has been taken by an administrator to make the disk available for Automatic Storage Management.
For example, on Windows, the administrator used asmtool or asmtoolg to stamp the disk with a header, or on Linux, the administrator used ASMLib to prepare the disk for ASM.


Below are the HEADER_STATUS in the v$ASM_DISK.

I have taken below status from 11gR2.

•         UNKNOWN - Automatic Storage Management disk header has not been read

•         CANDIDATE - Disk is not part of a disk group and may be added to a disk group with the ALTER DISKGROUP statement

•         INCOMPATIBLE - Version number in the disk header is not compatible with the Automatic Storage Management software version.

•         PROVISIONED - Disk is not part of a disk group and may be added to a disk group with the ALTER DISKGROUPstatement. The PROVISIONED header status is different from the 
CANDIDATE header status in that PROVISIONEDimplies that an additional platform-specific action has been taken by an administrator to make the disk available for Automatic Storage Management.

•         MEMBER - Disk is a member of an existing disk group. No attempt should be made to add the disk to a different disk group. The ALTER DISKGROUP statement will reject such an addition unless overridden with the FORCE option

•         FORMER - Disk was once part of a disk group but has been dropped cleanly from the group. It may be added to a new disk group with the ALTER DISKGROUP statement.

•         CONFLICT - Automatic Storage Management disk was not mounted due to a conflict

•         FOREIGN - Disk contains data created by an Oracle product other than ASM. This includes datafiles, logfiles, and OCR disks.


      When adding a disk, the FORCE option must be used if Oracle ASM recognizes that the disk was managed by Oracle.  Such a disk appears  in the V$ASM_DISK view with a status of FOREIGN.

                                                                                    See Also : Adding a New Disk to Existing Diskgroup


ADDING NEW DISK TO THE EXISTING DISK GROUP/REBALANCING EXISTING DISK GROUP

Things to consider while adding new disk/ Rebalancing existing Disk Group


1)         Make sure the disk are visible on all the cluster nodes; Disk readiness purely depend on the Os & version;

For ex:
Linux 5 – we will be using oracleasm as utility
Linux 6 – we will be using udev utility

2)         When you are planning to add disk to the disk group on the primary database, try to do it when database is having less load.

3)         Increase the ASM power limit to 9 or 10, depending on your environment. Once the rebalancing is completed, bring it to the original value.
Parameter è asm_power_limit
To increase or decrease the asm_power_limit

SQL> alter system set asm_power_limit=9;                 -- you need to issue it in the ASM instance.

4)         Add disks to one disk group at a time because rebalancing might cause the slowness to the database.

5)         Have a eye on the alert log of the ASM instance. If you are using cluster databases then you need to have a eye on all the instances in the cluster.

6)         You can monitor the rebalancing on the ASM instance using the below query
select group_number, operation, state, power, actual, sofar, est_work, est_rate, est_minutes from gv$asm_operation;

7)         you can check the size of the diskgroup before & after adding the Diskgroup in the ASM.
$ asmcmd –p
ASMCMD> lsdg NIK_B_SYSTEM

8)         Messages in the alert, when the rebalancing starts & when it completes
Disk added on the Node#1 and final status updates on the Node#2

-On Node One

SQL> ALTER DISKGROUP NIK_B_SYSTEM ADD  DISK '/dev/mapper/NIK_B_SYSTEM_05' SIZE 51200M /* ASMCA */
NOTE: GroupBlock outside rolling migration privileged region
NOTE: Assigning number (21,4) to disk (/dev/mapper/NIK_B_SYSTEM_05)
NOTE: requesting all-instance membership refresh for group=21
NOTE: initializing header on grp 21 disk NIK_B_SYSTEM_0004
NOTE: requesting all-instance disk validation for group=21
Wed Aug 06 17:09:45 2014
NOTE: skipping rediscovery for group 21/0xdb38ead3 (NIK_B_SYSTEM) on local instance.
NOTE: requesting all-instance disk validation for group=21
NOTE: skipping rediscovery for group 21/0xdb38ead3 (NIK_B_SYSTEM) on local instance.
NOTE: initiating PST update: grp = 21
Wed Aug 06 17:09:51 2014
GMON updating group 21 at 9546 for pid 73, osid 16865
NOTE: PST update grp = 21 completed successfully
NOTE: membership refresh pending for group 21/0xdb38ead3 (NIK_B_SYSTEM)
GMON querying group 21 at 9547 for pid 18, osid 101970
NOTE: cache opening disk 4 of grp 21: NIK_B_SYSTEM_0004 path:/dev/mapper/NIK_B_SYSTEM_05
Wed Aug 06 17:09:56 2014
NOTE: Attempting voting file refresh on diskgroup NIK_B_SYSTEM
GMON querying group 21 at 9548 for pid 18, osid 101970
SUCCESS: refreshed membership for 21/0xdb38ead3 (NIK_B_SYSTEM)
Wed Aug 06 17:09:56 2014
SUCCESS: ALTER DISKGROUP NIK_B_SYSTEM ADD  DISK '/dev/mapper/NIK_B_SYSTEM_05' SIZE 51200M /* ASMCA */
NOTE: starting rebalance of group 21/0xdb38ead3 (NIK_B_SYSTEM) at power 9
Starting background process ARB0
Wed Aug 06 17:09:56 2014
ARB0 started with pid=74, OS id=91751
NOTE: assigning ARB0 to group 21/0xdb38ead3 (NIK_B_SYSTEM) with 9 parallel I/Os
NOTE: Attempting voting file refresh on diskgroup NIK_B_SYSTEM
Wed Aug 06 17:11:01 2014

-On Second One
NOTE: disk validation pending for group 21/0xdb38cf46 (NIK_B_SYSTEM)
SUCCESS: validated disks for 21/0xdb38cf46 (NIK_B_SYSTEM)
NOTE: disk validation pending for group 21/0xdb38cf46 (NIK_B_SYSTEM)
NOTE: Assigning number (21,4) to disk (/dev/mapper/NIK_B_SYSTEM_05)
SUCCESS: validated disks for 21/0xdb38cf46 (NIK_B_SYSTEM)
NOTE: membership refresh pending for group 21/0xdb38cf46 (NIK_B_SYSTEM)
Wed Aug 06 17:09:54 2014
GMON querying group 21 at 9721 for pid 18, osid 84704
NOTE: cache opening disk 4 of grp 21: NIK_B_SYSTEM_0004 path:/dev/mapper/NIK_B_SYSTEM_05
GMON querying group 21 at 9722 for pid 18, osid 84704
SUCCESS: refreshed membership for 21/0xdb38cf46 (NIK_B_SYSTEM)
Wed Aug 06 17:09:58 2014
NOTE: Attempting voting file refresh on diskgroup NIK_B_SYSTEM

Adding disk
1)         I am using asmca to add the disk to the existing Diskgroup.
2)         You need to plan what kind of redundancy you are opting for, if you are going for a new diskgroup.
3)   As soon as you added the disk in the asmca, you will be shown an output as “Disks added successfully to disk group DISK_GROUP_NAME”. You need to see it in the sql prompt(on ASM instance) to know about the rebalancing status

MOVING TABLESPACE/DATAFILES ACROSS DISK GROUP IN ASM (ONLINE & OFFLINE)

1. MOVING SYSTEM TABLESPACE FROM ONE DISK GROUP TO ANOTHER DISK GROUP


$sqlplus / as sysdba

SQL> startup mount

RMAN>  backup as copy tablespace system format '+SYSTEM';

RMAN> switch tablespace system to copy;

SQL> alter database open;
  

2. MOVING SYSTEM DATAFILE FROM ONE DISK GROUP TO ANOTHER DISK GROUP


STEP 1: Start the database in the mount stage

STEP 2: connect to the rman and copy the datafile

RMAN> copy datafile 1 to '+SYSTEM';
Starting backup at 08-SEP-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=388 instance=BE1_2 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+DATA1/nikhil/datafile/psapundo.259.756901419
output file name=+SYSTEM/nikhil/datafile/undo.263.761315651 tag=TAG20110908T123410 RECID=21 STAMP=761315652
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 08-SEP-11

STEP 3: switch the datafile to the new disk group
RMAN> switch datafile 1 to copy;
datafile 1 switched to datafile copy "+SYSTEM/nikhil/datafile/undo.263.761315651"

STEP 4: open the database
SQL> alter database open;


3. MOVING NON-SYSTEM TABLESPACE FROM ONE DISK GROUP TO ANOTHER DISK GROUP    (WITH OFFLINE OPTION)


STEP 1: Offline the tablespace
RMAN>  sql ‘alter tablespace <TBS_NAME> offline’;

STEP 2: connect to the rman and copy the tablespace
RMAN> backup as copy tablespace <TBS_NAME>  format  ‘<+NEW_DISK>’;

STEP 3: Switch the tablespace to the new location
RMAN> switch tablespace <TBS_NAME>  to copy;

STEP 4: Online the tablespace
RMAN> sql ‘alter tablespace <TBS_NAME>  online’;

 4. MOVING NON-SYSTEM TABLESPACE FROM ONE DISK GROUP TO ANOTHER DISK GROUP
    (WITH ONLINE OPITION)


STEP 1: connect to the rman and copy the tablespace
RMAN> backup as copy tablespace  <TBS_NAME>  format  ‘<+NEW_DISK>’;

STEP 2: Offline the tablespace
RMAN> sql ‘alter tablespace <TBS_NAME> offline’;

STEP 3: Switch the tablespace to the new location
RMAN> switch tablespace <TBS_NAME>  to copy;

STEP 4: Recover the tablespace
RMAN> recover tablespace <TBS_NAME>;

STEP 4: Online the tablespace
RMAN> sql ‘alter tablespace <TBS_NAME> online’;


5. MOVING NON-SYSTEM DATAFILE FROM ONE DISK GROUP TO ANOTHER DISK GROUP    (ONLINE & OFFLINE)


STEP 1: Offline the datafile
RMAN> sql ‘alter datafile <datafile_number or name> offline’;

STEP 2: connect to the rman and copy the tablespace
RMAN> COPY DATAFILE <datafile_number or name> to ‘<+NEW_DISK’>;

STEP 3: Switch the tablespace to the new location
RMAN> switch datafile <datafile_number or name> to copy;

STEP 4: Recover the datafile
RMAN> recover datafile <datafile_number or name>;

STEP 5: Online the tablespace

RMAN> ‘alter datafile <datafile_number or name> online’;


Friday 11 March 2016

Viewing disk group clients with V$ASM_CLIENT



 How do we see Viewing disk group clients with V$ASM_CLIENT ?


SQL> SELECT dg.name AS diskgroup, SUBSTR(c.instance_name,1,12) AS instance,
2 SUBSTR(c.db_name,1,12) AS dbname, SUBSTR(c.SOFTWARE_VERSION,1,12) AS software,
3 SUBSTR(c.COMPATIBLE_VERSION,1,12) AS compatible
4 FROM V$ASM_DISKGROUP dg, V$ASM_CLIENT c
5 WHERE dg.group_number = c.group_number;

Output
 
DISKGROUP INSTANCE DBNAME SOFTWARE COMPATIBLE
------------------------------ ------------------------------------ ------------------------ --------------
DATA +ASM ERPPROD 11.2.0.2.0 11.2.0.0.0
FRA +ASM ERPPROD 11.2.0.2.0 11.2.0.0.0
REDO1 +ASM ERPPROD 11.2.0.2.0 11.2.0.0.0
REDO2 +ASM ERPPROD 11.2.0.2.0 11.2.0.0.0