Thursday, February 24, 2011

Restoring whole database after deleting a datafile

do a full backup

Starting backup at 24-FEB-11
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=17 RECID=19 STAMP=743104301
input archived log thread=1 sequence=21 RECID=20 STAMP=743155273
input archived log thread=1 sequence=22 RECID=21 STAMP=743911539
input archived log thread=1 sequence=23 RECID=22 STAMP=743913643
input archived log thread=1 sequence=24 RECID=23 STAMP=743929228
input archived log thread=1 sequence=25 RECID=24 STAMP=743965101
input archived log thread=1 sequence=26 RECID=25 STAMP=743965102
channel ORA_DISK_1: starting piece 1 at 24-FEB-11
channel ORA_DISK_1: finished piece 1 at 24-FEB-11
piece handle=/data/stage/toronto/backup/0cm5g0dg_1_1
tag=TAG20110224T165824 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/arch/toronto/1_17_742858742.dbf RECID=19 STAMP=743104301
archived log file name=/arch/toronto/1_21_742858742.dbf RECID=20 STAMP=743155273
archived log file name=/arch/toronto/1_22_742858742.dbf RECID=21 STAMP=743911539
archived log file name=/arch/toronto/1_23_742858742.dbf RECID=22 STAMP=743913643
archived log file name=/arch/toronto/1_24_742858742.dbf RECID=23 STAMP=743929228
archived log file name=/arch/toronto/1_25_742858742.dbf RECID=24 STAMP=743965101
archived log file name=/arch/toronto/1_26_742858742.dbf RECID=25 STAMP=743965102
Finished backup at 24-FEB-11

Starting backup at 24-FEB-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/toronto/toronto/system01.dbf
input datafile file number=00002 name=/data/toronto/toronto/sysaux01.dbf
input datafile file number=00003 name=/data/toronto/toronto/undotbs01.dbf
input datafile file number=00005 name=/data/toronto/toronto/toronto01.dbf
input datafile file number=00004 name=/data/toronto/toronto/users01.dbf
channel ORA_DISK_1: starting piece 1 at 24-FEB-11
channel ORA_DISK_1: finished piece 1 at 24-FEB-11
piece handle=/data/stage/toronto/backup/0dm5g0e0_1_1
tag=TAG20110224T165840 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:47
Finished backup at 24-FEB-11

Starting backup at 24-FEB-11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=27 RECID=26 STAMP=743965167
channel ORA_DISK_1: starting piece 1 at 24-FEB-11
channel ORA_DISK_1: finished piece 1 at 24-FEB-11
piece handle=/data/stage/toronto/backup/0em5g0fh_1_1
tag=TAG20110224T165928 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/arch/toronto/1_27_742858742.dbf RECID=26 STAMP=743965167
Finished backup at 24-FEB-11

Starting Control File and SPFILE Autobackup at 24-FEB-11
piece handle=/u01/app/oracle/flash_recovery_area/TORONTO/autobackup/2011_02_24/o1_mf_s_743965170_6pfo63kg_.bkp
comment=NONE
Finished Control File and SPFILE Autobackup at 24-FEB-11

... exit RMAN

remove the datafile toronto01.dbf

shutdown and startup mount toronto

start RMAN again

restore the whole database

Starting restore at 24-FEB-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 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 00001 to
/data/toronto/toronto/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to
/data/toronto/toronto/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to
/data/toronto/toronto/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to
/data/toronto/toronto/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to
/data/toronto/toronto/toronto01.dbf
channel ORA_DISK_1: reading from backup piece
/data/stage/toronto/backup/0dm5g0e0_1_1
channel ORA_DISK_1: piece
handle=/data/stage/toronto/backup/0dm5g0e0_1_1 tag=TAG20110224T165840
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 24-FEB-11

... exit RMAN

shutdown and start toronto

check the datafile status, it should be offline

bring it online

verify you can select data from that datafile, in my case, it is table toronto

Thursday, February 17, 2011

Reverting new primary back to standby

The process is pretty much the same as if you are switching over from original primary database to physical standby.

Following our previous examples. We have H2 as the new primary.
We shall switch it back to the standby.

