Total Pageviews

Tuesday 30 December 2014

Migrating the Database from Filesystem to ASM


Check the existing location of all datafiles , redo and control files:

SQL> select name from v$database;

NAME
---------
DBORA

SQL> Archive log list;
Database log mode        Archive Mode
Automatic archival        Enabled
Archive destination        /home/oracle/arch/
Oldest online log sequence     1
Next log sequence to archive   3
Current log sequence        3
SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/dbora/users01.dbf
/u01/app/oracle/oradata/dbora/undotbs01.dbf
/u01/app/oracle/oradata/dbora/sysaux01.dbf
/u01/app/oracle/oradata/dbora/system01.dbf

SQL> select file_name from dba_temp_files;

FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/dbora/temp01.dbf

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/dbora/redo03.log
/u01/app/oracle/oradata/dbora/redo02.log
/u01/app/oracle/oradata/dbora/redo01.log

SQL>  show parameter spfile ;

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
spfile         string  /u01/app/oracle/product/11.2/d
       b_1/dbs/spfiledbora.ora
SQL> show parameter control_file ;

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time      integer  7
control_files        string  /u01/app/oracle/oradata/dbora/
       control01.ctl, /u01/app/oracle
       /fast_recovery_area/dbora/cont
       rol02.ctl


 Backup pfile and spfile:

SQL> create pfile='/home/oracle/pfile.ora' from spfile ;

File created.


[oracle@oracle arch]$ cd $ORACLE_HOME/dbs
[oracle@oracle dbs]$ ls

hc_dbora.dat  initdbora.ora  init.ora  lkDBORA  orapwdbora  spfiledbora.ora
[oracle@oracle dbs]$ cp spfiledbora.ora /home/oracle/spfiledbora.ora_bkp

Back up the datafiles to the ASM disk group.

The format clause specifies +DATA2, which is the name of the ASM disk group to be used for storing the database.

[oracle@oracle dbs]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Mon Dec 29 17:38:21 2014

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

connected to target database: DBORA (DBID=3262226103)

RMAN> RUN
{
  ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
  ALLOCATE CHANNEL dev2 DEVICE TYPE DISK;
 BACKUP AS COPY
 INCREMENTAL LEVEL 0
 DATABASE
 FORMAT '+DATA2'
 TAG 'ORA_ASM_MIGRATION';
 }

using target database control file instead of recovery catalog
allocated channel: dev1
channel dev1: SID=48 device type=DISK

allocated channel: dev2
channel dev2: SID=53 device type=DISK

Starting backup at 29-DEC-14
channel dev1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/dbora/system01.dbf
channel dev2: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/dbora/sysaux01.dbf
output file name=+DATA2/dbora/datafile/sysaux.257.867606039 tag=ORA_ASM_MIGRATION RECID=1 STAMP=867606314
channel dev2: datafile copy complete, elapsed time: 00:05:38
channel dev2: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/dbora/undotbs01.dbf
output file name=+DATA2/dbora/datafile/undotbs1.258.867606335 tag=ORA_ASM_MIGRATION RECID=2 STAMP=867606350
channel dev2: datafile copy complete, elapsed time: 00:00:25
channel dev2: starting datafile copy
copying current control file
output file name=+DATA2/dbora/datafile/system.256.867606009 tag=ORA_ASM_MIGRATION RECID=3 STAMP=867606376
channel dev1: datafile copy complete, elapsed time: 00:06:32
channel dev1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/dbora/users01.dbf
output file name=+DATA2/dbora/controlfile/backup.259.867606353 tag=ORA_ASM_MIGRATION RECID=4 STAMP=867606379
channel dev2: datafile copy complete, elapsed time: 00:00:29
channel dev2: starting incremental level 0 datafile backup set
channel dev2: specifying datafile(s) in backup set
including current SPFILE in backup set
channel dev2: starting piece 1 at 29-DEC-14
output file name=+DATA2/dbora/datafile/users.260.867606381 tag=ORA_ASM_MIGRATION RECID=5 STAMP=867606382
channel dev1: datafile copy complete, elapsed time: 00:00:05
channel dev2: finished piece 1 at 29-DEC-14
piece handle=+DATA2/dbora/backupset/2014_12_29/nnsnn0_ora_asm_migration_0.261.867606385 tag=ORA_ASM_MIGRATION comment=NONE
channel dev2: backup set complete, elapsed time: 00:00:07
Finished backup at 29-DEC-14
released channel: dev1
released channel: dev2

If block change tracking is enabled for the database, then optionally make a level 1 incremental backup that you can use later to recover the database copy.

SQL> select  status from   v$block_change_tracking ;
STATUS  
----------
DISABLED
In our case it was disabled . If enable take level1 DB inc backup as below:

RUN
{
  ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
  ALLOCATE CHANNEL dev2 DEVICE TYPE DISK;
  ALLOCATE CHANNEL dev3 DEVICE TYPE DISK;
  ALLOCATE CHANNEL dev4 DEVICE TYPE DISK;
  BACKUP INCREMENTAL LEVEL 1 
    FOR RECOVER OF COPY WITH TAG 'ORA_ASM_MIGRATION' 
    DATABASE;
}

If the database is in ARCHIVELOG mode, and if the database is open, then archive the online logs.

The following example uses the SQL command to archive the current redo logs:

RMAN> SQL "ALTER SYSTEM ARCHIVE LOG CURRENT";

SQL "ALTER SYSTEM ARCHIVE LOG CURRENT";

If the database instance is currently using a server parameter file, then back it up.

The following example backs up the server parameter file:

RMAN> BACKUP AS BACKUPSET SPFILE;

Starting backup at 29-DEC-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=48 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 29-DEC-14
channel ORA_DISK_1: finished piece 1 at 29-DEC-14
piece handle=/u01/app/oracle/fast_recovery_area/DBORA/backupset/2014_12_29/o1_mf_nnsnf_TAG20141229T175459_bb2l0x3h_.bkp tag=TAG20141229T175459 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 29-DEC-14


If block change tracking is enabled, then disable it.

The following command disables block change tracking:

