ASM spfile operations

While playing with ASM in Oracle 12c i’ve ended up looking some details of the internal package DBMS_DISKGROUP. This package is an internal ASM Oracle library used for asmcmd implementation. For a list of available procedures (12c in this particular case) use the following:

[oracle@baco grid]$ find $ORACLE_HOME -name asmcmd* | xargs grep dbms_diskgroup

dbms_diskgroup.getfileattr(:fileName, :fileType, :fileSz, :blkSz);
dbms_diskgroup.mapextent(:fname, :extnum, :mapcount, :extsize, ...);
dbms_diskgroup.mapau(:gnum, :disk, :au, :file, :extent, :xsn);
dbms_diskgroup.dropdir('$dir');
dbms_diskgroup.createclientcluster (:clname, :direct_access);
dbms_diskgroup.getfileattr(:fileName, :fileType, :fileSz, :blkSz);
dbms_diskgroup.copy('', '', '', :src_path, :src_ftyp, :src_blksz,...);
dbms_diskgroup.getfileattr(:src_path, :fileType, :fileSz, :blkSz);
dbms_diskgroup.asmcopy(:src_path, :dst_name, :spfile_number,...);
dbms_diskgroup.gpnpsetds(:ds_path,0);
dbms_diskgroup.remap($gnum, $fnum, $vxn);

Sometime ago, i’ve wrote something about tracing asmcmd cp command using sql*net tracing, but today what got my attention was dbms_diskgroup.asmcopy. This procedure is used in asmcmdsys.pm ($GRID_HOME/lib/) and implements three different asmcmd commands: spcopy, spmove and spbackup. All these asmcmd commands handle only ASM SPFILE operations and no other operations. All other copy operations using asmcmd are handled by dbms_diskgroup.copy procedure. A deeper look in asmcmdsys.pm shows the use of asmcopy procedure and its parameters, including spfile_number(2) parameter that specifies the asm file number.

 my ($spfile_number) = 253;
...
 $sth = $dbh->prepare(q{
     begin
       dbms_diskgroup.asmcopy(:src_path, :dst_name, :spfile_number,
                              :fileType, :blkSz, :spfile_number2,
                              :spfile_type, :client_mode);
     exception when others then
       raise;
     end;
     });

...
  $sth->bind_param( ":spfile_number", $spfile_number);
...
  $sth->bind_param( ":spfile_number2", $spfile_number);

The ASM file number 253 seen in the top perl declaration represents the ASM spfile (that is why it is hardcoded). It is easily seen using my amap script:

SQL> @amap metadata DATA
DISKNUMBER FILENUMBER FILE EXTENT NUMBER	  METADATA DESC 	EXTENT MIRRORING RELATIVE AU POSITION
---------- ---------- ------------------ ------------------------------ ---------------- --------------------
	 0 1	      0 		 FILE DIRECTORY 		PRIMARY EXT	 2
	 1 1	      1 		 FILE DIRECTORY 		PRIMARY EXT	 31

	 1 9	      0 		 ATTRIBUTE DIRECTORY		PRIMARY EXT	 25
	 1 253	      0 		 ASM SPFILE			PRIMARY EXT	 30

There is nothing extraordinary with this post, just one more way to debug and understand the asmcmd commands when they may not return what you expect 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s