Check the contents of archive destination for boston (on H2)

/arch/boston
-rw-r----- 1 oracle oinstall 309248 Feb 8 10:16 1_19_741607100.dbf
-rw-r----- 1 oracle oinstall 5253120 Feb 8 10:16 1_18_741607100.dbf
-rw-r----- 1 oracle oinstall 2229248 Feb 8 11:20 1_20_741607100.dbf
-rw-r----- 1 oracle oinstall 9216 Feb 8 11:21 1_21_741607100.dbf
-rw-r----- 1 oracle oinstall 224256 Feb 8 11:22 1_17_741607100.dbf
-rw-r----- 1 oracle oinstall 471552 Feb 9 04:57 1_22_741607100.dbf
-rw-r----- 1 oracle oinstall 101376 Feb 9 04:57 1_23_741607100.dbf
-rw-r----- 1 oracle oinstall 8559616 Feb 9 06:15 1_24_741607100.dbf
-rw-r----- 1 oracle oinstall 116224 Feb 9 06:21 1_25_741607100.dbf
-rw-r----- 1 oracle oinstall 14848 Feb 9 06:21 1_26_741607100.dbf
-rw-r----- 1 oracle oinstall 12288 Feb 9 06:21 1_27_741607100.dbf
-rw-r----- 1 oracle oinstall 1024 Feb 9 06:26 1_28_741607100.dbf
-rw-r----- 1 oracle oinstall 41472 Feb 9 06:27 1_29_741607100.dbf
-rw-r----- 1 oracle oinstall 19968 Feb 9 06:27 1_30_741607100.dbf
-rw-r----- 1 oracle oinstall 209920 Feb 9 06:39 1_31_741607100.dbf
-rw-r----- 1 oracle oinstall 456704 Feb 9 06:55 1_32_741607100.dbf
-rw-r----- 1 oracle oinstall 1334272 Feb 9 07:15 1_33_741607100.dbf
-rw-r----- 1 oracle oinstall 50688 Feb 9 07:15 1_34_741607100.dbf
-rw-r----- 1 oracle oinstall 5035520 Feb 9 09:39 1_35_741607100.dbf
-rw-r----- 1 oracle oinstall 45088256 Feb 9 22:07 1_36_741607100.dbf
-rw-r----- 1 oracle oinstall 40347648 Feb 10 13:02 1_37_741607100.dbf
-rw-r----- 1 oracle oinstall 41274880 Feb 10 22:07 1_38_741607100.dbf
-rw-r----- 1 oracle oinstall 40055296 Feb 11 14:49 1_39_741607100.dbf
-rw-r----- 1 oracle oinstall 41124864 Feb 11 22:06 1_40_741607100.dbf
-rw-r----- 1 oracle oinstall 40373248 Feb 12 10:13 1_41_741607100.dbf
-rw-r----- 1 oracle oinstall 40055808 Feb 12 17:31 1_42_741607100.dbf
-rw-r----- 1 oracle oinstall 40054784 Feb 12 22:59 1_43_741607100.dbf
-rw-r----- 1 oracle oinstall 41642496 Feb 13 10:16 1_44_741607100.dbf
-rw-r----- 1 oracle oinstall 43699200 Feb 13 18:42 1_45_741607100.dbf
-rw-r----- 1 oracle oinstall 40054784 Feb 14 04:51 1_46_741607100.dbf
-rw-r----- 1 oracle oinstall 40991744 Feb 14 21:11 1_47_741607100.dbf
-rw-r----- 1 oracle oinstall 40881664 Feb 15 03:00 1_48_741607100.dbf

The status now should be

SWITCHOVER_STATUS
--------------------
TO STANDBY

Execute the switch over command. Then shutdown the database immediate and mount it.

ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;

Check the status again, it should be

SWITCHOVER_STATUS
--------------------
TO PRIMARY

DATABASE_ROLE DB_UNIQUE_NAME NAME
---------------- ------------------------------ ---------
PHYSICAL STANDBY boston CHICAGO

Go to the old standby database chicago now and execute switch over command.

ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

And open the database. Also, check the role.