RMAN> SQL "ALTER DATABASE DISABLE BLOCK CHANGE TRACKING";

RMAN> SQL "ALTER DATABASE FLASHBACK OFF";

sql statement: ALTER DATABASE FLASHBACK OFF

RMAN> SHUTDOWN IMMEDIATE;

database closed
database dismounted
Oracle instance shut down

RMAN> STARTUP MOUNT;

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area     839282688 bytes

Fixed Size                     2233000 bytes
Variable Size                536874328 bytes
Database Buffers             297795584 bytes
Redo Buffers                   2379776 bytes

RMAN> RESTORE SPFILE TO '+DATA2/spfiledbora.ora';

Starting restore at 29-DEC-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: restoring SPFILE
output file name=+DATA2/spfiledbora.ora
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DBORA/backupset/2014_12_29/o1_mf_nnsnf_TAG20141229T175459_bb2l0x3h_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DBORA/backupset/2014_12_29/o1_mf_nnsnf_TAG20141229T175459_bb2l0x3h_.bkp tag=TAG20141229T175459
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 29-DEC-14

If the database is not using a server parameter file, then create one in ASM. Execute the CREATE SPFILE command in SQL*Plus as follows, where sid is the SID of the database (the command spans two lines):

SQL> CREATE SPFILE='+DATA/spfiledbora.ora' FROM PFILE='?/dbs/initsid.ora';

Afterward, delete spfiledbora.ora and initdbora.ora from the ?/dbs directory and 

Create a new initdbora.ora with the following line of content:

SPFILE='+DATA2/spfiledbora.ora'


RMAN> STARTUP MOUNT;

RMAN> SHUTDOWN IMMEDIATE;

database dismounted
Oracle instance shut down

 SQL> STARTUP FORCE NOMOUNT;

Oracle instance started

Total System Global Area     839282688 bytes

Fixed Size                     2233000 bytes
Variable Size                536874328 bytes
Database Buffers             297795584 bytes
Redo Buffers                   2379776 bytes


SQL> alter system set control_files='+DATA','+DATA2' scope=spfile;

System altered.

SQL>  alter system set db_create_file_dest='+DATA2' scope=spfile;

System altered.


SQL> startup nomount ;
ORACLE instance started.

Total System Global Area  839282688 bytes
Fixed Size      2233000 bytes
Variable Size    536874328 bytes
Database Buffers   297795584 bytes
Redo Buffers      2379776 bytes
SQL> show parameter control_file;

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time      integer  7
control_files        string  +DATA, +DATA2
SQL> 
RMAN> restore controlfile from '/u01/app/oracle/oradata/dbora/control01.ctl' ;

Starting restore at 29-DEC-14
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: copied control file copy
output file name=+DATA/dbora/controlfile/current.256.867608667
output file name=+DATA2/dbora/controlfile/current.263.867608679
Finished restore at 29-DEC-14

RMAN> ALTER DATABASE MOUNT;

database mounted
released channel: ORA_DISK_1

RMAN> SWITCH DATABASE TO COPY;

datafile 1 switched to datafile copy "+DATA2/dbora/datafile/system.256.867606009"
datafile 2 switched to datafile copy "+DATA2/dbora/datafile/sysaux.257.867606039"
datafile 3 switched to datafile copy "+DATA2/dbora/datafile/undotbs1.258.867606335"
datafile 4 switched to datafile copy "+DATA2/dbora/datafile/users.260.867606381"

RMAN> RUN
{
  ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
  ALLOCATE CHANNEL dev2 DEVICE TYPE DISK;
  ALLOCATE CHANNEL dev3 DEVICE TYPE DISK;
  ALLOCATE CHANNEL dev4 DEVICE TYPE DISK;
  RECOVER DATABASE;
}

allocated channel: dev1
channel dev1: SID=24 device type=DISK

allocated channel: dev2
channel dev2: SID=26 device type=DISK

allocated channel: dev3
channel dev3: SID=27 device type=DISK

allocated channel: dev4
channel dev4: SID=28 device type=DISK

Starting recover at 29-DEC-14
starting media recovery
media recovery complete, elapsed time: 00:01:05

Finished recover at 29-DEC-14
released channel: dev1
released channel: dev2
released channel: dev3
released channel: dev4

RMAN> ALTER DATABASE OPEN;

database opened

QL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
+DATA2/dbora/datafile/users.260.867606381
+DATA2/dbora/datafile/undotbs1.258.867606335
+DATA2/dbora/datafile/sysaux.257.867606039
+DATA2/dbora/datafile/system.256.867606009

SQL> select file_name from dba_temp_files;

FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/dbora/temp01.dbf

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/dbora/redo03.log
/u01/app/oracle/oradata/dbora/redo02.log
/u01/app/oracle/oradata/dbora/redo01.log

SQL> show parameter spfile ;

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
spfile         string  /u01/app/oracle/product/11.2/d
       b_1/dbs/spfiledbora.ora
SQL> show parameter control_file ;

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time      integer  7
control_files        string  +DATA/dbora/controlfile/curren
       t.256.867608667, +DATA2/dbora/
       controlfile/current.263.867608
       679

 SQL> ALTER TABLESPACE TEMP ADD TEMPFILE ;

Tablespace altered.

SQL> select file_name from dba_temp_files;

FILE_NAME
--------------------------------------------------------------------------------
+DATA2/dbora/tempfile/temp.264.867609077


SQL> SET SERVEROUTPUT ON;
DECLARE
   CURSOR rlc IS
      SELECT GROUP# GRP, THREAD# THR, BYTES, 'NO' SRL
      FROM   V$LOG
      UNION
      SELECT GROUP# GRP, THREAD# THR, BYTES, 'YES' SRL
      FROM   V$STANDBY_LOG
      ORDER BY 1;
   stmt     VARCHAR2(2048);
