Snapshot Databases in Oracle Database Appliance

 * Defining ORACLE_HOME:

[root@oda01 ~]# oakcli show dbhomes
Oracle Home Name      Oracle Home version                  Home Location
OraDb11204_home1      11.2.0.4.6(20299013,20420937)       /u01/app/oracle/product/11.2.0.4/dbhome_1
OraDb12102_home2      12.1.0.2.3(20299023,20299022)       /u01/app/oracle/product/12.1.0.2/dbhome_2
OraDb12102_home1      12.1.0.2.160719(23054246,23054327)  /u01/app/oracle/product/12.1.0.2/dbhome_1
root@oda01 ~]# oakcli show databases
DB01   RAC        ASM       OraDb12102_home1     /u01/app/oracle/product/12.1.0.2/dbhome_1          12.1.0.2.160719(23054246,23054327)
DB02   RAC        ASM       OraDb12102_home1     /u01/app/oracle/product/12.1.0.2/dbhome_1          12.1.0.2.160719(23054246,23054327)
 [grid@oda01 ~]$ asmcmd lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  NORMAL  N         512   4096  4194304   7372800  1478768           368640          555064              0             Y  DATA/
MOUNTED  NORMAL  N         512   4096  4194304   9796800  6419444           489840         2964802              0             N  RECO/
MOUNTED  HIGH    N         512   4096  4194304    763120   373600           381560           -2653              0             N  REDO/

* Create Test Database:

oakcli create database -db TSTSNAP -oh OraDb12102_home1
Pwd: oracle123
Please select one of the following for Database type  [1 .. 3] :
1    => OLTP
2    => DSS
3    => In-Memory
option: 1
Please select one of the following for Database Deployment  [1 .. 3] :
1    => EE : Enterprise Edition
2    => RACONE
3    => RAC
option: 3

Please select one of the following for Database Class  [1 .. 6] :
1    => odb-01s  (   1 cores ,     4 GB memory)
2    =>  odb-01  (   1 cores ,     8 GB memory)
3    =>  odb-02  (   2 cores ,    16 GB memory)
4    =>  odb-04  (   4 cores ,    32 GB memory)
5    =>  odb-06  (   6 cores ,    48 GB memory)
6    =>  odb-12  (  12 cores ,    96 GB memory)
option: 1
[root@oda01 ~]# oakcli show databases
DB01     RAC        ASM       OraDb12102_home1     /u01/app/oracle/product/12.1.0.2/dbhome_1          12.1.0.2.160719(23054246,23054327)
DB02     RAC        ASM       OraDb12102_home1     /u01/app/oracle/product/12.1.0.2/dbhome_1          12.1.0.2.160719(23054246,23054327)
TSTSNAP  RAC        ACFS      OraDb12102_home1     /u01/app/oracle/product/12.1.0.2/dbhome_1          12.1.0.2.160719(23054246,23054327) <---
 [root@oda01 ~]# srvctl config database -d TSTSNAP
Database unique name: TSTSNAP
Database name: TSTSNAP
Oracle home: /u01/app/oracle/product/12.1.0.2/dbhome_1
Oracle user: oracle
Spfile: /u02/app/oracle/oradata/datastore/.ACFS/snaps/TSTSNAP/TSTSNAP/spfileTSTSNAP.ora
Password file: /u02/app/oracle/oradata/datastore/.ACFS/snaps/TSTSNAP/TSTSNAP/orapwTSTSNAP
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups:
Mount point paths: /u01/app/oracle/oradata/datastore,/u02/app/oracle/oradata/datastore,/u01/app/oracle/fast_recovery_area/datastore
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: racoper
Database instances: TSTSNAP1,TSTSNAP2
Configured nodes: oda01 ,oda02 
Database is administrator managed

—> Pre-Requisites to create a snpshot database

 https://docs.oracle.com/cd/E75550_01/doc.121/e79567/GUID-63DFD214-2B87-40A0-AE1B-C59805F0043E.htm#CMTXH-GUID-8B7849A5-1A3C-469D-9C90-12394364C980
    They must not be a standby or container database
    They must not be running in read-only mode, or in restricted mode, or in online backup mode
    They must be in ARCHIVELOG mode
    They must have all defined data files available and online
    They must not use centralized wallets with Transparent Data Encryption.

–> Archivelog Mode

 SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     3
