RAC database backup ve restore işlemleri

RAC database backup ve restore işlemleri

Bu örneğimizde RAC database’de nasıl backup alınır, ihtiyaç halinde nasıl restore yapılır beraber inceleyelim.Backup almak single instance ortamlarla aynı ama restore yaparken ufak bir trick var.Database’i cluster moddan çıkarıp restore bittikten sonra tekrar cluster moda almak gerekiyor.(alter system set cluster_database=false) Bu örneğimizde SYSTEM datafile’ını silip database’i backupdan restore edeceğiz.

Ortamlar:
Solaris 10,
Grid 11.2.0.4
Database 11.2.0.4

Adım adım beraber yapalım..

Spfile backup alalım..

RMAN> BACKUP SPFILE FORMAT '/orabackup/rman/ractst/spfile_%d_%T_%I_%u.bkp';
 
Starting backup at 01-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
using channel ORA_DISK_7
using channel ORA_DISK_8
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 01-OCT-15
channel ORA_DISK_1: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/spfile_RACTST_20151001_482324484_06qikjbu.bkp tag=TAG20151001T155958 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 01-OCT-15

Controlfile backup alalım..

RMAN> BACKUP CURRENT CONTROLFILE FORMAT '/orabackup/rman/ractst/controlfile_%d_%T_%u.bkp';
 
Starting backup at 01-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
using channel ORA_DISK_7
using channel ORA_DISK_8
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 01-OCT-15
channel ORA_DISK_1: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/controlfile_RACTST_20151001_07qikjcb.bkp tag=TAG20151001T160011 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 01-OCT-15

Sıkıştırılmış full database backup alalım..

RMAN> BACKUP AS COMPRESSED BACKUPSET DATABASE FORMAT '/orabackup/rman/ractst/datafiles_%d_%T_%u.bkp';
 
Starting backup at 01-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
using channel ORA_DISK_7
using channel ORA_DISK_8
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=+DATA/ractst/datafile/tbs_dm.273.873560789
input datafile file number=00004 name=+DATA/ractst/datafile/users.259.873558059
channel ORA_DISK_1: starting piece 1 at 01-OCT-15
channel ORA_DISK_2: starting compressed full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00010 name=+DATA/ractst/datafile/tbs_dm.272.873561081
channel ORA_DISK_2: starting piece 1 at 01-OCT-15
channel ORA_DISK_3: starting compressed full datafile backup set
channel ORA_DISK_3: specifying datafile(s) in backup set
input datafile file number=00011 name=+DATA/ractst/datafile/tbs_dm.271.873561315
input datafile file number=00005 name=+DATA/ractst/datafile/undotbs2.264.873558267
channel ORA_DISK_3: starting piece 1 at 01-OCT-15
channel ORA_DISK_4: starting compressed full datafile backup set
channel ORA_DISK_4: specifying datafile(s) in backup set
input datafile file number=00008 name=+DATA/ractst/datafile/tbs_mx.270.873559789
input datafile file number=00003 name=+DATA/ractst/datafile/undotbs1.258.873558059
channel ORA_DISK_4: starting piece 1 at 01-OCT-15
channel ORA_DISK_5: starting compressed full datafile backup set
channel ORA_DISK_5: specifying datafile(s) in backup set
input datafile file number=00007 name=+DATA/ractst/datafile/tbs_mlc.269.873559675
input datafile file number=00001 name=+DATA/ractst/datafile/system.256.873558057
channel ORA_DISK_5: starting piece 1 at 01-OCT-15
channel ORA_DISK_6: starting compressed full datafile backup set
channel ORA_DISK_6: specifying datafile(s) in backup set
input datafile file number=00006 name=+DATA/ractst/datafile/ts_audit.268.873559181
input datafile file number=00002 name=+DATA/ractst/datafile/sysaux.257.873558057
channel ORA_DISK_6: starting piece 1 at 01-OCT-15
channel ORA_DISK_7: starting compressed full datafile backup set
channel ORA_DISK_7: specifying datafile(s) in backup set
channel ORA_DISK_8: starting compressed full datafile backup set
channel ORA_DISK_8: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_8: starting piece 1 at 01-OCT-15
channel ORA_DISK_8: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_0fqikjcp.bkp tag=TAG20151001T160024 comment=NONE
channel ORA_DISK_8: backup set complete, elapsed time: 00:00:02
including current control file in backup set
channel ORA_DISK_7: starting piece 1 at 01-OCT-15
channel ORA_DISK_7: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_0eqikjcp.bkp tag=TAG20151001T160024 comment=NONE
channel ORA_DISK_7: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_6: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_0dqikjcp.bkp tag=TAG20151001T160024 comment=NONE
channel ORA_DISK_6: backup set complete, elapsed time: 00:00:37
channel ORA_DISK_5: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_0cqikjcp.bkp tag=TAG20151001T160024 comment=NONE
channel ORA_DISK_5: backup set complete, elapsed time: 00:02:27
channel ORA_DISK_4: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_0bqikjcp.bkp tag=TAG20151001T160024 comment=NONE
channel ORA_DISK_4: backup set complete, elapsed time: 00:04:47
channel ORA_DISK_1: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_08qikjcp.bkp tag=TAG20151001T160024 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:10:41
channel ORA_DISK_3: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_0aqikjcp.bkp tag=TAG20151001T160024 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:10:41
channel ORA_DISK_2: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_09qikjcp.bkp tag=TAG20151001T160024 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:10:51
Finished backup at 01-OCT-15