BEGIN
   FOR rlcRec IN rlc LOOP
      IF (rlcRec.srl = 'YES') THEN
         stmt := 'ALTER DATABASE ADD STANDBY LOGFILE THREAD ' ||
                 rlcRec.thr || ' SIZE ' || rlcRec.bytes;
         EXECUTE IMMEDIATE stmt;
         stmt := 'ALTER DATABASE DROP STANDBY LOGFILE GROUP ' || rlcRec.grp;
         EXECUTE IMMEDIATE stmt;
      ELSE
         stmt := 'ALTER DATABASE ADD LOGFILE THREAD ' ||
                 rlcRec.thr || ' SIZE ' ||  rlcRec.bytes;
         EXECUTE IMMEDIATE stmt;
         BEGIN
            stmt := 'ALTER DATABASE DROP LOGFILE GROUP ' || rlcRec.grp;
            DBMS_OUTPUT.PUT_LINE(stmt);
            EXECUTE IMMEDIATE stmt;
         EXCEPTION
            WHEN OTHERS THEN
               EXECUTE IMMEDIATE 'ALTER SYSTEM SWITCH LOGFILE';
               EXECUTE IMMEDIATE 'ALTER SYSTEM CHECKPOINT GLOBAL';
               EXECUTE IMMEDIATE stmt;
         END;
      END IF;
   END LOOP;
END;
/SQL>     

ALTER DATABASE DROP LOGFILE GROUP 1
ALTER DATABASE DROP LOGFILE GROUP 2
ALTER DATABASE DROP LOGFILE GROUP 3

PL/SQL procedure successfully completed.

SQL> SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA2/dbora/onlinelog/group_2.269.867609239
+DATA2/dbora/onlinelog/group_1.267.867609167
+DATA2/dbora/onlinelog/group_4.265.867609139
+DATA2/dbora/onlinelog/group_4.266.867609151
+DATA2/dbora/onlinelog/group_1.268.867609179
+DATA2/dbora/onlinelog/group_2.270.867609251

Back up archived redo log files, backup sets, and data file copies to Oracle ASM. For example, run the following command at the RMAN prompt:

RMAN> RUN
{
  ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
  ALLOCATE CHANNEL dev2 DEVICE TYPE DISK;
  ALLOCATE CHANNEL dev3 DEVICE TYPE DISK;
  ALLOCATE CHANNEL dev4 DEVICE TYPE DISK;

  BACKUP AS COPY ARCHIVELOG ALL DELETE INPUT;
  BACKUP BACKUPSET ALL DELETE INPUT;
  BACKUP AS COPY DATAFILECOPY ALL DELETE INPUT;
}

using target database control file instead of recovery catalog
allocated channel: dev1
channel dev1: SID=58 device type=DISK

allocated channel: dev2
channel dev2: SID=59 device type=DISK

allocated channel: dev3
channel dev3: SID=60 device type=DISK

allocated channel: dev4
channel dev4: SID=61 device type=DISK

Starting backup at 29-DEC-14
current log archived
channel dev1: starting archived log copy
input archived log thread=1 sequence=3 RECID=1 STAMP=867606655
channel dev2: starting archived log copy
input archived log thread=1 sequence=4 RECID=2 STAMP=867606867
channel dev3: starting archived log copy
input archived log thread=1 sequence=5 RECID=3 STAMP=867609204
channel dev4: starting archived log copy
input archived log thread=1 sequence=6 RECID=4 STAMP=867609456
output file name=+DATA2/dbora/archivelog/2014_12_29/thread_1_seq_4.272.867609463 RECID=5 STAMP=867609472
channel dev2: archived log copy complete, elapsed time: 00:00:21
channel dev2: deleting archived log(s)
archived log file name=/home/oracle/arch/arch_1_4_867594243.arc RECID=2 STAMP=867606867
output file name=+DATA2/dbora/archivelog/2014_12_29/thread_1_seq_5.273.867609467 RECID=6 STAMP=867609476
channel dev3: archived log copy complete, elapsed time: 00:00:20
channel dev3: deleting archived log(s)
archived log file name=/home/oracle/arch/arch_1_5_867594243.arc RECID=3 STAMP=867609204
output file name=+DATA2/dbora/archivelog/2014_12_29/thread_1_seq_6.274.867609471 RECID=7 STAMP=867609479
channel dev4: archived log copy complete, elapsed time: 00:00:18
channel dev4: deleting archived log(s)
archived log file name=/home/oracle/arch/arch_1_6_867594243.arc RECID=4 STAMP=867609456
output file name=+DATA2/dbora/archivelog/2014_12_29/thread_1_seq_3.271.867609459 RECID=8 STAMP=867609488
channel dev1: archived log copy complete, elapsed time: 00:00:37
channel dev1: deleting archived log(s)
archived log file name=/home/oracle/arch/arch_1_3_867594243.arc RECID=1 STAMP=867606655
Finished backup at 29-DEC-14

Starting backup at 29-DEC-14
channel dev1: input backup set: count=6, stamp=867606384, piece=1
channel dev1: starting piece 1 at 29-DEC-14
channel dev1: backup piece +DATA2/dbora/backupset/2014_12_29/nnsnn0_ora_asm_migration_0.261.867606385
channel dev2: input backup set: count=7, stamp=867606900, piece=1
channel dev2: starting piece 1 at 29-DEC-14
channel dev2: backup piece /u01/app/oracle/fast_recovery_area/DBORA/backupset/2014_12_29/o1_mf_nnsnf_TAG20141229T175459_bb2l0x3h_.bkp
piece handle=+DATA2/dbora/backupset/2014_12_29/nnnnf0_0.276.867609507 comment=NONE
channel dev1: finished piece 1 at 29-DEC-14
channel dev1: backup piece complete, elapsed time: 00:00:07
deleted backup piece
backup piece handle=+DATA2/dbora/backupset/2014_12_29/nnsnn0_ora_asm_migration_0.261.867606385 RECID=1 STAMP=867606384
piece handle=+DATA2/dbora/backupset/2014_12_29/nnnnf0_0.275.867609507 comment=NONE
channel dev2: finished piece 1 at 29-DEC-14
channel dev2: backup piece complete, elapsed time: 00:00:09
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/DBORA/backupset/2014_12_29/o1_mf_nnsnf_TAG20141229T175459_bb2l0x3h_.bkp RECID=2 STAMP=867606900
Finished backup at 29-DEC-14