Next log sequence to archive   4
Current log sequence           4

–> Size of DATABASE

create tablespace ts_test 
datafile '/u02/app/oracle/oradata/datastore/.ACFS/snaps/TSTSNAP/TSTSNAP/datafile/ts_test1.dbf' 
size 1g;
 col file_name format a100
select bytes/(1024*1024) mb, tablespace_name, file_name from dba_data_files;
         MB TABLESPACE_NAME                FILE_NAME
---------- ------------------------------ ----------------------------------------------------------------------------------------------------
       700 SYSTEM                         /u02/app/oracle/oradata/datastore/.ACFS/snaps/TSTSNAP/TSTSNAP/datafile/o1_mf_system_dmlcolr5_.dbf
       600 SYSAUX                         /u02/app/oracle/oradata/datastore/.ACFS/snaps/TSTSNAP/TSTSNAP/datafile/o1_mf_sysaux_dmlcp5g2_.dbf
       305 UNDOTBS1                       /u02/app/oracle/oradata/datastore/.ACFS/snaps/TSTSNAP/TSTSNAP/datafile/o1_mf_undotbs1_dmlcplml_.dbf
       200 UNDOTBS2                       /u02/app/oracle/oradata/datastore/.ACFS/snaps/TSTSNAP/TSTSNAP/datafile/o1_mf_undotbs2_dmlcq436_.dbf
         5 USERS                          /u02/app/oracle/oradata/datastore/.ACFS/snaps/TSTSNAP/TSTSNAP/datafile/o1_mf_users_dmlcq8rx_.dbf
      1024 TS_TEST                        /u02/app/oracle/oradata/datastore/.ACFS/snaps/TSTSNAP/TSTSNAP/datafile/ts_test1.dbf
prompt "Total Size: "
select round(sum(bytes)/(1024*1024*1024),0) GB from
(select sum(bytes) bytes from dba_data_files
union
select sum(bytes) bytes from dba_temp_files);
        GB
----------
         3
 --> Populating the DB
 SQL> create user test identified by test default tablespace ts_test;
User created.
SQL> grant dba to test;
Grant succeeded.
create table test.tb1 as select * from dba_segments;
  1*  select segment_name, bytes / (1024*1024) mb, tablespace_name from dba_segments where segment_name='TB1'
SQL> /
SEGMENT_NAME                 MB TABLESPACE_NAME
-------------------- ---------- ------------------------------
TB1                         .75 TS_TEST
 declare
begin
for x in 1 .. 10 loop
  insert into test.tb1 select * from test.tb1;
end loop;
commit;
end;
/
  select segment_name, bytes / (1024*1024) mb, tablespace_name 
from dba_segments where segment_name='TB1'
SEGMENT_NAME                 MB TABLESPACE_NAME
-------------------- ---------- ------------------------------
TB1                         672 TS_TEST
 select round(sum(bytes)/(1024*1024*1024),2) GB
from dba_free_space;  2
         GB
----------
      1.21
1

—> Creating the Snapshot

Start Time: 2017-06-08 14:12:06
End Time  : 2017-06-08 14:29:22

