Hot (Snap)Shots! Der Master aller Datenbanken. DB Clonen, nicht kleckern... Sebastian Solbach BU Datenbank, ORACLE Deutschland B.V. Co. KG Month 11, 2015
Agenda 1 2 3 4 Klonen von Datenbanken 12c ASM Cluster Filesystem Pluggable Databases auf ACFS & ACFS Snapshots Snapshot von 12c noncdb und 11.2.0.4 Datenbanken 3
Warum Datenbank Cloning? Test Backup & Recovery Test Upgrade auf ein neues Datenbank-Release Test Applikationen & Datenbank Performance Anlegen von Standby Datenbanken Reporting Gold Image Cloning... und vieles mehr... 4
Agenda 1 2 3 4 Klonen von Datenbanken 12c ASM Cluster Filesystem Pluggable Databases auf ACFS & ACFS Snapshots Snapshot von 12c noncdb und 11.2.0.4 Datenbanken 5
ASM Cluster Filesystem ACFS Generelles modernes, POSIX kompatibles Filesystem Basiert auf ASM Dynamic Volumes (ADVM) Extent basierend & Journaling NFS / CIFS Export möglich (mit 12c HA NFS) Integriert in die 12c Grid Infrastruktur Oracle Cluster Oracle Restart (Vorsicht: Kein Automount) 6
ASM Überblick Oracle Database Operating System Oracle Database ASM File System Logical Volume Manager Operating System Server Server
ASM Überblick Datendateien Redolog Controlfile Oracle Datenbank (oracle Executable) SPFile Passwordfile
ASM Überblick Compatibility Level
ASM Dynamic Volumes Neuer Filetyp in ASM (wie eine Datendatei): ASMVOL Verwaltet mit ASMCMD, ASMCA, Enterprise Manager Dynamisch ladbarer Kerneltreiber Erzeugen eines Device Files Linux: /dev/asm/acfsdata-207 Windows: \\.\acfsfra-345 Volume Betriebssystem 10
ACFS/ASM/AOKS auf Exadata 11
Automatic Storage Management Administrator's Guide Features Enabled By Disk Group Compatibility Attribute Settings COMPATIBLE.ASM > 12.1 Replication Status of Diskgroup Managing a shared password file in a disk group + COMPATIBLE.RDBMS > 12.1 Greater than 2 TB Oracle ASM disks without Oracle Exadata storage + COMPATIBLE.ADVM > 12.1.0.2 Storing database data files and redo logs in Oracle ACFS file systems Support for 1023 snapshots Accelerator volume for Oracle ACFS file system 12
ASM Dynamic Volume Redundancy: Default = ASM Diskgroup Redundancy Stripe Columns Stripe Width 12c geänderter Default: Datenbanken 1M = Allocation Unit 13
ASM Dynamic Volume ASMCMD> volinfo --all Diskgroup Name: DATA Volume Name: ACFSDATA Volume Device: /dev/asm/acfsdata-207 State: ENABLED Size (MB): 16384 Resize Unit (MB): 64 Redundancy: UNPROT Stripe Columns: 8 Stripe Width (K): 1024 Usage: ACFS Mountpath: /u01/app/oracle/oradata 14
Create ASM Cluster Filesystem Type: Local Node Cluster Datenbank braucht Cluster Filesystem 15
ASM Cluster Filesystem im Cluster $ crsctl stat res -t -init -------------------------------------------------------------------------------- Name Target State Server State details -------------------------------------------------------------------------------- Cluster Resources --------------------------------------------------------------------------------... ora.drivers.acfs 1 ONLINE ONLINE bumucsvm1 STABLE 16
ASM Cluster Filesystem im Cluster $ crsctl stat res -t -------------------------------------------------------------------------------------- Name Target State Server State details -------------------------------------------------------------------------------------- Local Resources -------------------------------------------------------------------------------------- ora.data.acfsdata.advm ONLINE ONLINE bumucsvm1 Volume device /dev/asm/acfsdata-207 is online,stable ONLINE ONLINE bumucsvm2 STABLE ora.data.dg ONLINE ONLINE bumucsvm1 STABLE ONLINE ONLINE bumucsvm2 STABLE ora.data.acfsdata.acfs ONLINE ONLINE bumucsvm1 mounted on /u01/app/oracle/oradata,stable ONLINE ONLINE bumucsvm2 mounted on /u01/app/oracle/oradata,stable ora.proxy_advm ONLINE ONLINE bumucsvm1 STABLE ONLINE ONLINE bumucsvm2 STABLE --------------------------------------------------------------------------------------- 17
ASM Cluster Filesystem im Cluster # acfsutil info fs /u01/app/oracle/oradata /u01/app/oracle/oradata ACFS Version: 12.1.0.2.0 on-disk version: 42.0 flags: MountPoint,Available mount time: Thu May 21 18:52:34 2015 allocation unit: 4096 volumes: 1 total size: 17179869184 ( 16.00 GB ) total free: 11350839296 ( 10.57 GB ) file entry table allocation: 1097728 primary volume: /dev/asm/acfsdata-207 label: state: Available major, minor: 250, 105985 size: 17179869184 ( 16.00 GB ) free: 11350839296 ( 10.57 GB ) ADVM diskgroup DATA 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 18
Agenda 1 2 3 4 Klonen von Datenbanken 12c ASM Cluster Filesystem Pluggable Databases auf ACFS & ACFS Snapshots Snapshot von 12c noncdb und 11.2.0.4 Datenbanken 19
Datenbanken: Warum auf ACFS? Schneller Clone (Read Only Time verringern) Read/Write Clone mit Orginal kann weitergearbeitet werden Platzsparend Kostengünstig (Snapshot braucht nur Enterprise Edition) Annähernd gleiche Performance wie ASM Filesystem! 20
ACFS Lizenzierung Oracle ACFS Features Oracle Database Files Non-Oracle Database Files ACFS features other than those listed below FREE FREE Snapshots Oracle DB EE required FREE Encryption Not Available FREE Security Not Available FREE Replication Not Available FREE Auditing Not Available FREE 21
12.1.0.2 Pluggable Datenbanken Cloning Einfaches Cloning von 12c Pluggable Datenbanken (PDBs) PDB in Read Only Status setzen SQL> alter pluggable database spdb open read only; PDB Clone anlegen SQL> create pluggable database s2pdb from spdb; PDB Snapshot Clone anlegen SQL> create pluggable database s2pdb from spdb snapshot copy; 22
ASM Cluster Filesystem im Cluster # acfsutil info fs /u01/app/oracle/oradata /u01/app/oracle/oradata ACFS Version: 12.1.0.2.0 on-disk version: 43.0 flags: MountPoint,Available mount time: Thu May 21 18:52:34 2015 allocation unit: 4096 volumes: 1 total size: 17179869184 ( 16.00 GB ) total free: 11257479168 ( 10.48 GB ) file entry table allocation: 1097728 primary volume: /dev/asm/acfsdata-207 label: state: Available major, minor: 250, 105985 size: 17179869184 ( 16.00 GB ) free: 11257479168 ( 10.48 GB ) ADVM diskgroup DATA ADVM resize increment: 67108864 ADVM redundancy: unprotected ADVM stripe columns: 8 ADVM stripe width: 1048576 number of snapshots: 1 snapshot space usage: 28811264 ( 27.47 MB ) replication status: DISABLED 23
Snaptshot Clone Directory Structure ACFS Root (oradata) CDB_ROOT SPDB datafile NEW PDB datafile Symlink.ACFS/snaps NEW PDB/SCDB/SPDB/datafile 24
Snapshot Clone SQL> select * from v$pdbs; CON_ID GUID NAME OPEN_MODE RES ---------- -------------------------------- -------------------- ---------- --- OPEN_TIME CREATE_SCN TOTAL_SIZE BLOCK_SIZE RECOVERY SNAPSHOT_PARENT_CON_ID ---------- ---------- ---------- ---------- -------- ---------------------- 3 16A0C7F3EA950D21E05370F4A50A9346 SPDB READ ONLY NO 15-JUN-15 1476617 943718400 8192 ENABLED 0 4 18943D57D3410C0BE05371F4A50A5C6D S2PDB MOUNTED 15-JUN-15 4690778 0 8192 ENABLED 0 25
Snapshot Clone # ll drwxr-x--- 3 oracle oinstall 8192 May 22 01:20 16A0C7F3EA950D21E05370F4A50A9346 drwxr-x--- 3 oracle asmadmin 8192 Jun 15 21:14 18943D57D3410C0BE05371F4A50A5C6D # # ll 18943D57D3410C0BE05371F4A50A5C6D/datafile lrwxrwxrwx 1 oracle asmadmin 142 Jun 15 21:14 o1_mf_sysaux_bqy909kw_.dbf -> /u01/app/oracle/oradata/.acfs/snaps/18943d57d3410c0be05371f4a50a5c6d/scdb/16a0c 7F3EA950D21E05370F4A50A9346/datafile/o1_mf_sysaux_bowt1yln_.dbf lrwxrwxrwx 1 oracle asmadmin 142 Jun 15 21:14 o1_mf_system_bqy909gr_.dbf -> /u01/app/oracle/oradata/.acfs/snaps/18943d57d3410c0be05371f4a50a5c6d/scdb/16a0c 7F3EA950D21E05370F4A50A9346/datafile/o1_mf_system_bowt1yfj_.dbf -rw-r----- 1 oracle asmadmin 20979712 Jun 15 21:14 o1_mf_temp_bqy909ly_.dbf lrwxrwxrwx 1 oracle asmadmin 141 Jun 15 21:14 o1_mf_users_bqy909m4_.dbf -> /u01/app/oracle/oradata/.acfs/snaps/18943d57d3410c0be05371f4a50a5c6d/scdb/16a0c 7F3EA950D21E05370F4A50A9346/datafile/o1_mf_users_bowtbxb7_.dbf 26
ACFS Verzeichnis Hidden [root@bumucsvm1 oradata]# ll total 96 drwx------ 2 root root 65536 May 21 18:52 lost+found drwxr-x--- 2 oracle oinstall 8192 May 22 01:13 scdb drwxr-x--- 8 oracle oinstall 8192 Jun 15 21:14 SCDB # cd.acfs [root@bumucsvm1.acfs]# ll total 8 drwxrwx--- 6 root root 4096 May 21 18:52 repl drwxr-xr-x 3 root root 4096 Jun 15 21:14 snaps 27
ACFS Informationen SNAPShot # acfsutil snap info /u01/app/oracle/oradata snapshot name: 18943D57D3410C0BE05371F4A50A5C6D snapshot location: /u01/app/oracle/oradata/.acfs/snaps/18943d57d3410c0be05371f4a50a5c6d RO snapshot or RW snapshot: RW parent name: /u01/app/oracle/oradata snapshot creation time: Mon Jun 15 21:14:18 2015 number of snapshots: 1 snapshot space usage: 415596544 ( 396.34 MB ) 28
ASM Cluster File System V$Views V$ASM_FILESYSTEM V$ASM_ACFSVOLUMES V$ASM_ACFSSNAPSHOTS V$ASM_ACFS_SECURITY_INFO V$ASM_ACFS_ENCRYPTION_INFO
Entfernen der PDB Drop der PDB: SQL> drop pluggable database s2pdb including datafiles; Pluggable database dropped. Snapshot wird gelöscht: # acfsutil snap info /u01/app/oracle/oradata number of snapshots: 0 (active) 1 (delete pending) snapshot space usage: 1097728 ( 1.04 MB ) Problem: Wenn man sich im.acfs/snap Folder sich befindet... # acfsutil snap delete t 18943D57D3410C0BE05371F4A50A5C6D /u01/app/oracle/oradata 30
Best Practices Eigenes ACFS Filesystem für Datenbank oder PDB: Restriktion auf 1023 Snapshots Größe der Snapshots Verwaltung/Identifikation der Snapshots 31
Agenda 1 2 3 4 Klonen von Datenbanken 12c ASM Cluster Filesystem Pluggable Databases auf ACFS & ACFS Snapshots Snapshot von 12c noncdb und 11.2.0.4 Datenbanken 32
gdbclone Database Snapshot Management Script Perl Skript zum: Klonen von Datenbanken Von ASM nach ACFS Remote oder Lokal Erzeugen von DB-Snapshots (lokal) Löschen von DBs http://www.oracle.com/technetwork/indexes/samplecode/gdbclone-download- 2295388.html 33
gdbclone Remote zu Lokal (Clone) Lokal zu Lokal ASM/FS ASM ASM/FS ACFS ASM/FS ACFS ACFS SNAP SNAP SNAP 34
gdbclone #./gdbclone Usage: gdbclone clone -sdbname <source DB name> -sdbhost <source DB Host SCAN name> -sbckloc '<backup>' -tdbname <Target Database Name> -acfs <acfs mount point> [ -sdbport <Source DB SCAN Listener Port> ] [ -tdbport <Target DB SCAN Listener Port> ] [ -syspw <Source DB SYSDBA Password> ] [-racmod <db type> ] gdbclone snap -sdbname <source DB name> -tdbname <Target Database Name> [ -sdbport <Source DB SCAN Listener Port> ] [ -tdbport <Target DB SCAN Listener Port> ] [ -syspw <Source DB SYSDBA Password> ] [-racmod <db type> ] gdbclone listdb [ -tree ] [ -verbose ] gdbclone deldb -tdbname <database name> [ -force ] 35
DB Clone Database Type Source Target Single Instance Single Instance RACOne Node RACOne Node RAC RAC
RMAN Backup vs. Snapshot 70 Clone Creation Time and DB Size 60 59,23 50 47,23 40 38,35 30 20 10 0 6,17 2,23 2,15 2,2 2,43 5 Gb 25 Gb 35 Gb 45 Gb RMAN Snapshot 37
gdbclone Beispiel clone: Lokal Lokal von ASM auf ACFS ASM/FS ACFS #./gdbclone clone -sdbname ssdb -sdbhost bumucsvm1-scan -tdbname sclone -acfs /u01/app/oracle/oradata 2015-06-15 23:16:57: I Checking source host bumucsvm1-scan... 2015-06-15 23:16:57: I Getting host info... 2015-06-15 23:16:57: I Starting... 2015-06-15 23:16:57: I Validating environment... Enter the source ssdb SYSDBA password: 2015-06-15 23:17:02: I Checking SCAN listener bumucsvm1-scan:1521... 2015-06-16 23:32:29: I Successfully created clone "SCLONE" database 38
gdbclone Beispiel clone: Lokal Lokal von Backup auf ACFS Klone von Backup: Keine Auswirkung auf Produktion RMAN Backup kann auch auf NFS liegen RMAN Full Backup ACFS Hinweis: Bei 12.1 NFS Export mit insecure option #./gdbclone clone -sdbname SSDB -sbckloc /u01/app/oracle/fra/ssdb -tdbname SCLONE -acfs /u01/app/oracle/oradata 39
gdbclone Beispiel snap ACFS SNAP SNAP SNAP #./gdbclone snap -sdbname sclone -tdbname DOAGDB 40
gdbclone listdb #./gdbclone listdb DB Name DB Type DB Role Location/Parent -------- ----------- -------- ---------------- SNAP0 SINGLE Snapshot GOLD SNAP3 RACOneNode Snapshot SNAP1 SNAP4 SINGLE Snapshot SNAP3 SNAP2 RACOneNode Snapshot GOLD SNAP5 SINGLE Snapshot SNAP1 GOLD RAC Master /cloudfs SNAP1 SINGLE Snapshot SNAP0 #./gdbclone listdb -tree Parent Child ------ ----- GOLD SNAP1 SNAP0 SNAP3 SNAP4 SNAP2 SNAP5 41
gdbclone deldb Löscht Datenbank und Snapshot #./gdbclone deldb -tdbname DOAG You are going to drop the database DOAG, are you sure (Y/N)? y Connecting to database 47% complete Updating network configuration files 52% complete Deleting instance and datafiles 76% complete 100% complete Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/snap32.log" for further details. acfsutil snap delete: Snapshot operation is complete. ACFS snapshot SNAP3 on /cloudfs ACFS file system has been deleted. 42
gdbclone Hinweise / Tipps und Tricks Source Datenbank muss im Archivelog Modus sein gdbclone wird als Root ausgeführt Keine Sonderzeichen für den DBNamen verwenden Gegebenfalls DEBUG Funktion verwenden Funktioniert nur mit Administrator Managed DBs! Hidden Commands:./gDBClone listsnap -acfs <acfs_mount_point> [ -tree ]./gdbclone delsnap -snapname <snapshot name> -acfs <acfs_mount_point> 43
gdbclone Debug gdbclone mit debug Option erzeugt Output und Tracefile zur Fehleranalyse gdbclone log/trace file: /var/log/gdbclone/gdbclone.trc Falls die Debug Option verwendet wird, befinden sich unter /tmp/clone einige dynamische Dateien zum Debuggen 44
45