Starting backup at 29-DEC-14
channel dev1: starting datafile copy
input is copy of datafile 00001: /u01/app/oracle/oradata/dbora/system01.dbf
channel dev2: starting datafile copy
input is copy of datafile 00002: /u01/app/oracle/oradata/dbora/sysaux01.dbf
channel dev3: starting datafile copy
input is copy of datafile 00003: /u01/app/oracle/oradata/dbora/undotbs01.dbf
channel dev4: starting datafile copy
input is copy of datafile 00004: /u01/app/oracle/oradata/dbora/users01.dbf
output file name=+DATA2/dbora/datafile/users.279.867609541 RECID=10 STAMP=867609562
channel dev4: datafile copy complete, elapsed time: 00:00:40
deleted datafile copy
datafile copy file name=/u01/app/oracle/oradata/dbora/users01.dbf RECID=9 STAMP=867608773
output file name=+DATA2/dbora/datafile/undotbs1.278.867609533 RECID=11 STAMP=867609567
channel dev3: datafile copy complete, elapsed time: 00:00:54
deleted datafile copy
datafile copy file name=/u01/app/oracle/oradata/dbora/undotbs01.dbf RECID=8 STAMP=867608771
output file name=+DATA2/dbora/datafile/sysaux.277.867609525 RECID=12 STAMP=867609831
channel dev2: datafile copy complete, elapsed time: 00:05:13
deleted datafile copy
datafile copy file name=/u01/app/oracle/oradata/dbora/sysaux01.dbf RECID=7 STAMP=867608769
output file name=+DATA2/dbora/datafile/system.261.867609525 RECID=13 STAMP=867609859
channel dev1: datafile copy complete, elapsed time: 00:05:37
deleted datafile copy
datafile copy file name=/u01/app/oracle/oradata/dbora/system01.dbf RECID=6 STAMP=867608768
Finished backup at 29-DEC-14
released channel: dev1
released channel: dev2
released channel: dev3
released channel: dev4


RMAN> report schema ;


using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name DBORA

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    700      SYSTEM               ***     +DATA2/dbora/datafile/system.256.867606009
2    550      SYSAUX               ***     +DATA2/dbora/datafile/sysaux.257.867606039
3    35       UNDOTBS1             ***     +DATA2/dbora/datafile/undotbs1.258.867606335
4    5        USERS                ***     +DATA2/dbora/datafile/users.260.867606381

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    100      TEMP                 32767       +DATA2/dbora/tempfile/temp.264.867609077

Get details about long running operations : v$session_longops


Getting the detail of long running queries:
Alter session set nls_date_format = 'DD-Mon-YYYY HH24:MI:SS' ;
set line 1000 
column OPNAME format a20
column target format a50

    
SELECT S.SID, sl.sql_id,opname,target, sl.last_update_time ,
elapsed_seconds/60 elepsed_min ,
time_remaining/60 time_rem_min ,  
((elapsed_seconds/(elapsed_seconds+time_remaining)) * 100 ) percent_complete 
FROM v$session_longops sl inner join v$session s 
ON sl.SID = s.SID AND sl.SERIAL# = s.SERIAL#
 WHERE time_remaining > 0 ;


Getting the SQLs of the above long running queries:
----------------------------------------------------
SELECT s.username,
       sl.sid,
       sq.executions,
       sq.sql_fulltext
  FROM v$session_longops sl
 INNER JOIN v$sql sq ON sq.sql_id = sl.sql_id
 INNER JOIN v$session s ON sl.SID = s.SID AND sl.serial# = s.serial#
 WHERE time_remaining > 0  ;



Sunday 28 December 2014

Automatic Storage Management : ASMCMD



ASMCMD is a command-line utility that you can use to easily view and manipulate files and directories within Automatic Storage Management (ASM) disk groups. It can list the contents of disk groups, perform searches, create and remove directories and aliases, display space utilization, and more.
You can specify the -p option with the asmcmd command to include the current directory in the ASMCMD prompt, as shown in the following example:

% asmcmd -p
ASMCMD [+] > cd dgroup1/mydir
ASMCMD [+DGROUP1/MYDIR] >
ASMCMD Command Reference:

ASM generates filenames according to the following scheme:
+diskGroupName/databaseName/fileType/fileTypeTag.file.incarnation

ASMCMD command attributes:
========================
cd  ---> Changes the current directory to the specified directory.
du  ---> Displays the total disk space occupied by ASM files in the specified ASM directory and all its subdirectories, recursively.
exit  ---> Exits ASMCMD.
find  ---> Lists the paths of all occurrences of the specified name (with wildcards) under the specified directory.
help  ---> Displays the syntax and description of ASMCMD commands.
ls  ---> Lists the contents of an ASM directory, the attributes of the specified file, or the names and attributes of all disk groups.
lsct  ---> Lists information about current ASM clients.
lsdg  ---> Lists all disk groups and their attributes.
mkalias  ---> Creates an alias for a system-generated filename.
mkdir  ---> Creates ASM directories.
pwd  ---> Displays the path of the current ASM directory.
rm  ---> Deletes the specified ASM files or directories.
rmalias  ---> Deletes the specified alias, retaining the file that the alias points to.
When you start ASMCMD, the current directory is set to root (+). For an ASM instance with two disk groups, dgroup1 and dgroup2, entering an lscommand with the root directory as the current directory produces the following output:
ASMCMD> ls
DGROUP1/
DGROUP2/

DU command:
============
This command is similar to the du -s command in UNIX. If you do not specify dir, information about the current directory is displayed. dir can contain wildcard characters.

The following two values are displayed, both in units of MB.

Used_MB—This value does not take the mirroring into account. Mirror_used_MB—This value takes mirroring into account.
For example, if a normal redundancy disk group contains 100 MB of data, then assuming that each file in the disk group is 2-way mirrored, Used_MB is 100 MB and Mirror_used_MB is roughly 200 MB.
The -H flag suppresses column headings from the output.
The following example shows disk space used in the SAMPLE directory in DGROUP1, including all directories below SAMPLE.
ASMCMD [+DGROUP1/SAMPLE] > du
Used_MB      Mirror_used_MB
   1251                2507

