Thursday, January 9, 2025

Storage optimization using acfs

 Problem statement:Lets assume you have a production database of 50 TB in size in and you maintain it in ASM file system with normal redundancy.This implies your storage utilization is 100 TB.In addition you maintain full size several copies of non-production (like dev,test,uat,pre-prod etc) as required by project team. So at some point of time you will reach in a situation where your storage has exceeded warning threshold. How will you handle this situation?

Solution: This problem can be solved using oracle acfs filesystem.Please see below link for detailed documentation

https://www.oracle.com/a/tech/docs/acfs-snapshot-best-practices.pdf

  • Create database clone from production database using acfs file system.That will work as a master database.
  • Create a snapshot database out of it in same acfs file system for your non-prod environments.

Initially snapshot created from master database will have only some metadata information.If you make changes in master database only the changed block will be copied to the snapshot file system so that snapshot db has consistent data.Basically it uses copy on write mechanism for this storage snapshot.

Without giving big lectures lets walk in the ground of reality.Please find below technical steps which will guide you to prepare to adopt this approach.

Technical steps:

1.      Create 3 volumes like below

asmcmd volcreate -G data -s 5120G DATA

asmcmd volcreate -G reco -s 500G RECO

asmcmd volcreate -G data -s 200G REDO

 

2.      Create file system out of that volume

 

asmcmd  volinfo -G DATA DATA

Diskgroup Name: DATA

 

         Volume Name: DATA

         Volume Device: /dev/asm/data-132

         State: ENABLED

         Size (MB): 5242880

         Resize Unit (MB): 64

         Redundancy: MIRROR

         Stripe Columns: 8

         Stripe Width (K): 1024

         Usage:

         Mountpath:

/sbin/mkfs -t acfs /dev/asm/data-132

mkfs.acfs: version                   = 19.0.0.0.0

mkfs.acfs: on-disk version           = 46.0

mkfs.acfs: volume                    = /dev/asm/data-132

mkfs.acfs: volume size               = 5497558138880  (   5.00 TB )

mkfs.acfs: Format complete.

 

asmcmd  volinfo -G RECO RECO

Diskgroup Name: RECO

 

         Volume Name: RECO

         Volume Device: /dev/asm/reco-262

         State: ENABLED

         Size (MB): 512000

         Resize Unit (MB): 64

         Redundancy: MIRROR

         Stripe Columns: 8

         Stripe Width (K): 1024

         Usage:

         Mountpath:

/sbin/mkfs -t acfs /dev/asm/reco-262

mkfs.acfs: version                   = 19.0.0.0.0

mkfs.acfs: on-disk version           = 46.0

mkfs.acfs: volume                    = /dev/asm/reco-262

mkfs.acfs: volume size               = 536870912000  ( 500.00 GB )

mkfs.acfs: Format complete.

               asmcmd  volinfo -G DATA REDO

               Diskgroup Name: DATA

               Volume Name: REDO

               Volume Device: /dev/asm/redo-132

               State: ENABLED

               Size (MB): 204800

               Resize Unit (MB): 64

               Redundancy: MIRROR

               Stripe Columns: 8

                Width (K): 1024

               Usage:

               Mountpath:   

/sbin/mkfs -t acfs /dev/asm/redo-132

               mkfs.acfs: version                   = 19.0.0.0.0

mkfs.acfs: on-disk version           = 46.0

mkfs.acfs: volume                    = /dev/asm/redo-132

mkfs.acfs: volume size               = 214748364800  ( 200.00 GB )

mkfs.acfs: Format complete.

 

3.      Create below mount point from root user

mkdir /data;chown oracle:dba /data;ls -ldr /data

drwxr-xr-x 2 oracle dba 4096 Jan  7 14:13 /data

mkdir /reco;chown oracle:dba /reco;ls -ldr /reco

drwxr-xr-x 2 oracle dba 4096 Jan  7 14:15 /reco

mkdir /redo;chown oracle:dba /redo;ls -ldr /redo

4.      Mount the acfs file syetm using below command

grep grid /u01/app/oraInventory/ContentsXML/inventory.xml

<HOME NAME="OraGrid19000" LOC="/u01/app/19.0.0.0/grid" TYPE="O" IDX="1" CRS="true"/>

 