Daha önce backup alınmamış Archivelogları backuplayalım..

RMAN> BACKUP AS COMPRESSED BACKUPSET ARCHIVELOG ALL NOT BACKED UP 1 TIMES FORMAT '/orabackup/rman/ractst/archivelogs_%d_%T_%u.bkp';
 
Starting backup at 01-OCT-15
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
using channel ORA_DISK_7
using channel ORA_DISK_8
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=2 sequence=333 RECID=952 STAMP=891959773
input archived log thread=1 sequence=621 RECID=955 STAMP=891959778
channel ORA_DISK_1: starting piece 1 at 01-OCT-15
channel ORA_DISK_2: starting compressed archived log backup set
channel ORA_DISK_2: specifying archived log(s) in backup set
input archived log thread=2 sequence=334 RECID=953 STAMP=891959775
input archived log thread=2 sequence=335 RECID=954 STAMP=891959775
channel ORA_DISK_2: starting piece 1 at 01-OCT-15
channel ORA_DISK_3: starting compressed archived log backup set
channel ORA_DISK_3: specifying archived log(s) in backup set
input archived log thread=1 sequence=622 RECID=956 STAMP=891961462
channel ORA_DISK_3: starting piece 1 at 01-OCT-15
channel ORA_DISK_4: starting compressed archived log backup set
channel ORA_DISK_4: specifying archived log(s) in backup set
input archived log thread=2 sequence=336 RECID=958 STAMP=891964042
input archived log thread=1 sequence=623 RECID=957 STAMP=891964040
channel ORA_DISK_4: starting piece 1 at 01-OCT-15
channel ORA_DISK_5: starting compressed archived log backup set
channel ORA_DISK_5: specifying archived log(s) in backup set
input archived log thread=1 sequence=624 RECID=960 STAMP=891966763
input archived log thread=2 sequence=337 RECID=959 STAMP=891966762
channel ORA_DISK_5: starting piece 1 at 01-OCT-15
channel ORA_DISK_1: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/archivelogs_RACTST_20151001_0gqikl9b.bkp tag=TAG20151001T163243 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_2: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/archivelogs_RACTST_20151001_0hqikl9b.bkp tag=TAG20151001T163243 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_5: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/archivelogs_RACTST_20151001_0kqikl9c.bkp tag=TAG20151001T163243 comment=NONE
channel ORA_DISK_5: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_3: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/archivelogs_RACTST_20151001_0iqikl9b.bkp tag=TAG20151001T163243 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_4: finished piece 1 at 01-OCT-15
piece handle=/orabackup/rman/ractst/archivelogs_RACTST_20151001_0jqikl9c.bkp tag=TAG20151001T163243 comment=NONE
channel ORA_DISK_4: backup set complete, elapsed time: 00:00:07
Finished backup at 01-OCT-15

Eksik backup var mı kontrol edelim.

RMAN> report need backup;
 
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of files with less than 1 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------

Databaseleri kapatalım..

-bash-3.2$ srvctl stop database -d ractst
-bash-3.2$ srvctl status database -d ractst
Instance ractst1 is not running on node svtstrac01
Instance ractst2 is not running on node svtstrac02
-bash-3.2$

Asm üzerinden SYSTEM Datafileını silelim.

-bash-3.2$ORACLE_HOME=/oragrid/app/product/11.2.0.4/grid
-bash-3.2$ORACLE_SID=+ASM1
-bash-3.2$PATH=$ORACLE_HOME/bin:$PATH
-bash-3.2$export ORACLE_HOME ORACLE_SID PATH ORACLE_UNQNAME
 
