Clone
database using Oracle 12c CloudFS Copy-On-Write snapshot without multitenant
feature
Three Goals:
1.
Time
Saving : Clone big database in a few
minutes, not hours.
2.
Storage
saving : Clone database using less than 1% of original database
space
3.
License
Cost saving : Achieve the two goals above
without Oracle multitenant feature
Solution:
Use Oracle 12c CloudFS Copy-On-Write snapshot feature and manually create
clone database without using pluggable database feature.
Pre-requisite requirement :
Oracle ACFS 12.1. How to create
ACFS is covered by another document.
This POC was done on Oracle 12c RAC flexible cluster on RedHat Linux
server vdclracdev01
Reference:
The two Oracle documents below
are about how to do this using multitenant feature.
Steps:
This document demonstrates the steps to create two clone databases using
CloudFS snapshot on a three nodes Oracle 12c RAC flexible cluster on Linux.
Step 1 :Prepare the source
database, create the seed database on CloudFS file system
Create the database
using dbca tool.
The file location is
/u10/ACFSTEST/db, /u10/ACFSTEST is the mount point of CloudFS.
--Add a 100GB tablespace and populate
the tablespace.
SQL> create tablespace bigtbs datafile
'/u10/ACFSTEST/db/TESTACFS/datafile/bigtbs1.dbf' size 30g;
SQL> alter tablespace bigtbs add
datafile '/u10/ACFSTEST/db/TESTACFS/datafile/bigtbs2.dbf' size 30g;
SQL> alter tablespace bigtbs add
datafile '/u10/ACFSTEST/db/TESTACFS/datafile/bigtbs3.dbf' size 30g;
SQL> alter tablespace bigtbs add
datafile '/u10/ACFSTEST/db/TESTACFS/datafile/bigtbs4.dbf' size 10g;
Create a table to use this tablespace.
SQL> create table test (col1
char(2000)) tablespace bigtbs;
SQL> insert into test values ('a');
SQL> insert into test select * from test;
…
SQL> select sum(bytes) from dba_segments where segment_name='TEST';
SUM(BYTES)
----------
2.2951E+10
SQL> show parameter control
NAME
TYPE VALUE
------------------------------------ -----------
------------------------------
control_file_record_keep_time
integer 7
control_files
string
/u10/ACFSTEST/db/TESTACFS/cont
rolfile/o1_mf_c3hs49mj_.ctl, /
u10/ACFSTEST/fra/TESTACFS/cont
rolfile/o1_mf_c3hs49o7_.ctl
control_management_pack_access
string DIAGNOSTIC+TUNING
SQL> select file_name,bytes from dba_data_files;
FILE_NAME
BYTES
--------------------------------------------------------------------------------
----------
/u10/ACFSTEST/db/TESTACFS/datafile/o1_mf_users_c3hs3307_.dbf 5242880
/u10/ACFSTEST/db/TESTACFS/datafile/o1_mf_undotbs1_c3hs344s_.dbf 346030080
/u10/ACFSTEST/db/TESTACFS/datafile/o1_mf_sysaux_c3hrzymy_.dbf 754974720
/u10/ACFSTEST/db/TESTACFS/datafile/o1_mf_system_c3hs1cs8_.dbf 1163919360
/u10/ACFSTEST/db/TESTACFS/datafile/bigtbs1.dbf 3.2212E+10
/u10/ACFSTEST/db/TESTACFS/datafile/bigtbs2.dbf 3.2212E+10
/u10/ACFSTEST/db/TESTACFS/datafile/bigtbs3.dbf 3.2212E+10
/u10/ACFSTEST/db/TESTACFS/datafile/bigtbs4.dbf 1.0737E+10
SQL>
select group#,member from v$logfile;
GROUP# MEMBER
----------
--------------------------------------------------------------------------------
2
/u10/ACFSTEST/db/TESTACFS/onlinelog/o1_mf_2_c3nlvxqt_.log
2
/u10/ACFSTEST/fra/TESTACFS/onlinelog/o1_mf_2_c3nlvxtl_.log
1
/u10/ACFSTEST/db/TESTACFS/onlinelog/o1_mf_1_c3nlvxft_.log
1
/u10/ACFSTEST/fra/TESTACFS/onlinelog/o1_mf_1_c3nlvxk4_.log
SQL>shutdown
--Have a look at the ACFS space.
-bash-4.1$ acfsutil info fs /u10/ACFSTEST
/u10/ACFSTEST
ACFS Version: 12.1.0.2.0
on-disk version: 43.0
flags: MountPoint,Available
mount time: Wed Oct 28 08:24:47 2015
allocation unit: 4096
volumes: 1
total size: 429496729600
( 400.00 GB )
total free: 318378569728
( 296.51 GB )
file entry table allocation:
1114112
primary volume:
/dev/asm/acfsvol01-345
label:
state: Available
major, minor: 252, 176641
size: 429496729600 ( 400.00 GB )
free: 318378569728 ( 296.51 GB )
ADVM diskgroup ACFS01
ADVM resize increment:
67108864
ADVM redundancy: unprotected
ADVM stripe columns: 8
ADVM stripe width: 1048576
number of snapshots: 0
snapshot space usage: 0 ( 0.00 )
replication status: DISABLED
Step 2 : Create snapshots
-bash-4.1$ time acfsutil snap
create -w clonedb1 /u10/ACFSTEST
acfsutil snap create: Snapshot operation is complete.
real 0m0.122s
user 0m0.012s
sys 0m0.014s
Noticed that the time to create the snapshot is 0.122 second.
-bash-4.1$ acfsutil snap info /u10/ACFSTEST
snapshot name:
clonedb1
snapshot location:
/u10/ACFSTEST/.ACFS/snaps/clonedb1
RO snapshot or RW snapshot: RW
parent name:
/u10/ACFSTEST
snapshot creation time: Wed
Nov 4 11:20:48 2015
number of snapshots: 1
snapshot space usage:
1114112 ( 1.06 MB )
-bash-4.1$ acfsutil snap create -w
clonedb2 /u10/ACFSTEST
acfsutil snap create: Snapshot operation is complete.
-bash-4.1$ acfsutil snap info /u10/ACFSTEST
snapshot name:
clonedb1
snapshot location:
/u10/ACFSTEST/.ACFS/snaps/clonedb1
RO snapshot or RW snapshot: RW
parent name:
/u10/ACFSTEST
snapshot creation time: Wed
Nov 4 11:20:48 2015
snapshot name:
clonedb2
snapshot location:
/u10/ACFSTEST/.ACFS/snaps/clonedb2
RO snapshot or RW snapshot: RW
parent name: /u10/ACFSTEST
snapshot creation time: Wed
Nov 4 11:21:45 2015
number of snapshots: 2
snapshot space usage:
2228224 ( 2.12 MB )
Noticed that snapshot space usage is
very small, only 2.12MB for now
-bash-4.1$ -bash-4.1$ du -m /u10/ACFSTEST/.ACFS/snaps/clonedb2
1
/u10/ACFSTEST/.ACFS/snaps/clonedb2/testdir1
104766
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile
101
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/onlinelog
13
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/controlfile
104878
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS
104878
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db
101
/u10/ACFSTEST/.ACFS/snaps/clonedb2/fra/TESTACFS/onlinelog
13
/u10/ACFSTEST/.ACFS/snaps/clonedb2/fra/TESTACFS/controlfile
1 /u10/ACFSTEST/.ACFS/snaps/clonedb2/fra/TESTACFS/archivelog/2015_11_04
1
/u10/ACFSTEST/.ACFS/snaps/clonedb2/fra/TESTACFS/archivelog
113
/u10/ACFSTEST/.ACFS/snaps/clonedb2/fra/TESTACFS
113
/u10/ACFSTEST/.ACFS/snaps/clonedb2/fra
104991 /u10/ACFSTEST/.ACFS/snaps/clonedb2
-bash-4.1$ du -m /u10/ACFSTEST/.ACFS/snaps/clonedb1
1
/u10/ACFSTEST/.ACFS/snaps/clonedb1/testdir1
104766
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile
101
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/onlinelog
13
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/controlfile
104878
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS
104878
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db
101
/u10/ACFSTEST/.ACFS/snaps/clonedb1/fra/TESTACFS/onlinelog
13 /u10/ACFSTEST/.ACFS/snaps/clonedb1/fra/TESTACFS/controlfile
1
/u10/ACFSTEST/.ACFS/snaps/clonedb1/fra/TESTACFS/archivelog/2015_11_04
1
/u10/ACFSTEST/.ACFS/snaps/clonedb1/fra/TESTACFS/archivelog
113
/u10/ACFSTEST/.ACFS/snaps/clonedb1/fra/TESTACFS
113
/u10/ACFSTEST/.ACFS/snaps/clonedb1/fra
104991
/u10/ACFSTEST/.ACFS/snaps/clonedb1
Notice that the space usages on FS are
showing about 100GB for the snapshots
-bash-4.1$ ls -l /u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile
total 107279436
-rw-r----- 1 oracle asmadmin 32212262912 Nov 4 11:10 bigtbs1.dbf
-rw-r----- 1 oracle asmadmin 32212262912 Nov 4 11:05 bigtbs2.dbf
-rw-r----- 1 oracle asmadmin 32212262912 Nov 4 11:05 bigtbs3.dbf
-rw-r----- 1 oracle asmadmin 10737426432 Nov 4 11:05 bigtbs4.dbf
-rw-r----- 1 oracle asmadmin
754982912 Nov 4 11:15
o1_mf_sysaux_c3hrzymy_.dbf
-rw-r----- 1 oracle asmadmin
1163927552 Nov 4 11:15
o1_mf_system_c3hs1cs8_.dbf
-rw-r----- 1 oracle asmadmin
206577664 Nov 2 14:33
o1_mf_temp_c3hs4mm8_.tmp
-rw-r----- 1 oracle asmadmin
346038272 Nov 4 11:10
o1_mf_undotbs1_c3hs344s_.dbf
-rw-r----- 1 oracle asmadmin
5251072 Nov 4 11:15
o1_mf_users_c3hs3307_.dbf
Notice that the datafile on these
snapshots are showing the right size (100+GB)
Step 3: Create database clonedb1
and clonedb2 on these snapshots:
Now we manually create clonedb1 and clonedb2 on these snapshots location.
SQL> startup nomount
SQL> CREATE CONTROLFILE reuse set DATABASE "CLONEDB1"
RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 2920
LOGFILE
GROUP 1 (
'/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/onlinelog/o1_mf_1_c3nlvxft_.log'
) SIZE 50M BLOCKSIZE 512,
GROUP 2 (
'/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/onlinelog/o1_mf_2_c3nlvxqt_.log'
) SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/o1_mf_system_c3hs1cs8_.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/bigtbs2.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/o1_mf_sysaux_c3hrzymy_.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/o1_mf_undotbs1_c3hs344s_.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/bigtbs1.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/o1_mf_users_c3hs3307_.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/bigtbs3.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/bigtbs4.dbf'
CHARACTER SET AL32UTF8
;
SQL> alter database open resetlogs;
Database altered.
SQL>
select file_name, bytes from dba_data_files;
FILE_NAME
BYTES
------------------------------------------------------------------------------------------
----------
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/bigtbs4.dbf 1.0737E+10
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/bigtbs3.dbf 3.2212E+10
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/o1_mf_users_c3hs3307_.dbf 5242880
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/bigtbs1.dbf 3.2212E+10
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/o1_mf_undotbs1_c3hs344s_.dbf 346030080
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/o1_mf_sysaux_c3hrzymy_.dbf 754974720
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/bigtbs2.dbf 3.2212E+10
/u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile/o1_mf_system_c3hs1cs8_.dbf 1163919360
8 rows selected.
-bash-4.1$ acfsutil info fs /u10/ACFSTEST
/u10/ACFSTEST
ACFS Version: 12.1.0.2.0
on-disk version: 43.0
flags: MountPoint,Available
mount time: Wed Oct 28 08:24:47 2015
allocation unit: 4096
volumes: 1
total size: 429496729600
( 400.00 GB )
total free: 318206722048
( 296.35 GB )
file entry table allocation: 1114112
primary volume:
/dev/asm/acfsvol01-345
label:
state: Available
major, minor: 252, 176641
size: 429496729600 ( 400.00 GB )
free: 318206722048 ( 296.35 GB )
ADVM diskgroup ACFS01
ADVM resize increment:
67108864
ADVM redundancy: unprotected
ADVM stripe columns: 8
ADVM stripe width: 1048576
number of snapshots: 2
snapshot space usage:
180465664 ( 172.10 MB )
replication status: DISABLED
Noticed that the snapshot space
usage is 172MB, although db size is over 100GB, time to create the snapshot is
less than a minute, plus DBA’s keyboard typing time.
-bash-4.1$ ls -l /u10/ACFSTEST/db/TESTACFS/datafile
total 107279436
-rw-r----- 1 oracle asmadmin 32212262912 Nov 4 11:10 bigtbs1.dbf
-rw-r----- 1 oracle asmadmin 32212262912 Nov 4 11:05 bigtbs2.dbf
-rw-r----- 1 oracle asmadmin 32212262912 Nov 4 11:05 bigtbs3.dbf
-rw-r----- 1 oracle asmadmin 10737426432 Nov 4 11:05 bigtbs4.dbf
-rw-r----- 1 oracle asmadmin
754982912 Nov 4 11:15
o1_mf_sysaux_c3hrzymy_.dbf
-rw-r----- 1 oracle asmadmin
1163927552 Nov 4 11:15
o1_mf_system_c3hs1cs8_.dbf
-rw-r----- 1 oracle asmadmin
206577664 Nov 2 14:33
o1_mf_temp_c3hs4mm8_.tmp
-rw-r----- 1 oracle asmadmin
346038272 Nov 4 11:10
o1_mf_undotbs1_c3hs344s_.dbf
-rw-r----- 1 oracle asmadmin
5251072 Nov 4 11:15
o1_mf_users_c3hs3307_.dbf
-bash-4.1$ ls -l /u10/ACFSTEST/.ACFS/snaps/clonedb1/db/TESTACFS/datafile
total 107279436
-rw-r----- 1 oracle asmadmin 32212262912 Nov 4 11:39 bigtbs1.dbf
-rw-r----- 1 oracle asmadmin 32212262912 Nov 4 11:39 bigtbs2.dbf
-rw-r----- 1 oracle asmadmin 32212262912 Nov 4 11:39 bigtbs3.dbf
-rw-r----- 1 oracle asmadmin 10737426432 Nov 4 11:39 bigtbs4.dbf
-rw-r----- 1 oracle asmadmin
754982912 Nov 4 11:44
o1_mf_sysaux_c3hrzymy_.dbf
-rw-r----- 1 oracle asmadmin
1163927552 Nov 4 11:15
o1_mf_system_c3hs1cs8_.dbf
-rw-r----- 1 oracle asmadmin
206577664 Nov 2 14:33
o1_mf_temp_c3hs4mm8_.tmp
-rw-r----- 1 oracle asmadmin
346038272 Nov 4 11:45
o1_mf_undotbs1_c3hs344s_.dbf
-rw-r----- 1 oracle asmadmin
5251072 Nov 4 11:39
o1_mf_users_c3hs3307_.dbf
-bash-4.1$
-bash-4.1$ . oraenv
ORACLE_SID = [CLONEDB1] ?
CLONEDB2
The Oracle base remains unchanged
with value /u01/app/oracle
-bash-4.1$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0
Production on Wed Nov 4 13:34:04 2015
Copyright (c) 1982, 2014,
Oracle. All rights reserved.
Connected to an idle instance.
SQL> create spfile from pfile
='/u01/app/oracle/product/12.1.0.2/dbs/initCLONEDB2.ora';
File created.
SQL> startup nomount
ORACLE instance started.
Total System Global Area
1526726656 bytes
Fixed Size 2924688 bytes
Variable Size 671092592 bytes
Database Buffers 838860800 bytes
Redo Buffers 13848576 bytes
SQL>
CREATE CONTROLFILE reuse set
DATABASE "CLONEDB2" RESETLOGS
NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 2920
LOGFILE
GROUP 1
SIZE 50M BLOCKSIZE 512,
GROUP 2 SIZE 50M BLOCKSIZE 512
DATAFILE
'/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/o1_mf_system_c3hs1cs8_.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/bigtbs2.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/o1_mf_sysaux_c3hrzymy_.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/o1_mf_undotbs1_c3hs344s_.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/bigtbs1.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/o1_mf_users_c3hs3307_.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/bigtbs3.dbf',
'/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/bigtbs4.dbf'
CHARACTER SET AL32UTF8
;
Control file created.
SQL> alter database open
resetlogs;
Database altered.
SQL>
SQL> create table test2 (col1 char(2000));
Table created.
SQL> insert into test2 values
('2');
1 row created.
SQL> commit;
Commit complete.
SQL>
SQL> select
file_name,bytes,status from dba_data_files;
FILE_NAME
BYTES STATUS
------------------------------------------------------------------------------------------
---------- ---------
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/bigtbs4.dbf 1.0737E+10 AVAILABLE
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/bigtbs3.dbf 3.2212E+10 AVAILABLE
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/o1_mf_users_c3hs3307_.dbf 5242880 AVAILABLE
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/bigtbs1.dbf 3.2212E+10 AVAILABLE
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/o1_mf_undotbs1_c3hs344s_.dbf 346030080 AVAILABLE
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/o1_mf_sysaux_c3hrzymy_.dbf 754974720 AVAILABLE
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/bigtbs2.dbf 3.2212E+10 AVAILABLE
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile/o1_mf_system_c3hs1cs8_.dbf 1163919360 AVAILABLE
8 rows selected.
SQL> host
[Wed Nov 04
13:39:07]oracle@vdclracdev01.bcferries.corp:/u01/app/oracle/product/12.1.0.2/dbs(/CLONEDB2)
bash-4.1>ls -l
/u10/ACFSTEST/.ACFS/snaps/clonedb2/db/TESTACFS/datafile
total 107279436
-rw-r----- 1 oracle asmadmin
32212262912 Nov 4 13:38 bigtbs1.dbf
-rw-r----- 1 oracle asmadmin
32212262912 Nov 4 13:38 bigtbs2.dbf
-rw-r----- 1 oracle asmadmin
32212262912 Nov 4 13:38 bigtbs3.dbf
-rw-r----- 1 oracle asmadmin
10737426432 Nov 4 13:38 bigtbs4.dbf
-rw-r----- 1 oracle asmadmin 754982912 Nov 4 13:38 o1_mf_sysaux_c3hrzymy_.dbf
-rw-r----- 1 oracle asmadmin 1163927552 Nov 4 13:38 o1_mf_system_c3hs1cs8_.dbf
-rw-r----- 1 oracle asmadmin 206577664 Nov 2 14:33 o1_mf_temp_c3hs4mm8_.tmp
-rw-r----- 1 oracle asmadmin 346038272 Nov 4 13:38 o1_mf_undotbs1_c3hs344s_.dbf
-rw-r----- 1 oracle asmadmin 5251072 Nov 4 13:38 o1_mf_users_c3hs3307_.dbf
[Wed Nov 04
13:39:13]oracle@vdclracdev01.bcferries.corp:/u01/app/oracle/product/12.1.0.2/dbs(/CLONEDB2)
bash-4.1>
Noticed that the datafiles
timestamps changed to 14:38 on the snapshots.
-bash-4.1$ acfsutil snap info
/u10/ACFSTEST
snapshot name: clonedb1
snapshot location: /u10/ACFSTEST/.ACFS/snaps/clonedb1
RO snapshot or RW snapshot: RW
parent name: /u10/ACFSTEST
snapshot creation time: Wed Nov
4 11:20:48 2015
snapshot name: clonedb2
snapshot location: /u10/ACFSTEST/.ACFS/snaps/clonedb2
RO snapshot or RW snapshot: RW
parent name: /u10/ACFSTEST
snapshot creation time: Wed Nov
4 11:21:45 2015
number of snapshots: 2
snapshot space usage: 469504000 ( 447.75 MB )
-bash-4.1$
Noticed that the snapshot space
usage increased to 447.75MB for this 100+GB database.
We can repeat the
above steps to create up to 1023 snapshots clone databases!
Comments
Post a Comment