/u01/app/19.0.0.0/grid/bin/srvctl add filesystem -device /dev/asm/data-132 -path /data -user oracle -mountowner oracle -mountgroup dba -mountperm 755

 

/u01/app/19.0.0.0/grid/bin/srvctl add filesystem -device /dev/asm/reco-262 -path /reco -user oracle -mountowner oracle -mountgroup dba -mountperm 755

 

/u01/app/19.0.0.0/grid/bin/srvctl add filesystem -device /dev/asm/redo-132 -path /redo -user oracle -mountowner oracle -mountgroup dba -mountperm 755

5.      Start the acfs file system

/u01/app/19.0.0.0/grid/bin/srvctl start filesystem -d /dev/asm/data-132

/u01/app/19.0.0.0/grid/bin/srvctl start filesystem -d /dev/asm/reco-262

/u01/app/19.0.0.0/grid/bin/srvctl start filesystem -d /dev/asm/redo-132

 

 

 

6.      Check the acfs file system status

/u01/app/19.0.0.0/grid/bin/crsctl stat res ora.data.data.acfs ora.data.redo.acfs ora.reco.reco.acfs -t

--------------------------------------------------------------------------------

Name           Target  State        Server                   State details

--------------------------------------------------------------------------------

Local Resources

--------------------------------------------------------------------------------

ora.data.data.acfs

               ONLINE  ONLINE       testoda01a              mounted on /data,

                                                             STABLE

               ONLINE  ONLINE       testsoda01b              mounted on /data,

                                                             STABLE

ora.data.redo.acfs

               ONLINE  ONLINE       testoda01a              mounted on /redo,

                                                             STABLE

               ONLINE  ONLINE       testoda01b              mounted on /redo,

                                                             STABLE

ora.reco.reco.acfs

               ONLINE  ONLINE       testoda01a              mounted on /reco,

                                                             STABLE

               ONLINE  ONLINE       testoda01b              mounted on /reco,

                                                             STABLE

 

df -h | grep

/dev/asm/data-132                5.0T   11G  5.0T   1% /data

/dev/asm/reco-262                500G  1.6G  499G   1% /reco

/dev/asm/redo-132                200G 1020M  200G   1% /redo

7.      Downloade gDBclone rpm using below link provided in gDBClone Powerful Database Clone/Snapshot Management Tool (Doc ID 2099214.1)

https://support.oracle.com/epmos/faces/ui/patch/PatchDetail.jspx?parent=DOCUMENT&sourceId=2099214.1&patchId=36589212

8.      Identify DB home to use for clone

/opt/gDBClone/gDBClone.bin listhomes

INFO: 2025-01-07 14:50:50: Please check the logfile '/opt/gDBClone/out/log/gDBClone_2758.log' for more details

 

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

 gDBClone - Version: 3.0.6-18

 Copyright (c) 2012-2024 Oracle and/or its affiliates.

 --------------------------------------------------------

 Author: Ruggero Citton <ruggero.citton@oracle.com>

 RAC Pack, Cloud Innovation and Solution Engineering Team

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

 

Oracle Home Name      Home Location

----------------      ------------

OraDB19000_home1      /u01/app/oracle/product/19.0.0.0/dbhome_1

9.      Create password file which can be used later

/opt/gDBClone/gDBClone.bin syspwf -syspwf /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/orapwMSTR

 

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

 gDBClone - Version: 3.0.6-18

 Copyright (c) 2012-2024 Oracle and/or its affiliates.

 --------------------------------------------------------

 Author: Ruggero Citton <ruggero.citton@oracle.com>

 RAC Pack, Cloud Innovation and Solution Engineering Team

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

Please enter the password to encrypt:

Please re-enter the password to encrypt:

 

SYS password file created as /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/orapwMSTR

10.  Use below command to clone from source database

/opt/gDBClone/gDBClone.bin clone -sdbname cist4.world -sbckloc /orabak5z/tusldoda01a/rman/CIST4  -tdbname mstr -tdbhome OraDB19000_home1 -dataacfs /data -redoacfs /redo -recoacfs /reco -racmod 0 -channels 8 -syspwf /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/orapwMSTR

INFO: 2025-01-07 15:13:06: Please check the logfile '/opt/gDBClone/out/log/gDBClone_75659.log' for more details