ASMCMD> cd +DATA/RACTST/DATAFILE
ASMCMD> ls
SYSTEM.256.873558057
SYSAUX.257.873558057
TBS_DM.271.873561315
TBS_DM.272.873561081
TBS_DM.273.873560789
TBS_MLC.269.873559675
TBS_MX.270.873559789
TS_AUDIT.268.873559181
UNDOTBS1.258.873558059
UNDOTBS2.264.873558267
USERS.259.873558059
 
ASMCMD> rm SYSTEM.256.873558057
ASMCMD> ls
SYSAUX.257.873558057
TBS_DM.271.873561315
TBS_DM.272.873561081
TBS_DM.273.873560789
TBS_MLC.269.873559675
TBS_MX.270.873559789
TS_AUDIT.268.873559181
UNDOTBS1.258.873558059
UNDOTBS2.264.873558267
USERS.259.873558059

SYSTEM datafile’ı sildik,databaseleri start edelim.Ve hatayı görelim..

-bash-3.2$ srvctl start database -d ractst
PRCR-1079 : Failed to start resource ora.ractst.db
CRS-5017: The resource action "ora.ractst.db start" encountered the following error:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '+DATA/ractst/datafile/system.256.873558057'
 
CRS-2674: Start of 'ora.ractst.db' on 'svtstrac01' failed
CRS-2632: There are no more servers to try to place resource 'ora.ractst.db' on that would satisfy its placement policy
CRS-5017: The resource action "ora.ractst.db start" encountered the following error:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '+DATA/ractst/datafile/system.256.873558057'

Görüldüğü gibi SYSTEM datafile’ına erişemedi, ve instancelar startup olmadı..
İnstancelardan birine bağlanıp mount modda açalım ve cluster_database=false yapalım..

-bash-3.2$ sqlplus / as sysdba
 
SQL*Plus: Release 11.2.0.4.0 Production on Thu Oct 1 17:11:37 2015
 
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
 
Connected to an idle instance.
 
SQL> startup mount;
ORACLE instance started.
 
Total System Global Area 1.0689E+10 bytes
Fixed Size                  2233536 bytes
Variable Size            5905582912 bytes
Database Buffers         4764729344 bytes
Redo Buffers               16928768 bytes
Database mounted.
 
SQL> alter system set cluster_database=false scope=spfile sid='*';
 
System altered.
 
SQL> shutdown immediate;
ORA-01109: database not open
 
Database dismounted.
ORACLE instance shut down.

Parametreyi false yaptıktan sonra RMAN üzerinden mount edelim ve restore başlatalım..

-bash-3.2$ rman target /
 
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Oct 1 17:13:42 2015
 
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
 
connected to target database (not started)
 
RMAN> startup mount;
 
Oracle instance started
database mounted
 
Total System Global Area   10689474560 bytes
 
Fixed Size                     2233536 bytes
Variable Size               5905582912 bytes
Database Buffers            4764729344 bytes
Redo Buffers                  16928768 bytes

RMAN ile database restore başlatalım..

RMAN> restore database;
 