oakcli create snapshotdb -db SNAP01 -from TSTSNAP
pwd: oracle123 (if the password doens't match try: welcome1)

Please select one of the following for Database Deployment  [1 .. 2] :
1    => RACONE
2    => RAC
Option: 2
Please select one of the following for Database Class  [1 .. 5] :
1    => odb-01s  (   1 cores ,     4 GB memory)
2    =>  odb-01  (   1 cores ,     8 GB memory)
3    =>  odb-02  (   2 cores ,    16 GB memory)
4    =>  odb-04  (   4 cores ,    32 GB memory)
5    =>  odb-06  (   6 cores ,    48 GB memory)
Option: 1
SUCCESS: 
All nodes in /opt/oracle/oak/temp_clunodes.txt are pingable and alive.
......
SUCCESS: All nodes in /opt/oracle/oak/temp_clunodes.txt are 
pingable and alive.
INFO: 2017-06-08 14:16:35: Creating the SNAP 
Database 'SNAP01' from the source Database 'TSTSNAP'
INFO: 2017-06-08 14:16:44: Do not perform any Structural change to 
Database 'TSTSNAP' till SNAP Database 'SNAP01' is created
INFO: 2017-06-08 14:17:05: Taking SNAP of the Database 'TSTSNAP'
INFO: 2017-06-08 14:17:10: Successfully took  the SNAP of database: TSTSNAP
INFO: 2017-06-08 14:20:53: Creating controlfile for database: SNAP01
INFO: 2017-06-08 14:21:39: Successfully created the control file for the database : SNAP01
INFO: 2017-06-08 14:21:39: Adding log files for the second thread for the database : SNAP01
INFO: 2017-06-08 14:21:46: Successfully added the log files for second thread
INFO: 2017-06-08 14:21:52: Recovering the database: SNAP01,  snapshot time : '2017-06-08:14:17:09' , until time : '2017-06-08:14:17:40'
INFO: 2017-06-08 14:21:55: Successfully recovered the database
INFO: 2017-06-08 14:21:55: Opening the database with resetlogs
INFO: 2017-06-08 14:22:26: Successfully opened the database after recovery
INFO: 2017-06-08 14:22:32: Setting the temporary tablespace for database : SNAP01
INFO: 2017-06-08 14:22:47: Successfully set the temporary tablespace for the database : SNAP01
INFO: 2017-06-08 14:23:32: Successfully changed the Database ID
INFO: 2017-06-08 14:25:17: Adding the Database resource to the clusterware
INFO: 2017-06-08 14:26:43: Successfully started the database
INFO: 2017-06-08 14:26:43: Updating the TNS entries for the database SNAP01
INFO: 2017-06-08 14:27:31: Successfully set the RMAN SNAPSHOT control file
INFO: 2017-06-08 14:27:44: Disabling the external references in the database 'SNAP01' inherited from 'TSTSNAP'
INFO: 2017-06-08 14:27:45: Successfully disabled the external references
INFO: 2017-06-08 14:28:08: Run the SQL script '/u01/app/oracle/product/12.1.0.2/dbhome_1/enable_external_refs_SNAP01_r_GY.sql' on the database 'SNAP01' to enable these external references
 Also need to restart the database after running the SQL script
SUCCESS: 2017-06-08 14:29:22: Successfully created the Database 'SNAP01' from 'TSTSNAP'
 2
[oracle@oda01 ~]$ srvctl config database -d SNAP01
Database unique name: SNAP01
Database name:
Oracle home: /u01/app/oracle/product/12.1.0.2/dbhome_1
Oracle user: oracle
Spfile: 
/u02/app/oracle/oradata/datastore/.ACFS/snaps/SNAP01/SNAP01/spfileSNAP01.ora
Password file: 
/u02/app/oracle/oradata/datastore/.ACFS/snaps/SNAP01/SNAP01/orapwSNAP01
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups:
Mount point paths: 
/u01/app/oracle/oradata/datastore,/u02/app/oracle/oradata/datastore,
/u01/app/oracle/fast_recovery_area/datastore
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: racoper
Database instances: SNAP011,SNAP012
Configured nodes: oda01 ,oda02 
Database is administrator managed

. oraenv
SNAP011
 sqlplus / as sysdba
SQL> col file_name format a100
SQL> select bytes/(1024*1024) mb, tablespace_name, file_name 
from dba_data_files;
        MB TABLESPACE_NAME                FILE_NAME
---------- ------------------------------ ----------------------------------------------------------------------------------------------------
       700 SYSTEM                         /u02/app/oracle/oradata/datastore/.ACFS/snaps/SNAP01/SNAP01/datafile/o1_mf_system_dmlcolr5_.dbf
       600 SYSAUX                         /u02/app/oracle/oradata/datastore/.ACFS/snaps/SNAP01/SNAP01/datafile/o1_mf_sysaux_dmlcp5g2_.dbf
       305 UNDOTBS1                       /u02/app/oracle/oradata/datastore/.ACFS/snaps/SNAP01/SNAP01/datafile/o1_mf_undotbs1_dmlcplml_.dbf
       200 UNDOTBS2                       /u02/app/oracle/oradata/datastore/.ACFS/snaps/SNAP01/SNAP01/datafile/o1_mf_undotbs2_dmlcq436_.dbf
         5 USERS                          /u02/app/oracle/oradata/datastore/.ACFS/snaps/SNAP01/SNAP01/datafile/o1_mf_users_dmlcq8rx_.dbf
      1024 TS_TEST                        /u02/app/oracle/oradata/datastore/.ACFS/snaps/SNAP01/SNAP01/datafile/ts_test1.dbf
SQL> select round(sum(bytes)/(1024*1024*1024),0) GB from
(select sum(bytes) bytes from dba_data_files
union
select sum(bytes) bytes from dba_temp_files);
        GB
----------
         3
 ---> Creating the Snapshot from previous Snapshot
Start Time: 2017-06-08 14:41:18
End Time  : 2017-06-08 14:54:10
 oakcli create snapshotdb -db SNAP02 -from SNAP01
pwd: welcome1
*** Note: on this case i changed the type of the database to RACONE
[root@oda01 ~]# oakcli create snapshotdb -db SNAP02 -from SNAP01
INFO: 2017-06-08 14:41:18: Please check the logfile  
'/opt/oracle/oak/log/oda01/tools/12.1.2.8.0/createdb_SNAP02_61544.log' for more details
 Please enter the 'SYS'  password for the Database SNAP01:
Please re-enter the 'SYS' password:
Please select one of the following for Database Deployment  [1 .. 2] :
1    => RACONE
2    => RAC
1
The selected value is : RACONE
Please select one of the following for Database Class  [1 .. 5] :
1    => odb-01s  (   1 cores ,     4 GB memory)
2    =>  odb-01  (   1 cores ,     8 GB memory)
3    =>  odb-02  (   2 cores ,    16 GB memory)
4    =>  odb-04  (   4 cores ,    32 GB memory)
5    =>  odb-06  (   6 cores ,    48 GB memory)
1
The selected value is : odb-01s  (   1 cores ,     4 GB memory)
......
SUCCESS: 
All nodes in /opt/oracle/oak/temp_clunodes.txt are pingable and alive.
......
SUCCESS: 
All nodes in /opt/oracle/oak/temp_clunodes.txt are pingable and alive.
INFO: 2017-06-08 14:44:13: 
Creating the SNAP Database 'SNAP02' from the source Database 'SNAP01'
INFO: 2017-06-08 14:44:22: 
Do not perform any Structural change to Database 'SNAP01' till SNAP Database 'SNAP02' is created
INFO: 2017-06-08 14:44:42: 
Taking SNAP of the Database 'SNAP01'
INFO: 2017-06-08 14:44:47: 
Successfully took  the SNAP of database: SNAP01
INFO: 2017-06-08 14:45:35: 
Creating controlfile for database: SNAP02
INFO: 2017-06-08 14:46:40: 
Successfully created the control file for the database : SNAP02
INFO: 2017-06-08 14:46:46: 
Recovering the database: SNAP02,  snapshot time : '2017-06-08:14:44:47' , until time : '2017-06-08:14:44:57'
INFO: 2017-06-08 14:46:49: Successfully recovered the database
INFO: 2017-06-08 14:46:49: Opening the database with resetlogs
INFO: 2017-06-08 14:47:20: Successfully opened the database after recovery
INFO: 2017-06-08 14:47:25: Setting the temporary tablespace for database : SNAP02
INFO: 2017-06-08 14:47:33: Successfully set the temporary tablespace for the database : SNAP02
INFO: 2017-06-08 14:48:19: Successfully changed the Database ID
INFO: 2017-06-08 14:49:56: Adding the Database resource to the clusterware
INFO: 2017-06-08 14:51:40: Successfully started the database
INFO: 2017-06-08 14:51:46: Updating the TNS entries for the database SNAP02
INFO: 2017-06-08 14:52:27: Successfully set the RMAN SNAPSHOT control file
INFO: 2017-06-08 14:52:38: 
Disabling the external references in the database 'SNAP02' inherited from 'SNAP01'
INFO: 2017-06-08 14:52:39: Successfully disabled the external references
INFO: 2017-06-08 14:53:07: 
Run the SQL script '/u01/app/oracle/product/12.1.0.2/dbhome_1/enable_external_refs_SNAP02_wpY9.sql' on the database 'SNAP02' to enable these external references
 Also need to restart the database after running the SQL script
SUCCESS: 2017-06-08 14:54:10: 
Successfully created the Database 'SNAP02' from 'SNAP01'
 3

 

Please note that the second snapshot took 30% less of the used storage, this is because that only changed blocks are copied during the process.

Advertisements