DATABASE_ROLE DB_UNIQUE_NAME NAME
---------------- ------------------------------ ---------
PRIMARY chicago CHICAGO

On the new standby database, boston, turn on the recovery process. Then generate a new log file on primary.

/arch/chicago
-rw-r----- 1 oracle oinstall 4865536 Feb 7 05:12 1_5_741607100.dbf
-rw-r----- 1 oracle oinstall 32439808 Feb 7 06:03 1_6_741607100.dbf
-rw-r----- 1 oracle oinstall 48640 Feb 7 06:08 1_7_741607100.dbf
-rw-r----- 1 oracle oinstall 6873600 Feb 7 11:01 1_8_741607100.dbf
-rw-r----- 1 oracle oinstall 2055168 Feb 7 11:42 1_9_741607100.dbf
-rw-r----- 1 oracle oinstall 51200 Feb 7 11:42 1_10_741607100.dbf
-rw-r----- 1 oracle oinstall 40399872 Feb 7 22:03 1_11_741607100.dbf
-rw-r----- 1 oracle oinstall 22781440 Feb 8 04:08 1_12_741607100.dbf
-rw-r----- 1 oracle oinstall 269312 Feb 8 04:47 1_13_741607100.dbf
-rw-r----- 1 oracle oinstall 5327872 Feb 8 07:18 1_14_741607100.dbf
-rw-r----- 1 oracle oinstall 36864 Feb 8 07:19 1_15_741607100.dbf
-rw-r----- 1 oracle oinstall 69120 Feb 8 07:21 1_16_741607100.dbf
-rw-r----- 1 oracle oinstall 224256 Feb 8 07:36 1_17_741607100.dbf
-rw-r----- 1 oracle oinstall 5253120 Feb 8 10:02 1_18_741607100.dbf
-rw-r----- 1 oracle oinstall 309248 Feb 8 10:16 1_19_741607100.dbf
-rw-r----- 1 oracle oinstall 2229248 Feb 8 11:20 1_20_741607100.dbf
-rw-r----- 1 oracle oinstall 9216 Feb 8 11:21 1_21_741607100.dbf
-rw-r----- 1 oracle oinstall 471552 Feb 9 04:55 1_22_741607100.dbf
-rw-r----- 1 oracle oinstall 101376 Feb 9 04:57 1_23_741607100.dbf
-rw-r----- 1 oracle oinstall 8559616 Feb 9 06:15 1_24_741607100.dbf
-rw-r----- 1 oracle oinstall 116224 Feb 9 06:21 1_25_741607100.dbf
-rw-r----- 1 oracle oinstall 14848 Feb 9 06:21 1_26_741607100.dbf
-rw-r----- 1 oracle oinstall 12288 Feb 9 06:21 1_27_741607100.dbf
-rw-r----- 1 oracle oinstall 1334272 Feb 9 07:15 1_33_741607100.dbf
-rw-r----- 1 oracle oinstall 41472 Feb 9 07:15 1_29_741607100.dbf
-rw-r----- 1 oracle oinstall 19968 Feb 9 07:15 1_30_741607100.dbf
-rw-r----- 1 oracle oinstall 1024 Feb 9 07:15 1_28_741607100.dbf
-rw-r----- 1 oracle oinstall 456704 Feb 9 07:15 1_32_741607100.dbf
-rw-r----- 1 oracle oinstall 209920 Feb 9 07:15 1_31_741607100.dbf
-rw-r----- 1 oracle oinstall 50688 Feb 9 07:15 1_34_741607100.dbf
-rw-r----- 1 oracle oinstall 5035520 Feb 9 09:39 1_35_741607100.dbf
-rw-r----- 1 oracle oinstall 45088256 Feb 9 22:07 1_36_741607100.dbf
-rw-r----- 1 oracle oinstall 40347648 Feb 10 13:01 1_37_741607100.dbf
-rw-r----- 1 oracle oinstall 41274880 Feb 10 22:07 1_38_741607100.dbf
-rw-r----- 1 oracle oinstall 40055296 Feb 11 14:48 1_39_741607100.dbf
-rw-r----- 1 oracle oinstall 41124864 Feb 11 22:06 1_40_741607100.dbf
-rw-r----- 1 oracle oinstall 40373248 Feb 12 10:13 1_41_741607100.dbf
-rw-r----- 1 oracle oinstall 40055808 Feb 12 17:31 1_42_741607100.dbf
-rw-r----- 1 oracle oinstall 40054784 Feb 12 23:00 1_43_741607100.dbf
-rw-r----- 1 oracle oinstall 41642496 Feb 13 10:17 1_44_741607100.dbf
-rw-r----- 1 oracle oinstall 43699200 Feb 13 18:43 1_45_741607100.dbf
-rw-r----- 1 oracle oinstall 40054784 Feb 14 04:51 1_46_741607100.dbf
-rw-r----- 1 oracle oinstall 40991744 Feb 14 21:12 1_47_741607100.dbf
-rw-r----- 1 oracle oinstall 40881664 Feb 15 03:00 1_48_741607100.dbf
-rw-r----- 1 oracle oinstall 21595136 Feb 15 12:09 1_49_741607100.dbf
-rw-r----- 1 oracle oinstall 27136 Feb 15 12:10 1_50_741607100.dbf
-rw-r----- 1 oracle oinstall 14336 Feb 15 12:11 1_51_741607100.dbf
-rw-r----- 1 oracle oinstall 1024 Feb 15 12:17 1_52_741607100.dbf
-rw-r----- 1 oracle oinstall 2048 Feb 15 12:18 1_53_741607100.dbf
-rw-r----- 1 oracle oinstall 60928 Feb 15 12:23 1_54_741607100.dbf