Find command:
==============
Displays the absolute paths of all occurrences of the specified name (with wildcards) in a specified directory and its subdirectories.
Syntax and Description
find [-t type] dir name
This command searches the specified directory and all subdirectories below it in the directory tree for the supplied name. name can be a directory name or a filename, and can include wildcard characters. dir may also include wildcards. In the output of the command, directory names are suffixed with the slash character (/) to distinguish them from filenames.
You use the -t flag to find all the files of a particular type (specified as type). For example, you can search for control files by specifying type as CONTROLFILE. Valid values for type are the following:
CONTROLFILE
DATAFILE
ONLINELOG
ARCHIVELOG
TEMPFILE
BACKUPSET
DATAFILE
PARAMETERFILE
DATAGUARDCONFIG
FLASHBACK
CHANGETRACKING
DUMPSET
AUTOBACKUP
XTRANSPORT
Examples
The following example searches the dgroup1 disk group for files that begin with 'undo':
ASMCMD> find +dgroup1 undo*
+dgroup1/SAMPLE/DATAFILE/UNDOTBS1.258.555341963
+dgroup1/SAMPLE/DATAFILE/UNDOTBS1.272.557429239
The following example returns the absolute path of all the control files in the +dgroup1/sample directory.
ASMCMD> find -t CONTROLFILE +dgroup1/sample *
+dgroup1/sample/CONTROLFILE/Current.260.555342185
+dgroup1/sample/CONTROLFILE/Current.261.555342183
ls command:
===========
Lists the contents of an ASM directory, the attributes of the specified file, or the names and attributes of all disk groups.
Syntax and Description
ls [-lsdrtLaH] [name]
name can be a filename or directory name, including wildcard characters.
If name is a directory name, ASMCMD lists the contents of the directory, and, depending on flag settings, information about each directory member. Directories are listed with a trailing slash (/) to distinguish them from files.
If name is a filename, ASMCMD lists the file, and, depending on flag settings, information about the file. The file must be located in the current directory if the filename is specified with a relative path.
Command flags enable you to modify and customize the output of the command. The following table lists the flags and their descriptions.
Flag Description
(none)  Displays only filenames and directory names.
-l    ------> Displays extended file information, including striping and redundancy attributes and whether the file was system-generated (indicated by Y under the SYS column) or user-created (as in the case of an alias, indicated by N under the SYS column). When used in the "ls -l +" command, displays extended disk group information. Note that not all possible file attributes or disk group attributes are included. To view the complete set of attributes for a file or a disk group, query the V$ASM_FILE and V$ASM_DISKGROUP views.
-s  ---------> Displays file space information.
-d If the name argument is a directory, displays information about that directory, rather than the directory contents. Typically used with another flag, such as the -l flag.
-r -------->  Reverses the sort order of the listing.
-t  ---------> Sorts the listing by timestamp (latest first) instead of by name.
-L If ------> the name argument is an alias, displays information on the file that it references. Typically used with another flag, such as the -l flag.
-a  ---------> For each listed file, displays the absolute path of the alias that references it, if any.
-H  -------> Suppresses column headings.
If you specify all flags, then the command shows a union of their attributes, with duplicates removed. If you enter ls +, then the command returns information on all disk groups, including whether or not they are mounted.
Examples
ASMCMD [+DGROUP1/SAMPLE/DATAFILE] > ls
EXAMPLE.269.555342243
SYSAUX.257.555341961
SYSTEM.256.555341961
UNDOTBS1.258.555341963
UNDOTBS1.272.557429239
USERS.259.555341963
ASMCMD [+DGROUP1/SAMPLE/DATAFILE] > ls -l
Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   APR 18 19:16:07  Y    EXAMPLE.269.555342243
DATAFILE  MIRROR  COARSE   MAY 09 22:01:28  Y    SYSAUX.257.555341961
DATAFILE  MIRROR  COARSE   APR 19 19:16:24  Y    SYSTEM.256.555341961
DATAFILE  MIRROR  COARSE   MAY 05 12:28:42  Y    UNDOTBS1.258.555341963
DATAFILE  MIRROR  COARSE   MAY 04 17:27:34  Y    UNDOTBS1.272.557429239
DATAFILE  MIRROR  COARSE   APR 18 19:16:07  Y    USERS.259.555341963
ASMCMD [+DGROUP1/SAMPLE/DATAFILE] > ls -lt
Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   MAY 09 22:01:28  Y    SYSAUX.257.555341961
DATAFILE  MIRROR  COARSE   MAY 05 12:28:42  Y    UNDOTBS1.258.555341963
DATAFILE  MIRROR  COARSE   MAY 04 17:27:34  Y    UNDOTBS1.272.557429239
DATAFILE  MIRROR  COARSE   APR 19 19:16:24  Y    SYSTEM.256.555341961
DATAFILE  MIRROR  COARSE   APR 18 19:16:07  Y    USERS.259.555341963
DATAFILE  MIRROR  COARSE   APR 18 19:16:07  Y    EXAMPLE.269.555342243

ASMCMD [+DGROUP1/SAMPLE/DATAFILE] > ls -l undo*
Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   MAY 05 12:28:42  Y    UNDOTBS1.258.555341963
DATAFILE  MIRROR  COARSE   MAY 04 17:27:34  Y    UNDOTBS1.272.557429239

ASMCMD [+DGROUP1/SAMPLE/DATAFILE] > ls -s
Block_Size  Blocks      Bytes       Space  Name
      8192   12801  104865792   214958080  EXAMPLE.269.555342243
      8192   48641  398467072   802160640  SYSAUX.257.555341961
      8192   61441  503324672  1011875840  SYSTEM.256.555341961
      8192    6401   52436992   110100480  UNDOTBS1.258.555341963
      8192   12801  104865792   214958080  UNDOTBS1.272.557429239
      8192     641    5251072    12582912  USERS.259.555341963