Starting restore at 01-OCT-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=355 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=125 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=246 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=363 device type=DISK
allocated channel: ORA_DISK_5
channel ORA_DISK_5: SID=9 device type=DISK
allocated channel: ORA_DISK_6
channel ORA_DISK_6: SID=126 device type=DISK
allocated channel: ORA_DISK_7
channel ORA_DISK_7: SID=247 device type=DISK
allocated channel: ORA_DISK_8
channel ORA_DISK_8: SID=364 device type=DISK
 
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00002 to +DATA/ractst/datafile/sysaux.257.873558057
channel ORA_DISK_1: restoring datafile 00006 to +DATA/ractst/datafile/ts_audit.268.873559181
channel ORA_DISK_1: reading from backup piece /orabackup/rman/ractst/datafiles_RACTST_20151001_0dqikjcp.bkp
channel ORA_DISK_2: starting datafile backup set restore
channel ORA_DISK_2: specifying datafile(s) to restore from backup set
channel ORA_DISK_2: restoring datafile 00001 to +DATA/ractst/datafile/system.256.873558057
channel ORA_DISK_2: restoring datafile 00007 to +DATA/ractst/datafile/tbs_mlc.269.873559675
channel ORA_DISK_2: reading from backup piece /orabackup/rman/ractst/datafiles_RACTST_20151001_0cqikjcp.bkp
channel ORA_DISK_3: starting datafile backup set restore
channel ORA_DISK_3: specifying datafile(s) to restore from backup set
channel ORA_DISK_3: restoring datafile 00003 to +DATA/ractst/datafile/undotbs1.258.873558059
channel ORA_DISK_3: restoring datafile 00008 to +DATA/ractst/datafile/tbs_mx.270.873559789
channel ORA_DISK_3: reading from backup piece /orabackup/rman/ractst/datafiles_RACTST_20151001_0bqikjcp.bkp
channel ORA_DISK_4: starting datafile backup set restore
channel ORA_DISK_4: specifying datafile(s) to restore from backup set
channel ORA_DISK_4: restoring datafile 00004 to +DATA/ractst/datafile/users.259.873558059
channel ORA_DISK_4: restoring datafile 00009 to +DATA/ractst/datafile/tbs_dm.273.873560789
channel ORA_DISK_4: reading from backup piece /orabackup/rman/ractst/datafiles_RACTST_20151001_08qikjcp.bkp
channel ORA_DISK_5: starting datafile backup set restore
channel ORA_DISK_5: specifying datafile(s) to restore from backup set
channel ORA_DISK_5: restoring datafile 00005 to +DATA/ractst/datafile/undotbs2.264.873558267
channel ORA_DISK_5: restoring datafile 00011 to +DATA/ractst/datafile/tbs_dm.271.873561315
channel ORA_DISK_5: reading from backup piece /orabackup/rman/ractst/datafiles_RACTST_20151001_0aqikjcp.bkp
channel ORA_DISK_6: starting datafile backup set restore
channel ORA_DISK_6: specifying datafile(s) to restore from backup set
channel ORA_DISK_6: restoring datafile 00010 to +DATA/ractst/datafile/tbs_dm.272.873561081
channel ORA_DISK_6: reading from backup piece /orabackup/rman/ractst/datafiles_RACTST_20151001_09qikjcp.bkp
channel ORA_DISK_1: piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_0dqikjcp.bkp tag=TAG20151001T160024
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
channel ORA_DISK_2: piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_0cqikjcp.bkp tag=TAG20151001T160024
channel ORA_DISK_2: restored backup piece 1
channel ORA_DISK_2: restore complete, elapsed time: 00:02:45
channel ORA_DISK_3: piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_0bqikjcp.bkp tag=TAG20151001T160024
channel ORA_DISK_3: restored backup piece 1
channel ORA_DISK_3: restore complete, elapsed time: 00:05:25
channel ORA_DISK_4: piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_08qikjcp.bkp tag=TAG20151001T160024
channel ORA_DISK_4: restored backup piece 1
channel ORA_DISK_4: restore complete, elapsed time: 00:13:35
channel ORA_DISK_5: piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_0aqikjcp.bkp tag=TAG20151001T160024
channel ORA_DISK_5: restored backup piece 1
channel ORA_DISK_5: restore complete, elapsed time: 00:13:35
channel ORA_DISK_6: piece handle=/orabackup/rman/ractst/datafiles_RACTST_20151001_09qikjcp.bkp tag=TAG20151001T160024
channel ORA_DISK_6: restored backup piece 1
channel ORA_DISK_6: restore complete, elapsed time: 00:13:45
Finished restore at 01-OCT-15

Restore işlemi bittikten sonra recover diyerek archivelogları da işletelim ve database’i son ana kadar getirelim.

RMAN> recover database;
 
Starting recover at 01-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
using channel ORA_DISK_7
using channel ORA_DISK_8
 
starting media recovery
media recovery complete, elapsed time: 00:00:02
 
Finished recover at 01-OCT-15

Restore ve recover tamamlandı, şimdi cluster_database=true yapıp instanceları başlatalım..

-bash-3.2$ sqlplus / as sysdba
 
SQL*Plus: Release 11.2.0.4.0 Production on Thu Oct 1 17:30:58 2015
 
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
 
SQL> alter system set cluster_database=true scope=spfile sid='*';
 
System altered.
 
SQL> shu immediate;
ORA-01109: database not open
 
Database dismounted.
ORACLE instance shut down.

Şimdi Her iki instanceı da başlatalım..

-bash-3.2$ srvctl start database -d ractst
 
-bash-3.2$ srvctl status database -d ractst
Instance ractst1 is running on node svtstrac01
Instance ractst2 is running on node svtstrac02

İşlem tamamdır. Databaselerimiz ayakta : )

Notlar:
-Restore recover işlemini tek nod üzerinden yaptık,bunun için cluster_database parametresini false yapmamız gerekti.
-Restore sonrasında bu parametreyi true yaparak iki nodu birden ayağa kaldırdık.
-Burdaki senaryoda aslında datafile kayıptı.Restore datafile,recover datafile diyerek yapabilirdik,daha kısa sürerdi, örnek olması açısından yaptım.
-Backup ve restore adımlarında 8 channel görünüyor, rman configrasyonunda 8 parallel verdiğim için 8 channel açtı.

Umarım faydalı olur..

Tagged: , , , , , , ,

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir