Manage Your Snapshot Databases

Manage your snapshot databases to use the most current thin clone database and delete outdated snapshots.

Create a Snapshot Database

Create a snapshot database from the Test Master.

If the Test Master is a physical standby, then the Test Master database must be in MOUNTED state. If it is in READ Only mode, change it to MOUNTED before creating a snapshot database. This isn't required when the Test Master is created with RMAN active duplication or RMAN backup from production.
  1. Define the parameters and create a snapshot database.
    Use the following gDBClone options to define the snapshot:
    • -sdbname: Source Database Name
    • -tdbname: Target Database Name
    • -tdbhome: Target Database Home
    • -racmod: Oracle RAC type. Use 0 for an Oracle Single Instance database.
    • -syspwf: SYS encrypted password file
    [root@tstmstr gDBClone]# /opt/gDBClone/gDBClone snap -sdbname TSTMSTR -tdbname TSTDEV -tdbhome OraDB12102_home2 -racmod 0 -syspwf /opt/gDBClone/SYS.password
  2. Run the post snapshot creation script SQL to enable external references.
    
    SQL> /u01/app/oracle/product/12.1.0.2/dbhome_2/enable_external_refs_TSTDEV_jTEm.sql
  3. Restart the database.
    [oracle@tstmstr ~]$ srvctl stop database
          -d TSTMSTR[oracle@tstmstr ~]$ srvctl start database -d TSTMSTR
  4. Update the environment for the snapshot database.
    [oracle@tstmstr ~]$ srvctl getenv database -d TSTDEV
    TSTDEV:
    [oracle@tstmstr ~]$ srvctl setenv database -d TSTDEV -envs "ORACLE_UNQNAME=TSTDEV,TZ=UTC"
    [oracle@tstmstr ~]$ srvctl getenv database -d TSTDEV
    TSTDEV:
    ORACLE_UNQNAME=TSTDEV
    TZ=UTC
  5. Check TDE wallet status in snapshot database.
    The utility automatically copies the TDE wallet files from the Test Master to the snapshot database.
    SQL> set linesize 180
    SQL> col wrl_parameter format a80
    SQL> 
    SQL> select * from v$encryption_wallet;
    
    WRL_TYPW  WRL_PARAMETER					    STATUS   WALLET_TYPE  WALLET_OR FULLY_BAC CON_ID
    -------- --------------------------------------------------  ------- ------------- --------- ----------- ------
    FILE	/opt/oracle/dcs/commonstore/wallets/tde/TSTDEV/    OPEN     UNKNOWN      SINGLE     NO         0
    SQL> 
  6. Check the Snapshot database environment and status. Validate the snapshot database and display snap details to confirm that the parameters are correct.
    The snapshot should be in READ WRITE mode.
    [oracle@tstmstr ~]$ . oraenv
    ORACLE_SID = [oracle] ? TSTDEV
    The Oracle base has been set to /u01/app/oracle
    [oracle@tstmstr ~]$ sqlplus / as sysdba
    
    SQL> select name,open_mode from v$database;
    
    SQL> select file_name from dba_data_files;
  7. Display a list of databases to confirm that the snapshot appears in the list.
    [root@tstmstr gDBClone]# /opt/gDBClone/gDBClone listdbs
    Database Name    Database Type   Database Role      Master/Snapshot  Location/Parent
    -------------    -------------   -------------      ---------------  ---------------
    TSTDEV           SINGLE          PRIMARY            Snapshot         TSTMSTR        
    ORCL_iad1hb      SINGLE          PRIMARY            n/a              ASM            
    TSTMSTR          SINGLE          PRIMARY            Master           /u02/app/oracle/oradata/TSTMSTR/.ACFS/snaps/
    To display the parent child relationship of the databases, use the -tree option.
    # /opt/gDBClone/gDBClone listdbs -tree
    Parent	Child
    ------	-----
    TSTMSTR
    	      TSTDEV
  8. (Optional) Change the snapshot database's PDB name.
    When you create a snapshot, the snapshot database and the production database have the same PDB name. For development and test environments, you can change the snapshot database PDB name to match the environment. For example, change PDB1 to PDBDEV.
    
    [oracle@tstmstr ~]$ sqlplus / as sysdba
    
    SQL*Plus: Release 12.1.0.2.0 Production on Thu Oct 3 07:52:30 2019
    
    Copyright (c) 1982, 2014, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 12c EE High Perf Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Real Application Clusters, OLAP, Advanced Analytics
    and Real Application Testing options
    
    SQL> select name,open_mode from v$database;
    
    NAME	  OPEN_MODE
    --------- --------------------
    TSTDEV   READ WRITE
    
    SQL> alter pluggable database PDB1 close immediate;
    
    Pluggable database altered.
    
    SQL> alter pluggable database PDB1 open restricted;
    
    Pluggable database altered.
    
    SQL> alter session set container=PDB1;
    
    Session altered.
    
    SQL> alter pluggable database PDB1 rename global_name to PDBDEV;
    
    Pluggable database altered.
     
    SQL> connect / as sysdba
    Connected.
    SQL> show pdbs
    
        CON_ID CON_NAME		       OPEN MODE  RESTRICTED
    ---------- ---------------------------- ---------- ----------
    	 2 PDB$SEED			  MOUNTED
    	 3 PDBDEV			    READ WRITE YES
    SQL> alter pluggable database PDBDEV close immediate;
    
    Pluggable database altered.
    
    SQL> alter pluggable database PDBDEV open;
    
    Pluggable database altered.
    
    SQL> show pdbs
    
        CON_ID CON_NAME			  OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
    	 2 PDB$SEED			  MOUNTED
    	 3 PDBDEV			  READ WRITE NO
    