ASMCMD [+DGROUP1] > ls +DGROUP1/SAMPLE
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfilesample.ora
ASMCMD [+DGROUP1] > ls -l +DGROUP1/SAMPLE
Type  Redund  Striped  Time  Sys Name
                             Y   CONTROLFILE/
                             Y   DATAFILE/
                             Y   ONLINELOG/
                             Y   PARAMETERFILE/
                             Y   TEMPFILE/
                             N   spfilesample.ora=>
                              +DGROUP1/SAMPLE/PARAMETERFILE/spfile.270.555342443
ASMCMD [+DGROUP1] > ls -r +DGROUP1/SAMPLE
spfilesample.ora
TEMPFILE/
PARAMETERFILE/
ONLINELOG/
DATAFILE/
CONTROLFILE/
ASMCMD [+DGROUP1] > ls -lL example_df2.f
Type      Redund  Striped  Time          Sys  Name
DATAFILE  MIRROR  COARSE   APR 27 11:04  N    example_df2.f => +DGROUP1/SAMPLE/DATAFILE/EXAMPLE.271.556715087
ASMCMD [+DGROUP1] > ls -a +DGROUP1/SAMPLE/DATAFILE/EXAMPLE.271.556715087
+DGROUP1/example_df2.f => EXAMPLE.271.556715087
ASMCMD [+DGROUP1] > ls -lH +DGROUP1/SAMPLE/PARAMETERFILE
PARAMETERFILE  MIRROR  COARSE   MAY 04 21:48  Y    spfile.270.555342443
ASMCMD [+DGROUP1] > ls -l +
State    Type    Rebal  Unbal  Name
MOUNTED  NORMAL  N      N      DGROUP1/
MOUNTED  NORMAL  N      N      DGROUP2/
MOUNTED  EXTERN  N      N      DGROUP3/
lsct command:
=============
Lists information about current ASM clients. A client is a database that uses disk groups managed by the ASM instance that ASMCMD is currently connected to.
Syntax and Description
lsct [-H] [group]
If group is specified, information about only that disk group is displayed. The -H flag suppresses column headings.
Example
This example displays information about the client accessing the dgroup1 disk group.
ASMCMD [+] > lsct dgroup1
DB_Name   Status        Software_Version  Compatible_version  Instance_Name
sample    CONNECTED           10.2.0.0.0          10.2.0.0.0  sample
lsdg command:
==============
Purpose
Lists all disk groups and their attributes.
Syntax and Description
lsdg [-H] [group]
Attribute Name Description
State Mounted/connected state of the disk group
Type Disk group redundancy (NORMAL, HIGH, EXTERNAL)
Rebal Y if a rebalance operation is in progress
Unbal Y if the disk group is in need of rebalancing
Sector Sector size in bytes
Block Block size in bytes
AU Allocation Unit size in bytes
Total_MB Size of the disk group in MB
Free_MB Free space in the disk group in MB, without regard to redundancy. From the V$ASM_DISKGROUP view.
Req_mir_free_MB Amount of space that must be available in the disk group to restore full redundancy after the worst failure that can be tolerated by the disk group. This is the REQUIRED_MIRROR_FREE_MB column from the V$ASM_DISKGROUP view.
Usable_file_MB Amount of free space, adjusted for mirroring, that is available for new files. From the V$ASM_DISKGROUP view.
Offline_disks Number of offline disks in the disk group. Offline disks are eventually dropped.
If group is specified, information about only that disk group is listed. The -H flag suppresses column headings.
Example
The following example lists the attributes of the dgroup2 disk group.
ASMCMD [+] > lsdg dgroup2
State    Type    Rebal  Unbal  Sector  Block       AU  Total_MB  Free_MB
Req_mir_free_MB  Usable_file_MB  Offline_disks  Name
MOUNTED  NORMAL  N      N         512   4096  1048576      4096     1208
           1024              92              0  DGROUP2/
mkalias command:
================
Purpose
Creates an alias for the specified system-generated filename.
mkalias file alias
alias must be in the same disk group as the system-generated file. Only one alias is permitted for each ASM file.
The SQL*Plus equivalent of the mkalias command is:
ALTER DISKGROUP dg_name ADD ALIAS user_alias FOR file
Example
The following example creates the sysaux.f alias for the fully qualified filename +DGROUP1/SAMPLE/DATAFILE/SYSAUX.257.555341961.
ASMCMD [+DGROUP1/SAMPLE/DATAFILE] > mkalias SYSAUX.257.555341961 sysaux.f
ASMCMD [+DGROUP1/SAMPLE/DATAFILE] > ls -a
none => EXAMPLE.269.555342243
+DGROUP1/SAMPLE/DATAFILE/sysaux.f => SYSAUX.257.555341961
none => SYSTEM.256.555341961
none => UNDOTBS1.258.555341963
none => UNDOTBS1.272.557429239
none => USERS.259.555341963
sysaux.f
mkdir command:
==============
Creates ASM directories under the current directory.
mkdir dir [dir] . . .
The current directory can be a system-created or user-created directory. You cannot create a directory at the root (+) level.
The SQL*PLUS equivalent of the mkdir command is ALTER DISKGROUP dg_name ADD DIRECTORY dir, dir . . .
Example
The following example creates the directories subdir1 and subdir2 at the disk group level in the disk group dgroup1.
ASMCMD [+DGROUP1] > mkdir subdir1 subdir2
ASMCMD [+DGROUP1] > ls
SAMPLE/
example_df2.f
subdir1/
subdir2/
pwd command:
=============
Displays the absolute path of the current directory.
ASMCMD> pwd
+dgroup1/sample/controlfile