Wait a short time, and go to standby database and check the logs.

/arch/boston
-rw-r----- 1 oracle oinstall 309248 Feb 8 10:16 1_19_741607100.dbf
-rw-r----- 1 oracle oinstall 5253120 Feb 8 10:16 1_18_741607100.dbf
-rw-r----- 1 oracle oinstall 2229248 Feb 8 11:20 1_20_741607100.dbf
-rw-r----- 1 oracle oinstall 9216 Feb 8 11:21 1_21_741607100.dbf
-rw-r----- 1 oracle oinstall 224256 Feb 8 11:22 1_17_741607100.dbf
-rw-r----- 1 oracle oinstall 471552 Feb 9 04:57 1_22_741607100.dbf
-rw-r----- 1 oracle oinstall 101376 Feb 9 04:57 1_23_741607100.dbf
-rw-r----- 1 oracle oinstall 8559616 Feb 9 06:15 1_24_741607100.dbf
-rw-r----- 1 oracle oinstall 116224 Feb 9 06:21 1_25_741607100.dbf
-rw-r----- 1 oracle oinstall 14848 Feb 9 06:21 1_26_741607100.dbf
-rw-r----- 1 oracle oinstall 12288 Feb 9 06:21 1_27_741607100.dbf
-rw-r----- 1 oracle oinstall 1024 Feb 9 06:26 1_28_741607100.dbf
-rw-r----- 1 oracle oinstall 41472 Feb 9 06:27 1_29_741607100.dbf
-rw-r----- 1 oracle oinstall 19968 Feb 9 06:27 1_30_741607100.dbf
-rw-r----- 1 oracle oinstall 209920 Feb 9 06:39 1_31_741607100.dbf
-rw-r----- 1 oracle oinstall 456704 Feb 9 06:55 1_32_741607100.dbf
-rw-r----- 1 oracle oinstall 1334272 Feb 9 07:15 1_33_741607100.dbf
-rw-r----- 1 oracle oinstall 50688 Feb 9 07:15 1_34_741607100.dbf
-rw-r----- 1 oracle oinstall 5035520 Feb 9 09:39 1_35_741607100.dbf
-rw-r----- 1 oracle oinstall 45088256 Feb 9 22:07 1_36_741607100.dbf
-rw-r----- 1 oracle oinstall 40347648 Feb 10 13:02 1_37_741607100.dbf
-rw-r----- 1 oracle oinstall 41274880 Feb 10 22:07 1_38_741607100.dbf
-rw-r----- 1 oracle oinstall 40055296 Feb 11 14:49 1_39_741607100.dbf
-rw-r----- 1 oracle oinstall 41124864 Feb 11 22:06 1_40_741607100.dbf
-rw-r----- 1 oracle oinstall 40373248 Feb 12 10:13 1_41_741607100.dbf
-rw-r----- 1 oracle oinstall 40055808 Feb 12 17:31 1_42_741607100.dbf
-rw-r----- 1 oracle oinstall 40054784 Feb 12 22:59 1_43_741607100.dbf
-rw-r----- 1 oracle oinstall 41642496 Feb 13 10:16 1_44_741607100.dbf
-rw-r----- 1 oracle oinstall 43699200 Feb 13 18:42 1_45_741607100.dbf
-rw-r----- 1 oracle oinstall 40054784 Feb 14 04:51 1_46_741607100.dbf
-rw-r----- 1 oracle oinstall 40991744 Feb 14 21:11 1_47_741607100.dbf
-rw-r----- 1 oracle oinstall 40881664 Feb 15 03:00 1_48_741607100.dbf
-rw-r----- 1 oracle oinstall 21595136 Feb 15 12:09 1_49_741607100.dbf
-rw-r----- 1 oracle oinstall 27136 Feb 15 12:10 1_50_741607100.dbf
-rw-r----- 1 oracle oinstall 14336 Feb 15 12:11 1_51_741607100.dbf
-rw-r----- 1 oracle oinstall 1024 Feb 15 12:20 1_52_741607100.dbf
-rw-r----- 1 oracle oinstall 2048 Feb 15 12:20 1_53_741607100.dbf
-rw-r----- 1 oracle oinstall 60928 Feb 15 12:23 1_54_741607100.dbf