NOTE: Here I have used backup based duplication and that is why used parameter sbckloc

 

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

 gDBClone - Version: 3.0.6-18

 Copyright (c) 2012-2024 Oracle and/or its affiliates.

 --------------------------------------------------------

 Author: Ruggero Citton <ruggero.citton@oracle.com>

 RAC Pack, Cloud Innovation and Solution Engineering Team

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

 

 

MacroStep1 - Getting information and validating setup...

INFO: 2025-01-08 14:51:53: Validating environment

INFO: 2025-01-08 14:51:53: Checking superuser usage

INFO: 2025-01-08 14:51:53: Checking 'mstr' target database name

INFO: 2025-01-08 14:51:53: Checking target database home 'OraDB19000_home1' existence

INFO: 2025-01-08 14:51:53: Checking if Oracle Restart

INFO: 2025-01-08 14:51:53: Checking source backup location /orabak5z/tusldoda01a/rman/CIST4...

INFO: 2025-01-08 14:51:53: Getting ORACLE_BASE path from orabase

INFO: 2025-01-08 14:51:53: Checking target database 'mstr' existence

INFO: 2025-01-08 14:51:53: Checking target database 'mstr' registered instance

INFO: 2025-01-08 14:51:55: Checking ACFS snapshot 'mstr' existence under '/data'

INFO: 2025-01-08 14:51:56: Checking listener on 'tuslsoda01:1521'

INFO: 2025-01-08 14:51:56: Checking ACFS options

INFO: 2025-01-08 14:51:56: ...checking if dataacfs '/data' is an ACFS file system

INFO: 2025-01-08 14:51:56: ...checking if redoacfs '/redo' is an ACFS file system

INFO: 2025-01-08 14:51:56: ...checking if recoacfs '/reco' is an ACFS file system

SUCCESS: 2025-01-08 14:51:59: Environment validation complete

 

MacroStep2 - Setting up clone environment...

INFO: 2025-01-08 14:51:59: Creating local pfile

INFO: 2025-01-08 14:51:59: Creating local password file

INFO: 2025-01-08 14:51:59: Creating local Audit folder

INFO: 2025-01-08 14:51:59: Checking local auxiliary listener existence

INFO: 2025-01-08 14:51:59: Creating local auxiliary listener

INFO: 2025-01-08 14:51:59: Starting auxiliary listener

INFO: 2025-01-08 14:51:59: Sleeping 60 secs, please wait...

INFO: 2025-01-08 14:52:59: Setting up ACFS storage

INFO: 2025-01-08 14:52:59: Creating RMAN dynamic scripts

INFO: 2025-01-08 14:53:00: Cloning to target ACFS from backup location '/orabak5z/tusldoda01a/rman/CIST4'

INFO: 2025-01-08 14:53:00: ...creating RMAN duplicate script

INFO: 2025-01-08 14:53:00: ...creating RMAN spfile script

INFO: 2025-01-08 14:53:00: Creating RMAN script for spfile target to ACFS

INFO: 2025-01-08 14:53:00: Instantiating clone database

SUCCESS: 2025-01-08 14:53:00: Environment setup complete

 

MacroStep3 - Cloning database 'cist4.world'...

INFO: 2025-01-08 14:53:00: Database clone from backup in progress, please wait...

INFO: 2025-01-08 14:53:00:    (this can take a while depending on database size and/or network speed)

INFO: 2025-01-08 14:53:00:    (rman spool file '/opt/gDBClone/out/log/rman_clone_79140.log')

INFO: 2025-01-08 16:18:58: Create PFile from SPFile

INFO: 2025-01-08 16:20:15: Register 'mstr' database as cluster resource

INFO: 2025-01-08 16:20:16: Creating password file for 'mstr'

INFO: 2025-01-08 16:20:16: Register ACFS passwordfile '/data/.ACFS/snaps/mstr/MSTR/password/orapwmstr'

INFO: 2025-01-08 16:20:17: Updating SPFile

INFO: 2025-01-08 16:20:20: Updating local pfile

INFO: 2025-01-08 16:20:20: Modifying DB instance

INFO: 2025-01-08 16:20:21: Setup ACFS dependency