rm command
===========
Purpose
Deletes the specified ASM files and directories.
Syntax and Description
rm [-rf] name [name] . . .
If name is a file or alias, rm can delete it only if it is not currently in use by a client database. If name is a directory, rm can delete it only if it is empty (unless the -r flag is used) and it is not a system-generated directory. If name is an alias, rm deletes both the alias and the file that the alias references. (To delete just an alias and retain the file that the alias references, use the rmalias command.)
Note:
The SQL*Plus equivalents of the rm command are:
ALTER DISKGROUP ... DROP FILE
ALTER DISKGROUP ... DROP DIRECTORY
If you use a wildcard, rm deletes all matches except non-empty directories (unless the -r flag is used).
To recursively delete, use the -r flag. This enables you to delete a non-empty directory, including all files and directories in it and in the entire directory tree underneath it.
If you use the -r flag or a wildcard character, rm prompts you to confirm deletion before proceeding, unless you specify the -f flag.If a wildcard character matches an alias or a system-generated file that has an alias, both the alias and the system-generated file that it references are deleted. When using the -r flag, either the system-generated file or the alias needs to be present in the directory in which you run the rm command.
For example, if you have a user alias, +dg1/dir1/file.alias that points to +dg/ORCL/DATAFILE/System.256.146589651, then running the rm -r +dg1/dir1 command will remove +dg1/dir1/file.alias as well as +dg/ORCL/DATAFILE/System.256.146589651.
The following example deletes the alias alias293.f.
ASMCMD [+DGROUP1/SAMPLE/DATAFILE] > rm alias293.f
rmalias command
=============
Purpose
Deletes the specified aliases, retaining the files that the aliases reference.
rmalias [-r] alias [alias] . . .
The SQL*Plus equivalent of the rmalias command is:
ALTER DISKGROUP dg_name DROP ALIAS user_alias
To recursively delete, use the -r flag. This enables you to delete all aliases in the current directory and in the entire directory tree beneath the current directory. If any user-created directories become empty as a result of deleting aliases, they are deleted also. System-created files and directories are not deleted.
The following example deletes the alias sysaux.f, retaining the datafile that it references.
ASMCMD [+DGROUP1/SAMPLE/DATAFILE] > rmalias sysaux.f
lsdsk Command
================
Purpose
List the disks that are visible to ASM, using the V$ASM_DISK_STAT and V$ASM_DISK views. The V$ASM_DISK_STAT view is used by default.
lsdsk [-ksptagcHI] [-d diskg_roup_name] [pattern]
pattern restricts the output to only disks that matches the pattern specified. Wild-card characters and slashes (/ or \) can be part of the pattern. See "Wildcard Characters".
The k, s, p, and t flags modify how much information is displayed for each disk. If any combination of the flags are specified, then the output shows the union of the attributes associated with each flag. The flags are described in Table 7-7.
This command can run in connected or non-connected mode. The connected mode is always attempted first. The -I option forces the non-connected mode.
In connected mode, ASMCMD uses dynamic views to retrieve disk information.

In non-connected mode, ASMCMD scans disk headers to retrieve disk information, using an ASM disk string to restrict the discovery set.
(none)
Displays the PATH column of the V$ASM_DISK view.
-k
Displays the TOTAL_MB, FREE_MB, OS_MB,NAME, FAILGROUP, LIBRARY, LABEL, UDID, PRODUCT, REDUNDANCY, and PATH columns of the V$ASM_DISK view.
-s
Displays the READS, WRITES, READ_ERRS, WRITE_ERRS, READ_TIME, WRITE_TIME, BYTES_READ, BYTES_WRITTEN, and the PATH columns of the V$ASM_DISK view.
-p
Displays the GROUP_NUMBER, DISK_NUMBER, INCARNATION, MOUNT_STATUS, HEADER_STATUS, MODE_STATUS, STATE, and the PATH columns of the V$ASM_DISK view.
-t
Displays the CREATE_DATE, MOUNT_DATE, REPAIR_TIMER, and the PATH columns of the V$ASM_DISK view.
-g
Selects from GV$ASM_DISK_STAT, or from GV$ASM_DISK if the -c flag is also specified. GV$ASM_DISK.INST_ID is included in the output.
-c
Selects from V$ASM_DISK, or from GV$ASM_DISK if the -g flag is also specified. This option is ignored if the ASM instance is version 10.1 or earlier.
-H
Suppresses column headings.
-I
Scans disk headers for information rather than extracting the information from an ASM instance. This option forces the non-connected mode.
-d
Restricts results to only those disks that belong to the group specified by disk_group_name.
ASMCMD> lsdsk -k -d DATA *_0001
ASMCMD> lsdsk -s -d DATA *_0001
ASMCMD> lsdsk -t -d DATA *_0001
ASMCMD> lsdsk -C -t -d DATA *_0001
ASMCMD> lsdsk -g -t -d DATA *_0001

Saturday 27 December 2014

Find size of a table and Associated segments ( index , lob )

COLUMN TABLE_NAME FORMAT A32
COLUMN OBJECT_NAME FORMAT A32
COLUMN OWNER FORMAT A10

SELECT
   owner, table_name,segment_type, TRUNC(sum(bytes)/1024/1024/1024) Size_GB
    FROM
      (SELECT segment_name table_name, owner, bytes ,segment_type
       FROM dba_segments  WHERE segment_type = 'TABLE'
UNION ALL
     SELECT i.table_name, i.owner, s.bytes ,segment_type FROM dba_indexes i, dba_segments s
      WHERE s.segment_name = i.index_name AND   s.owner = i.owner
     AND   s.segment_type = 'INDEX'
UNION ALL
    SELECT l.table_name, l.owner, s.bytes ,segment_type
    FROM dba_lobs l, dba_segments s
    WHERE s.segment_name = l.segment_name
    AND   s.owner = l.owner
    AND   s.segment_type = 'LOBSEGMENT'
  UNION ALL
 SELECT l.table_name, l.owner, s.bytes ,segment_type
    FROM dba_lobs l, dba_segments s
    WHERE s.segment_name = l.index_name
    AND   s.owner = l.owner
    AND   s.segment_type = 'LOBINDEX')
WHERE owner ='&owner'
   and table_name='&table'
   GROUP BY owner,table_name,segment_type
   ORDER BY SUM(bytes) desc
  /


OWNER      TABLE_NAME          SEGMENT_TYPE          SIZE_GB
---------- -------------------------------- ------------------ -------------------------
SUMIT     TABLE_BIG                   LOBSEGMENT                3196
SUMIT     TABLE_BIG                   TABLE                               121
SUMIT     TABLE_BIG                   INDEX                                111
SUMIT     TABLE_BIG                   LOBINDEX                         51