SEQUENCE# APPLIED
---------- ---------
17 YES
18 YES
19 YES
20 YES
21 YES
22 YES
23 YES
24 YES
25 YES
26 YES
27 YES

SEQUENCE# APPLIED
---------- ---------
28 YES
28 YES
29 YES
29 YES
30 YES
30 YES
31 YES
31 YES
32 YES
32 YES
33 YES

SEQUENCE# APPLIED
---------- ---------
33 YES
34 YES
34 YES
35 YES
35 YES
36 YES
36 YES
37 YES
37 YES
38 YES
38 YES

SEQUENCE# APPLIED
---------- ---------
39 YES
39 YES
40 YES
40 YES
41 YES
41 YES
42 YES
42 YES
43 YES
43 YES
44 YES

SEQUENCE# APPLIED
---------- ---------
44 YES
45 YES
45 YES
46 YES
46 YES
47 YES
47 YES
48 YES
48 YES
49 YES
49 YES

SEQUENCE# APPLIED
---------- ---------
50 YES
50 NO
51 YES
51 NO
52 NO
53 NO
54 NO

Monday, February 14, 2011

Switching archive log destination

Generate a log file using default destination.

/arch/toronto
-rw-r----- 1 oracle oinstall 6656 Feb 14 17:40 1_16_742858742.dbf

Change the destination now, and generate another log file.

/arch/toronto_temp
-rw-r----- 1 oracle oinstall 10240 Feb 14 17:43 1_17_742858742.dbf

Switch the destination back to original, and generate another log file.

/arch/toronto
-rw-r----- 1 oracle oinstall 6656 Feb 14 17:40 1_16_742858742.dbf
-rw-r----- 1 oracle oinstall 2560 Feb 14 17:43 1_18_742858742.dbf

Run a backup of archive logs.

Starting backup at 14-FEB-11
current log archived
...
archived log file name=/arch/toronto/1_16_742858742.dbf RECID=14 STAMP=743103604
archived log file name=/arch/toronto_temp/1_17_742858742.dbf RECID=15 STAMP=743103792
archived log file name=/arch/toronto/1_18_742858742.dbf RECID=16 STAMP=743103834
archived log file name=/arch/toronto/1_19_742858742.dbf RECID=17 STAMP=743104161
archived log file name=/arch/toronto/1_20_742858742.dbf RECID=18 STAMP=743104162
Finished backup at 14-FEB-11

We will see both the original destination and temp destination archive logs are backed up and removed.

Now restore the log file sequence #17 to original location.