You can create additional snapshots, as needed, and rename the PDB names to reflect the environment.

Display a List of Snapshot Databases

Display details of your snapshot databases that are on Oracle ASM Cluster File System (Oracle ACFS), including the creation date, location, and the amount of storage allocated to the snapshot.

For fewer details, you can display a list of snapshots and the associated Test Master. In this example, TSTMSTR is the Test Master server and the snapshot database is TSTDEV.
  1. Log into the Test Master Server as opc , then sudo to root.
  2. Display the snapshot databases that are on Oracle ACFS.
    [root@tstmstr gDBClone]# /opt/gDBClone/gDBClone listsnaps -dataacfs /u02/app/oracle/oradata/TSTMSTR 
    snapshot name: TSTMSTR
    snapshot location: /u02/app/oracle/oradata/TSTMSTR/.ACFS/snaps/TSTMSTR
    RO snapshot or RW snapshot: RW
    parent name: /u02/app/oracle/oradata/TSTMSTR
    snapshot creation time: Wed Oct  9 07:42:06 2019
    file entry table allocation: 8650752 ( 8.25 MB )
    storage added to snapshot:   4295647232 ( 4.00 GB )
    
    snapshot name: TSTDEV
    snapshot location: /u02/app/oracle/oradata/TSTMSTR/.ACFS/snaps/TSTDEV
    RO snapshot or RW snapshot: RW
    parent name: TSTMSTR
    snapshot creation time: Wed Oct  9  07:58:14 2019
    file entry table allocation: 8650752   ( 8.25 MB )
    storage added to snapshot: 250892288   ( 239.27 MB )    
    number of snapshots: 2    
    snapshot space usage: 4550168576  ( 4.24 GB )
    [root@tstmstr gDBClone]#
        
  3. (Optional) Display a list of databases by using the listdbs command, or use the listdbs -tree command to display a Test Master database and the associated snap clone databases.
    If you use the listdbs -tree command, the databases appear in a tree format showing the relationship of parent and child databases.
    
    [root@sdbm1 gDBClone]# /opt/gDBClone/gDBClone listdbs -tree
    Parent  Child
    ------  -----
    SDBM2
            SDBC1
    

Delete a Snapshot Database

Delete and unregister a snapshot database.

To create a fresh snapshot from the Test Master, delete the existing snapshot and create a new snapshot using the method that you configured to clone your production database.
  1. Log into the Test Master Server as opc , then sudo to root.
  2. Delete and unregister the snapshot database. Enter Y to confirm that you want to delete, or drop, the database.
    If you don't use the -force option, the Oracle Database Configuration Assistant (DBCA) deletes the database.
    [root@tstmstr gDBClone]# /opt/gDBClone deldb -tdbname TESTDEV -syspwf /opt/gDBClone/SYS.password -force
  3. (Optional) Display a list of databases and confirm that the deleted database does not appear in the list.
    root@tstmstr gDBClone]# /opt/gDBClone/gDBClone listdbs