Friday 26 December 2014

Create Asm diskgroups using ASMCA


Check the disks on both nodes node1 and node2 using the below command : 

[root@node1 ~]# oracleasm listdisks
DATA
FRA
OCR_VOTE

[root@node2 ~]# oracleasm listdisks
DATA
FRA
OCR_VOTE

Now login to grid user on node1 or node2 and run the command .

[grid@node1] asmca





click on create -->

Disk Group Name       : DATA
Redundancy                :External
Select Member Disks: Eligible
Select the disk path : /dev/oracleasm/disks/DATA and click OK






click on create -->

Disk Group Name       : FRA
Redundancy                :External
Select Member Disks: Eligible
Select the disk path : /dev/oracleasm/disks/FRA and click OK




SQL> select name,total_mb/1024 "total_gb" , free_mb/1024 "free_gb" from v$asm_diskgroup;

NAME total_gb                 free_gb
-------------------------------------------------------------------
OCR_VOTE         5.77539063        5.48535156
FRA          3.1015625         2.77832031
DATA          6.19628906       2.50585938

SQL> select MOUNT_STATUS,HEADER_STATUS,MODE_STATUS,OS_MB,TOTAL_MB,FREE_MB, NAME from v$asm_disk ;

MOUNT_S    HEADER_STATU  MODE_ST  OS_MB   TOTAL_MB    FREE_MB NAME
------- ------------ ------- -------- ---------- ---------- ---------- ------------------------------ ----------------------
CACHED MEMBER         ONLINE        3176       3176                2845      FRA_0000  
CACHED MEMBER         ONLINE         6345       6345                 2556      DATA_0000
CACHED MEMBER         ONLINE          5914       5914                  5617  OCR_VOTE_0000  

SQL>

Create Shareable ASM disks on Oracle virtual box

Create 3 shared disks for ASM:
========================

Power off both node1 and node2 .

Add 3 new disks on node1 and make them shareable . After that add these disks to node2 also .

Settings->storage->Controller:SATA-Add disk -> Create new disk




Hard Drive file type = VDI



Storage on physical hard drive = Fixed sized




File Location and Size : H:\ASM_SHARED_DISK\asm_disk_1.vdi

Similarly create 2 mode asm diks "asm_disk_2.vdi" and "asm_disk_3.vdi" screenshots below:






Storage : After Adding 3 asm_disks.



Now we need to make these asm disks sharable. Open Virtual Media Manager -

Select asm_disk_1 -> Click on Modify ->



Select asm_disk_1 -> Click on Modify -> Shareable -> ok



 Repeat the above for other 2 disks:

Select asm_disk_2  -> Click on Modify -> Shareable -> ok
Select asm_disk_3 -> Click on Modify -> Shareable -> ok

Attach these shareable "ask_disks_*"  existing disk to node2 VM using "Storage" page. Don't forget to select correct controller before attaching the disk and use "Choose existing disk" option.

on node 2 add shareable disks screenshot below:

Settings->storage->Controller:SATA->Add disks ->choose existing diks





[root@node1 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x81d9944a.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-281, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-281, default 281):
Using default value 281

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.


[root@node1 ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xdd8c70c4.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-535, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-535, default 535):
Using default value 535

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@node1 ~]#
[root@node1 ~]# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x104efb19.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-522, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522):
Using default value 522

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.


Check Permission of disks :

[root@oracle11g ~]# ls -lrth /dev/sd*
brw-rw---- 1 root disk 8,  0 Jan 11 12:25 /dev/sda
brw-rw---- 1 root disk 8,  2 Jan 11 12:25 /dev/sda2
brw-rw---- 1 root disk 8,  1 Jan 11 12:25 /dev/sda1
brw-rw---- 1 root disk 8, 48 Jan 11 18:12 /dev/sdd
brw-rw---- 1 root disk 8, 16 Jan 11 18:12 /dev/sdb
brw-rw---- 1 root disk 8, 32 Jan 11 18:12 /dev/sdc
brw-rw---- 1 root disk 8, 49 Jan 11 18:12 /dev/sdd1
brw-rw---- 1 root disk 8, 17 Jan 11 18:12 /dev/sdb1
brw-rw---- 1 root disk 8, 33 Jan 11 18:12 /dev/sdc1
[root@oracle11g ~]#
[root@oracle11g ~]# fdisk -l

Disk /dev/sda: 25.8 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000beb7a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        3134    24652800   8e  Linux LVM

Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe961556e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         391     3140676   83  Linux

Disk /dev/sdc: 5754 MB, 5754306560 bytes
255 heads, 63 sectors/track, 699 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x12fdc659

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         699     5614686   83  Linux

Disk /dev/sdd: 5754 MB, 5754306560 bytes
255 heads, 63 sectors/track, 699 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xeeb628c4

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         699     5614686   83  Linux

Disk /dev/mapper/vg_sumit-lv_root: 23.7 GB, 23668457472 bytes
255 heads, 63 sectors/track, 2877 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_sumit-lv_swap: 1572 MB, 1572864000 bytes
255 heads, 63 sectors/track, 191 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


[root@node1 ~]# oracleasm createdisk ocr_vote /dev/sdb1
Writing disk header: done
Instantiating disk: done
[root@node1 ~]# oracleasm createdisk DATA /dev/sdc1
Writing disk header: done
Instantiating disk: done
[root@node1 ~]# oracleasm createdisk FRA /dev/sdd1
Writing disk header: done
Instantiating disk: done
[root@node1 ~]# oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
[root@node1 ~]# oracleasm listdisks
DATA
FRA
OCR_VOTE
[root@node1 ~]#


on node 2:
root@node2's password:
[root@node2 ~]# oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
Instantiating disk "OCR_VOTE"
Instantiating disk "DATA"
Instantiating disk "FRA"
[root@node2 ~]# oracleasm listdisks
DATA
FRA
OCR_VOTE
[root@node2 ~]#