/arch/toronto
-rw-r----- 1 oracle oinstall 10240 Feb 14 17:51 1_17_742858742.dbf

We can view archive log details using rman.

List of Backup Sets
===================

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
51 119.51M DISK 00:00:05 12-FEB-11
BP Key: 54 Status: AVAILABLE Compressed: NO Tag: TAG20110212T201930
Piece Name: /data/stage/toronto/backup/01m4gnmj_1_1

List of Archived Logs in backup set 51
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 4 779391 11-FEB-11 800324 11-FEB-11
1 5 800324 11-FEB-11 823330 12-FEB-11
1 6 823330 12-FEB-11 841950 12-FEB-11

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
71 90.00K DISK 00:00:00 12-FEB-11
BP Key: 76 Status: AVAILABLE Compressed: NO Tag: TAG20110212T202027
Piece Name: /data/stage/toronto/backup/03m4gnoc_1_1

List of Archived Logs in backup set 71
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 7 841950 12-FEB-11 842048 12-FEB-11

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
137 265.18M DISK 00:00:41 14-FEB-11
BP Key: 140 Status: AVAILABLE Compressed: NO Tag: TAG20110214T163109
Piece Name: /data/stage/toronto/backup/05m4lj2f_1_1

List of Archived Logs in backup set 137
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 4 779391 11-FEB-11 800324 11-FEB-11
1 5 800324 11-FEB-11 823330 12-FEB-11
1 6 823330 12-FEB-11 841950 12-FEB-11
1 7 841950 12-FEB-11 842048 12-FEB-11
1 8 842048 12-FEB-11 847862 12-FEB-11
1 9 847862 12-FEB-11 869074 13-FEB-11
1 10 869074 13-FEB-11 891741 13-FEB-11
1 11 891741 13-FEB-11 916649 14-FEB-11
1 12 916649 14-FEB-11 916667 14-FEB-11

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
203 41.03M DISK 00:00:01 14-FEB-11
BP Key: 206 Status: AVAILABLE Compressed: NO Tag: TAG20110214T173236
Piece Name: /data/stage/toronto/backup/07m4lmlk_1_1

List of Archived Logs in backup set 203
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 5 800324 11-FEB-11 823330 12-FEB-11
1 13 916667 14-FEB-11 918073 14-FEB-11
1 14 918073 14-FEB-11 918159 14-FEB-11
1 15 918159 14-FEB-11 918179 14-FEB-11

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
260 35.00K DISK 00:00:00 14-FEB-11
BP Key: 263 Status: AVAILABLE Compressed: NO Tag: TAG20110214T174923
Piece Name: /data/stage/toronto/backup/09m4lnl3_1_1

List of Archived Logs in backup set 260
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 16 918179 14-FEB-11 918390 14-FEB-11
1 17 918390 14-FEB-11 918461 14-FEB-11
1 18 918461 14-FEB-11 918475 14-FEB-11
1 19 918475 14-FEB-11 918602 14-FEB-11
1 20 918602 14-FEB-11 918620 14-FEB-11

Running archive backup again.

Here, there is sequence #5 which had been already backed-up previously.  (Here)
We restored it back to this destination. A new log file also has been generated, file # 13.

-rw-r----- 1 oracle oinstall 41651200 Feb 14 16:47 1_5_742858742.dbf
-rw-r----- 1 oracle oinstall 1362432 Feb 14 17:29 1_13_742858742.dbf

We will run archive backup now and delete input to see what happens.

The result is, all of the archive logs are deleted from archive destination, including #5.

Backing up archive logs

Further our previous discussion (here) about setting up RMAN catalog, let's demo the removal of archive logs after backup.

Start up the rman session again.

Issue the rman command that backs up archives and also removes the inputs. While it's running, you have a moment to review the archive destination.

The archive destination is as follows

