Saturday, 27 February 2016

ACFS SNAPSHOT


Demonstrate you on how to secure your ADVM Volumes by creating a snapshot copy of it.
A snapshot copy is a widely used concept with Storage Vendors, where they use it to reduce backup and recovery
time.

Snapshot Copy is the read only copy of a partition at a particular point in time. It doesn't take much time to create the snapshot partition regardless of the size or use of the partition. Thus it gives good amount of benefit for large sized partition.

Utility used to create acfs snapshot is acfsutil, once a snapshot is creates a read only copy of the partition is made 
and would be accessible from inside the .ACFS directory

Volume Allocation Unit (VAU) if the stripe column is 4 and AU is 1 MB
64 MB is the size of extenet

[root@rac1 advm]# acfsutil snap create snap_01 /advm
acfsutil snap create: Snapshot operation is complete.

[root@rac1 advm]# cd /advm

[root@rac1 advm]# ls -la
total 102500
drwxr-xr-x  4 oracle dba       4096 Oct  6 16:37 .
drwxr-xr-x 36 root   root      4096 Oct  6 16:11 ..
-rw-r--r--  1 oracle dba         57 Oct  6 16:30 a
drwxr-xr-x  5 root   root      4096 Oct  6 15:50 .ACFS
-rw-r--r--  1 root   root        61 Oct  6 16:37 check
drwx------  2 root   root     65536 Oct  6 15:50 lost+found
-rw-r-----  1 oracle dba  104865792 Oct  6 16:21 testnew01.dbf

# cd .ACFS/snaps/snap_01

# ls -ltr
total 102420
?--------- ? ?      ?            ?            ? lost+found
-rw-r----- 1 oracle dba  104865792 Oct  6 16:21 testnew01.dbf
-rw-r--r-- 1 oracle dba         57 Oct  6 16:30 a
-rw-r--r-- 1 root   root        61 Oct  6 16:37 check

# pwd
/advm/.ACFS/snaps/snap_01

# cd /advm

[root@rac1 advm]# ls -ltr
total 102484
drwx------ 2 root   root     65536 Oct  6 15:50 lost+found
-rw-r----- 1 oracle dba  104865792 Oct  6 16:21 testnew01.dbf
-rw-r--r-- 1 oracle dba         57 Oct  6 16:30 a
-rw-r--r-- 1 root   root        61 Oct  6 16:37 check

[root@rac1 advm]# vi check

[root@rac1 advm]# cat check
Step 1 : Checking Files
Step 2 : Before we create a snaphost
step 3 : After creating the snapshot