WARNING: 2025-01-08 16:20:24: Copy '/u01/app/oracle/product/19.0.0.0/dbhome_1/network/admin/tnsnames.ora' to remote node 'tuslsoda01a' failed

INFO: 2025-01-08 16:20:24: Starting database : mstr

SUCCESS: 2025-01-08 16:20:43: Clone database 'mstr' created successfully

 

INFO: 2025-01-08 16:20:43: Starting database 'mstr'

SUCCESS: 2025-01-08 16:20:44: Successfully created clone database 'mstr'

You have new mail in /var/spool/mail/root

11.   Check new database using tool

/opt/gDBClone/gDBClone.bin listdbs

INFO: 2025-01-08 16:25:16: Please check the logfile '/opt/gDBClone/out/log/gDBClone_75342.log' for more details

 

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

 gDBClone - Version: 3.0.6-18

 Copyright (c) 2012-2024 Oracle and/or its affiliates.

 --------------------------------------------------------

 Author: Ruggero Citton <ruggero.citton@oracle.com>

 RAC Pack, Cloud Innovation and Solution Engineering Team

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

 

Database Name    Database Type   Database Role      Master/Snapshot  Location/Parent

-------------    -------------   -------------      ---------------  ---------------

oemtest          SINGLE          PRIMARY            Master           /u02/app/oracle/oradata

mstr          SINGLE          PRIMARY            Master           /data/.ACFS/snaps/


 

12.  Create a snap db using the tool

/opt/gDBClone/gDBClone.bin snap -sdbname mstr -tdbname dev -tdbhome "OraDB19000_home1" -racmod 0 -syspwf /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/orapwMSTR

 

 

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

 gDBClone - Version: 3.0.6-18

 Copyright (c) 2012-2024 Oracle and/or its affiliates.

 --------------------------------------------------------

 Author: Ruggero Citton <ruggero.citton@oracle.com>

 RAC Pack, Cloud Innovation and Solution Engineering Team

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

 

 

MacroStep1 - Getting information and validating setup...

INFO: 2025-01-08 16:30:23: Checking whether the database 'mstr' is on Exascale

INFO: 2025-01-08 16:30:25: Checking whether the database 'mstr' is on ACFS snapshot

INFO: 2025-01-08 16:30:28: Validating environment...

INFO: 2025-01-08 16:30:28: Superuser usage check

INFO: 2025-01-08 16:30:28: Clusterware running check

INFO: 2025-01-08 16:30:28: Oracle Restart check

INFO: 2025-01-08 16:30:28: Minimum crs activeversion check

INFO: 2025-01-08 16:30:28: Checking source database 'mstr' existence

INFO: 2025-01-08 16:30:28: Checking source database 'mstr' if running

INFO: 2025-01-08 16:30:29: ...checking if target database home 'OraDB19000_home1' exists

INFO: 2025-01-08 16:30:29: Checking source database 'mstr' connectivity

INFO: 2025-01-08 16:30:34: Checking source database 'mstr' and target dbhome version

INFO: 2025-01-08 16:30:39: Checking target database 'dev' name

INFO: 2025-01-08 16:30:39: Checking target database 'dev' existence

INFO: 2025-01-08 16:30:39: Checking target database 'dev' registered instance

INFO: 2025-01-08 16:30:43: Checking target database 'dev' exists as ACFS snapshot in '/data'

INFO: 2025-01-08 16:30:43: Checking if source database 'mstr' is snapable...

INFO: 2025-01-08 16:30:44: ...checking whether the database 'mstr' is entirely on ACFS

INFO: 2025-01-08 16:30:46: ...checking whether the database 'mstr' is a primary/physical standby database.

INFO: 2025-01-08 16:30:47: ...checking whether the database 'mstr' is in rw/ro mode

INFO: 2025-01-08 16:30:50: ...checking whether the database 'mstr' is a multitenant

INFO: 2025-01-08 16:30:55: ...checking whether the database 'mstr' is running as backup mode

INFO: 2025-01-08 16:30:58: ...checking whether the database 'mstr' is running in archivelog mode

INFO: 2025-01-08 16:31:00: ...checking whether all database 'mstr' datafiles are available

INFO: 2025-01-08 16:31:03: ...checking if there are offline datafiles