-rw-r----- 1 oracle oinstall 52023296 Feb 11 23:01 1_4_742858742.dbf
-rw-r----- 1 oracle oinstall 41651200 Feb 12 10:08 1_5_742858742.dbf
-rw-r----- 1 oracle oinstall 31639040 Feb 12 20:19 1_6_742858742.dbf
-rw-r----- 1 oracle oinstall 91136 Feb 12 20:20 1_7_742858742.dbf
-rw-r----- 1 oracle oinstall 41349632 Feb 12 22:32 1_8_742858742.dbf
-rw-r----- 1 oracle oinstall 41532416 Feb 13 10:07 1_9_742858742.dbf
-rw-r----- 1 oracle oinstall 44419584 Feb 13 22:21 1_10_742858742.dbf
-rw-r----- 1 oracle oinstall 25357312 Feb 14 16:31 1_11_742858742.dbf
-rw-r----- 1 oracle oinstall 1024 Feb 14 16:31 1_12_742858742.dbf

Just before the rman backup finishes, it will delete the backed up archives.

Check the backup location, and you will see the new file it just created

-rw-r----- 1 oracle oinstall 278062592 Feb 14 16:31 05m4lj2f_1_1

If we want to restore a particular archive log, we can do so.

For example, if we want log sequence #5, we can see it will bring it back:

-rw-r----- 1 oracle oinstall 41651200 Feb 14 16:47 1_5_742858742.dbf

Saturday, February 12, 2011

Configuring rman catalog

Create the tablespace and user rman first inside the rman catalog database.

1. create tablespace rman ...
2. create user rmantoronto ...
3. grant the role recovery_catalog_owner to this new user.

Connect to rman using this user now.
Create the catalog.

Register the catalog and configure parameters.
Connect to the target using the catalog.

connected to target database: TORONTO (DBID=3278972211)
connected to recovery catalog database

Register the database.

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

Also, do the following
1. set the retention
2. set the disk type
3. set auto backup control file
4. set format

Now do a full backup.

Starting backup at 12-FEB-11
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=4 RECID=1 STAMP=742863663
input archived log thread=1 sequence=5 RECID=2 STAMP=742903701
input archived log thread=1 sequence=6 RECID=3 STAMP=742940369
channel ORA_DISK_1: starting piece 1 at 12-FEB-11
channel ORA_DISK_1: finished piece 1 at 12-FEB-11
piece handle=/data/stage/toronto/backup/01m4gnmj_1_1 tag=TAG20110212T201930 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 12-FEB-11

Starting backup at 12-FEB-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/toronto/toronto/system01.dbf
input datafile file number=00002 name=/data/toronto/toronto/sysaux01.dbf
input datafile file number=00003 name=/data/toronto/toronto/undotbs01.dbf
input datafile file number=00004 name=/data/toronto/toronto/users01.dbf
channel ORA_DISK_1: starting piece 1 at 12-FEB-11
channel ORA_DISK_1: finished piece 1 at 12-FEB-11
piece handle=/data/stage/toronto/backup/02m4gnmr_1_1 tag=TAG20110212T201939 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:46
Finished backup at 12-FEB-11

Starting backup at 12-FEB-11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=7 RECID=4 STAMP=742940426
channel ORA_DISK_1: starting piece 1 at 12-FEB-11
channel ORA_DISK_1: finished piece 1 at 12-FEB-11
piece handle=/data/stage/toronto/backup/03m4gnoc_1_1 tag=TAG20110212T202027 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-FEB-11

Starting Control File and SPFILE Autobackup at 12-FEB-11
piece handle=/u01/app/oracle/flash_recovery_area/TORONTO/autobackup/2011_02_12/o1_mf_s_742940430_6ogdgypg_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 12-FEB-11

RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 7 days
using channel ORA_DISK_1
no obsolete backups found

See the backed up files:

-rw-r----- 1 oracle oinstall 125314048 Feb 12 20:19 01m4gnmj_1_1
-rw-r----- 1 oracle oinstall 1001431040 Feb 12 20:20 02m4gnmr_1_1
-rw-r----- 1 oracle oinstall 92672 Feb 12 20:20 03m4gnoc_1_1

We can see the details of the backup:

List of Backup Sets
===================

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
51 119.51M DISK 00:00:05 12-FEB-11
BP Key: 54 Status: AVAILABLE Compressed: NO Tag: TAG20110212T201930
Piece Name: /data/stage/toronto/backup/01m4gnmj_1_1