[root@rac1 advm]# rm check
rm: remove regular file `check'? y

# cd .ACFS/snaps/snap_01

# ls -ltr
total 102420
?--------- ? ?      ?            ?            ? lost+found
-rw-r----- 1 oracle dba  104865792 Oct  6 16:21 testnew01.dbf
-rw-r--r-- 1 oracle dba         57 Oct  6 16:30 a
-rw-r--r-- 1 root   root        61 Oct  6 16:37 check

[root@rac1 advm snap_01]# cp check /advm

[root@rac1 advm snap_01]# cd /advm

[root@rac1 advm]# ls -ltr
total 102484
drwx------ 2 root   root     65536 Oct  6 15:50 lost+found
-rw-r----- 1 oracle dba  104865792 Oct  6 16:21 testnew01.dbf
-rw-r--r-- 1 oracle dba         57 Oct  6 16:30 a
-rw-r--r-- 1 root   root        61 Oct  6 16:40 check

[root@rac1 advm]# acfsutil info fs
/advm
    ACFS Version: 11.2.0.1.0.0
    flags:        MountPoint,Available
    mount time:   Thu Oct  6 15:50:23 2011
    volumes:      1
    total size:   268435456
    total free:   58609664
    primary volume: /dev/asm/tvol-200
        label:
        flags:                 Primary,Available,ADVM
        on-disk version:       39.0
        allocation unit:       4096
        major, minor:          252, 102401
        size:                  268435456
        free:                  58609664
        ADVM diskgroup         ABC
        ADVM resize increment: 268435456
        ADVM redundancy:       unprotected
        ADVM stripe columns:   4
        ADVM stripe width:     131072
    number of snapshots:  1
    snapshot space usage: 40960

/orcl
    ACFS Version: 11.2.0.1.0.0
    flags:        MountPoint,Available
    mount time:   Thu Oct  6 16:11:13 2011
    volumes:      1
    total size:   2147483648
    total free:   71909376
    primary volume: /dev/asm/orclvol-200
        label:
        flags:                 Primary,Available,ADVM
        on-disk version:       39.0
        allocation unit:       4096
        major, minor:          252, 102402
        size:                  2147483648
        free:                  71909376
        ADVM diskgroup         ABC
        ADVM resize increment: 268435456
        ADVM redundancy:       unprotected
        ADVM stripe columns:   4
        ADVM stripe width:     131072
    number of snapshots:  1
    snapshot space usage: 470855680

# ls -tlr
total 102484
drwx------ 2 root   root     65536 Oct  6 15:50 lost+found
-rw-r----- 1 oracle dba  104865792 Oct  6 16:21 testnew01.dbf
-rw-r--r-- 1 oracle dba         57 Oct  6 16:30 a
-rw-r--r-- 1 root   root       110 Oct  6 16:41 check

# acfsutil snap delete snap_01 /advm
acfsutil snap delete: Snapshot operation is complete. 

# acfsutil snap create snapnew /advm
acfsutil snap create: Snapshot operation is complete.

# cd /advm

# ls -tlr
total 102484
drwx------ 2 root   root     65536 Oct  6 15:50 lost+found
-rw-r----- 1 oracle dba  104865792 Oct  6 16:21 testnew01.dbf
-rw-r--r-- 1 oracle dba         57 Oct  6 16:30 a
-rw-r--r-- 1 root   root       110 Oct  6 16:41 check

# cd .ACFS/snaps/snapnew

# ls -ltr
total 102420
?--------- ? ?      ?            ?            ? lost+found
-rw-r----- 1 oracle dba  104865792 Oct  6 16:21 testnew01.dbf
-rw-r--r-- 1 oracle dba         57 Oct  6 16:30 a
-rw-r--r-- 1 root   root       110 Oct  6 16:41 check


Check the video to understand it on a practical note.


-       Multiple snapshot
[root@rac1 advm]# acfsutil snap create snap_01 /advm
[root@rac1 advm]# acfsutil snap create snap_02 /advm
[root@rac1 advm]# acfsutil snap create snap_03 /advm
[root@rac1 advm]# acfsutil snap create snap_04 /advm





Queries

------------------------------------------------------------------------------------------------
To identify the file system which are allocated through the ACFS
------------------------------------------------------------------------------------------------
col FS_NAME format a15
select * from V$ASM_FILESYSTEM;

-----------------------------------------------------------------------------------------------------
To know about the mount point and volumes allocated in the ACFS
-----------------------------------------------------------------------------------------------------
col FS_NAME format a15
col VOL_DEVICE format a15
col VOL_LABEL format a15    
select * from v$asm_acfsvolumes;

----------------------------------------------------------------------------------------------------------------
TO understand more about the current volume statistics for ACFS volumes
----------------------------------------------------------------------------------------------------------------
col VOLUME_NAME format a15
select * from V$ASM_VOLUME_STAT;

col VOLUME_NAME format a15
col USAGE format a15
col MOUNTPATH  format a15
select VOLUME_NAME,SIZE_MB,STRIPE_COLUMNS,USAGE,MOUNTPATH from v$asm_volume;

-----------------------------------------------------------------------------------------------------------------------------------
In side the ASMCMD tool, we can find about the volumes through the below commands
-----------------------------------------------------------------------------------------------------------------------------------
volcreate
voldelete
voldisable
volenable
volinfo
volresize
volset
volstat

ADVM (ASM Dynamic Volume Manager)

In 11g R2 New Feature

ADVM volume is created in ASM diskgroup. You can use "ALTER DISKGROUP ADD VOLUME" or "asmcmd volcreate" commands.

ACFS file system is created in ADVM volume with "mkfs -t acfs" command.
After this you can manage it with "acfsutil" command.


NOTE: In simple word prior to 12c non-database file (like Vedios, Doc., mp4 ..etc) only Stored in ACFS and after 12c onword non-database file + database files are stored in ACFS.

A new device driver which is integrated into the Oracle Kernel called ASM Dynamic Volume Manager (ADVM) is loaded at ASM startup and functions as a standard I/O interface for normal file systems to utilize ASM functionalities.

This driver communicates with the ASM instance about ASM extent maps, rebalancing operations and I/O failure issues.
Files used as ASM Disks are not supported by ADVM. For example on NetApp Filer only real disks or Netapp Devices using ISCSI, SCSI or Fibre Channel can be used.

For the first version of ADVM Oracle Corporation claims to support up to  64 million files per file system, and up to 64 mounts on 32 bit systems, and 256 mounts on 64 bit systems.


ADVM is also integrated with new commands for the asmcmd interface.
*. volcreate
*. voldelete
*. voldisable
*. volenable
*. volinfo
*. volresize
*. volset

The new diskgroup attribute COMPATIBLE.ADVM must be set 11.2 as well as COMPATIBLE.ASM to add a new volume.



Oracle has introduced ADVM ( ASM Dynamic Volume Manager in 11g R2 ), this feature allow DBA's / SA to create a dynamic volume
out of an existing diskgroup and mount it like a normal partition to store files inside it ( Not necessarily a database file ).

Benefits of Using ADVM 

ADVM will benefit from Mirroring and striping done at the ASM Level.
ADVM allows to use ACFS Snapshots to ensure quick recovery of data in case of failure.

See how to create ADVM managed volumes

You need to have compatible set to 11.2.0 at diskgroup level before you proceed with volume creation.


$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Thu Oct 6 15:46:05 2011

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Enter user-name: / as sysasm

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Automatic Storage Management option


SQL> col NAME for a10
SQL> col COMPATIBILITY for a15
SQL> col DATABASE_COMPATIBILITY for a15
SQL> select GROUP_NUMBER,NAME,COMPATIBILITY,DATABASE_COMPATIBILITY,VOTING_FILES from v$asm_diskgroup;



SQL> alter diskgroup TEST set attribute 'compatible.asm'='11.2.0';
 Diskgroup altered.


SQL> alter diskgroup TEST set attribute 'compatible.rdbms'='11.2.0';
 Diskgroup altered.

SQL> exit


Now check at the asmcmd level with volume information
  

$ asmcmd
ASMCMD> volinfo -a
no volumes found

Now create a volume out of the existing diskgroup TEST


ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB Name
MOUNTED  EXTERN  N         512   4096  1048576      2048     1972                0            1972 TEST/
MOUNTED  NORMAL  N         512   4096  1048576      9216     5705              883            2411 DATA/
MOUNTED  EXTERN  N         512   4096  1048576      9216     8982                0            8982 FRA/

ASMCMD> volcreate -G TEST -s 256M TVOL

ASMCMD> volinfo -a
Diskgroup Name: TEST

         Volume Name: TVOL
         Volume Device: /dev/asm/tvol-77
         State: ENABLED
         Size (MB): 256
         Resize Unit (MB): 256
         Redundancy: UNPROT
         Stripe Columns: 4
         Stripe Width (K): 128
         Usage:
         Mountpath:

ASMCMD>
ASMCMD> exit

Now you need to login through root user and run the mkfs and mount command at the server with the new volume created above


su -
Password:
$ ls -ltr /dev/asm/tvol-77
brwxrwx--- 1 root dba 252, 102401 Oct  6 15:49 /dev/asm/tvol-77

-- ACFS Stands for ASM Cluster file System

[root@rac1 bin]# mkfs -t acfs /dev/asm/tvol-77
mkfs.acfs: version                   = 11.2.0.1.0.0
mkfs.acfs: on-disk version           = 39.0
mkfs.acfs: volume                    = /dev/asm/tvol-77
mkfs.acfs: volume size               = 268435456
mkfs.acfs: Format complete.

[root@rac1 bin]#

# mkdir /advm
# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5             113G   48G   59G  46% /
/dev/sda2              23M  6.7M   15M  31% /boot
tmpfs                 1.2G  430M  723M  38% /dev/shm
/dev/sda1              30G   11G   20G  35% /mnt/cdrive


Now mount the recently created partition out of diskgroup

# mount -t acfs /dev/asm/tvol-77 /advm
# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5             113G   48G   59G  46% /
/dev/sda2              23M  6.7M   15M  31% /boot
tmpfs                 1.2G  430M  723M  38% /dev/shm
/dev/sda1              30G   11G   20G  35% /mnt/cdrive
/dev/asm/tvol-200     256M   37M  220M  15% /advm

# cd advm
# ls -ltr
total 102484
drwx------ 2 root   root     65536 Oct  6 15:50 lost+found

# chown -R oracle:dba /advm

So Now you could see a partition created with the name advm and you can utilize it for storing file. 
in the next step we would be logging from database instance and we would create a tablespace with 
datafile in advm partition.



$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Thu Oct 6 15:51:22 2011
Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Enter user-name: / as sysdba

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> create tablespace TESTNEW datafile '/advm/testnew01.dbf' size 100M;
 Tablespace created.


SQL> create table t1  tablespace testnew as select * from t;
 Table created.

SQL> exit


Now login from the ASM instance and see volinfo -a


 asmcmd
ASMCMD> volinfo -a
Diskgroup Name: TEST

         Volume Name: TVOL
         Volume Device: /dev/asm/tvol-77
         State: ENABLED
         Size (MB): 256
         Resize Unit (MB): 256
         Redundancy: UNPROT
         Stripe Columns: 4
         Stripe Width (K): 128
         Usage: ACFS
         Mountpath: /advm

ASMCMD>

the last lines shows that this volume is mounted as ADVM with the use of ACFS file system.



-------- Install again driver ---------

 ] # ./acfsroot  install

su – oracle

grid_env

asmcmd

--Enable ACFS volume

Volinfo –h

lsdg

volenable –G TEST –a

[root@rac1 bin]# mount -t acfs /dev/asm/tvol-77 /advm