SUCCESS: 2025-01-08 16:31:05: Environment validation complete

 

MacroStep2 - Getting database ACFS snapshot...

INFO: 2025-01-08 16:31:05: Cloning source database 'mstr' using ACFS snapshot

INFO: 2025-01-08 16:31:21: Entering into SNAP database creation phase 1

INFO: 2025-01-08 16:31:21: ...getting required information to get consistent database snapshot

WARNING: 2025-01-08 16:31:26: Do not perform any structural change to database 'mstr' till snapshot database 'dev' is created

INFO: 2025-01-08 16:31:33: ...getting the snapshot of Database 'mstr' at this time

INFO: 2025-01-08 16:31:33: ...successfully took the ACFS snapshot 'dev' of database 'mstr' on '/data'

INFO: 2025-01-08 16:31:37: ...setting up storage for SNAP Database 'dev'

INFO: 2025-01-08 16:31:50: Entering into SNAP database creation phase 2

INFO: 2025-01-08 16:31:50: ...creating controlfile for database 'dev'

INFO: 2025-01-08 16:32:23: ...recovering the database: dev, snapshot time : '2025-01-08:16:31:33', until 'change:39241811117184'

INFO: 2025-01-08 16:32:34: ...opening the database with resetlogs

INFO: 2025-01-08 16:32:49: ...setting the temporary tablespace for database 'dev'

INFO: 2025-01-08 16:35:06: ...creating spfile for 'dev'

INFO: 2025-01-08 16:35:08: ...Creating pfile for 'dev'

INFO: 2025-01-08 16:35:10: Creating password file for 'dev'

INFO: 2025-01-08 16:35:10: Entering into SNAP database creation phase 3

INFO: 2025-01-08 16:35:19: ...starting database 'dev'

INFO: 2025-01-08 16:35:40: ...successfully started the database

INFO: 2025-01-08 16:35:42: ...setting RMAN SNAPSHOT control file

INFO: 2025-01-08 16:35:47: ...disabling the external references in the database 'dev' inherited from 'mstr'

------------------------------------------------------------------------------

Run on the database 'dev' the SQL script:

 '/u01/app/oracle/product/19.0.0.0/dbhome_1/enable_external_refs_dev_CN5r.sql'

to enable these external references.

Also need to restart the database after running the SQL script.

------------------------------------------------------------------------------

INFO: 2025-01-08 16:37:12: Enabling block change tracking for database 'dev'

INFO: 2025-01-08 16:37:16: Setup ACFS dependency

SUCCESS: 2025-01-08 16:37:20: Snapshot database 'dev' created successfully

INFO: 2025-01-08 16:37:20: Starting database 'dev'

SUCCESS: 2025-01-08 16:37:21: Successfully started clone database 'dev'

Now emphasize in below output where master snap has size of 5.35 TB where as snapshot ccbdev is consuming only 514 GB

 acfsutil snap info /ccbdata

snapshot name:               ccbmstr

snapshot location:           /data/.ACFS/snaps/ccbmstr

RO snapshot or RW snapshot:  RW

parent name:                 /data

snapshot creation time:      Wed Jan  8 14:52:59 2025

file entry table allocation: 8781824   (   8.38 MB )

storage added to snapshot:   5885571432448   (   5.35 TB )

snapshot name:               ccbdev

snapshot location:           /data/.ACFS/snaps/ccbdev

RO snapshot or RW snapshot:  RW

parent name:                 ccbmstr

snapshot creation time:      Wed Jan  8 16:31:33 2025

file entry table allocation: 8781824   (   8.38 MB )

storage added to snapshot:   551938048000   ( 514.03 GB )

    number of snapshots:  2

    kilosnap state:       ENABLED

    snapshot space usage: 6440485769216  (   5.86 TB )

 df -h /data

Filesystem            Size  Used Avail Use% Mounted on

/dev/asm/data-132  9.0T  5.9T  3.1T  66% /data

Please mind that mstr DB size is around 5 TB so ideally if we clone another database out of it /data will run out of space but due to snapshot mechanism it consumes only 514 GB.

I hope this will work as a good strater if you have similar problem in your company.


Happy learning...



When SQL plan baseline is not used

 Thank you very much for your interest. Problem Statement: Lets assume you are reported about an application query running slow in one envir...