List of Archived Logs in backup set 51
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 4 779391 11-FEB-11 800324 11-FEB-11
1 5 800324 11-FEB-11 823330 12-FEB-11
1 6 823330 12-FEB-11 841950 12-FEB-11

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
52 Full 955.03M DISK 00:00:43 12-FEB-11
BP Key: 55 Status: AVAILABLE Compressed: NO Tag: TAG20110212T201939
Piece Name: /data/stage/toronto/backup/02m4gnmr_1_1
List of Datafiles in backup set 52
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 841970 12-FEB-11 /data/toronto/toronto/system01.dbf
2 Full 841970 12-FEB-11 /data/toronto/toronto/sysaux01.dbf
3 Full 841970 12-FEB-11 /data/toronto/toronto/undotbs01.dbf
4 Full 841970 12-FEB-11 /data/toronto/toronto/users01.dbf

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
71 90.00K DISK 00:00:00 12-FEB-11
BP Key: 76 Status: AVAILABLE Compressed: NO Tag: TAG20110212T202027
Piece Name: /data/stage/toronto/backup/03m4gnoc_1_1

List of Archived Logs in backup set 71
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 7 841950 12-FEB-11 842048 12-FEB-11

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
84 Full 9.36M DISK 00:00:00 12-FEB-11
BP Key: 86 Status: AVAILABLE Compressed: NO Tag: TAG20110212T202030
Piece Name: /u01/app/oracle/flash_recovery_area/TORONTO/autobackup/2011_02_12/o1_mf_s_742940430_6ogdgypg_.bkp
SPFILE Included: Modification time: 12-FEB-11
SPFILE db_unique_name: TORONTO
Control File Included: Ckp SCN: 842073 Ckp time: 12-FEB-11

Thursday, February 10, 2011

Switch over from primary to standby database

Assumptions before we begin this exercise.
1.  Primary and standby are running on two hosts, H1 and H2  (see previous post)

Check the status of the primary database.

SWITCHOVER_STATUS
--------------------
TO STANDBY

Issus the switch over command.

ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;

Then shutdown the primary database and start it up mount.

Check the status again

SWITCHOVER_STATUS
--------------------
TO PRIMARY

Confirm the database role of the new standby

DATABASE_ROLE    DB_UNIQUE_NAME                 NAME
---------------- ------------------------------ ---------
PHYSICAL STANDBY chicago                                      CHICAGO

On the new primary database, perform the following

ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

Then open the database.

Check the role of the new primary database now

DATABASE_ROLE    DB_UNIQUE_NAME                 NAME
---------------- ------------------------------ ---------
PRIMARY          boston                                            CHICAGO

Test out the log switching, goto the new standby and run a query on the archive logs

Start the standby recover process on the new standby

Issue a log switch from new primary

Check again the archive logs on the new standby

Creating a physical standby database

Some details about the set-up before we begin:

1. There are 2 servers running oracle binaries. (11gR2 in my case)
2. They can see each other on the network
3. Your primary database is already running on primary host
4. Primary database is in archive log mode

In this example, the primary host is called H1. And the standby host is called H2.
First thing to do is to set up the listeners on H1 and H2.

There are 2 databases, chicago on H1 and boston on H2. Test the connections.

Ping boston from H1

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = H2.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = boston)))

OK (10 msec)

Ping chicago from H2

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = H1.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = chicago)))

OK (70 msec)

Prepare the pfile from chicago and put it on the H2. Edit it when it is on H2.

Take note of all the paths that needs to be corrected and reflected from H2 now. Make sure those paths do exist before continuing. Connect to the database now. You will see it is in IDLE state. Create a spfile.

Now start boston with nomount.

We will backup chicago database.

backup device type disk format '/data/stage/%U' database plus archivelog;
backup device type disk format '/data/stage/%U' current controlfile for standby;

Send the files over to H2.
Once transmission is done, duplicate the database on H2.

duplicate target database for standby;

When that is complete, add the redo log files. Also, add standby redo logs.

Start the standby recover process on boston now:

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Check the archive logs now on boston.

Switch the log on chicago
Check again the archive logs on boston now.

Now, let's switch over to standby