Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,380 --> 00:00:05,880
In this lesson, we're going to
do an RMAN incomplete recovery.
2
00:00:05,880 --> 00:00:08,070
Now, you might ask,
why in the world
3
00:00:08,070 --> 00:00:10,860
would we want to do an
incomplete recovery?
4
00:00:10,860 --> 00:00:13,080
Well, there are
certain circumstances.
5
00:00:13,080 --> 00:00:15,450
Of course, a complete
recovery occurs
6
00:00:15,450 --> 00:00:18,000
when we restore from
backup and recover up
7
00:00:18,000 --> 00:00:20,850
until the last
committed transaction.
8
00:00:20,850 --> 00:00:23,820
And that's what we would need
in the case of media failures
9
00:00:23,820 --> 00:00:26,220
and those types of problems.
10
00:00:26,220 --> 00:00:30,330
But there are situations that
call for incomplete recoveries.
11
00:00:30,330 --> 00:00:32,850
And in an incomplete
recovery, what we will do
12
00:00:32,850 --> 00:00:36,060
is restore the
backup and recover up
13
00:00:36,060 --> 00:00:38,350
until a point in the past.
14
00:00:38,350 --> 00:00:40,380
So why would we need to do this?
15
00:00:40,380 --> 00:00:43,320
Well, a simple example would
be unfortunately something
16
00:00:43,320 --> 00:00:44,910
that happens all too often.
17
00:00:44,910 --> 00:00:47,610
Let's say that a
user accidentally
18
00:00:47,610 --> 00:00:50,730
had the privileges to
drop a production table.
19
00:00:50,730 --> 00:00:54,630
And so they drop a table
in production on a Monday.
20
00:00:54,630 --> 00:00:57,420
On Tuesday morning,
we discover this.
21
00:00:57,420 --> 00:00:59,910
And then a decision
has to be made.
22
00:00:59,910 --> 00:01:02,190
Is the table important enough--
23
00:01:02,190 --> 00:01:04,830
assuming that there's no
other way to recover the data,
24
00:01:04,830 --> 00:01:07,080
is it important
enough that we lose
25
00:01:07,080 --> 00:01:10,230
all of the data that
occurred after the drop,
26
00:01:10,230 --> 00:01:14,190
because what we're talking about
doing is restoring the backup
27
00:01:14,190 --> 00:01:18,990
and recovering the database
right up until before the table
28
00:01:18,990 --> 00:01:20,160
drop occurred.
29
00:01:20,160 --> 00:01:21,990
Now, there can be some
difficulty in exactly
30
00:01:21,990 --> 00:01:24,930
finding out when that occurred.
31
00:01:24,930 --> 00:01:28,500
But assuming we can find a
mark to hit, if you will,
32
00:01:28,500 --> 00:01:31,560
then we can do an
incomplete recovery.
33
00:01:31,560 --> 00:01:33,750
So keep in mind that
an incomplete recovery
34
00:01:33,750 --> 00:01:37,050
is one of the most stressful
things that a DBA does.
35
00:01:37,050 --> 00:01:39,360
It's quite difficult and
there are steps involved.
36
00:01:39,360 --> 00:01:42,450
But what we're going to
do here is simulate it
37
00:01:42,450 --> 00:01:46,140
on a very small scale, sort
of a laboratory approach.
38
00:01:46,140 --> 00:01:48,960
But these are the steps
that we would go through.
39
00:01:48,960 --> 00:01:53,080
So in learning this, this is
a simple incomplete recovery.
40
00:01:53,080 --> 00:01:56,010
But it is completely
valid for our purposes.
41
00:01:56,010 --> 00:01:58,560
So we've got a little
bit of setup here.
42
00:01:58,560 --> 00:02:01,560
So I'm connected
to the Scott user.
43
00:02:01,560 --> 00:02:05,310
And Scott is going to create
a table for us to recover.
44
00:02:05,310 --> 00:02:08,560
So we've created a
table called help_me.
45
00:02:08,560 --> 00:02:12,520
Now we're going to insert a
value into it, You did it!
46
00:02:12,520 --> 00:02:14,590
Hopefully that's what we'll see.
47
00:02:14,590 --> 00:02:16,090
And then it's very
important that we
48
00:02:16,090 --> 00:02:22,360
do a commit so that that row
is committed to the database.
49
00:02:22,360 --> 00:02:25,040
What I want to do here is kind
of show the passage of time.
50
00:02:27,990 --> 00:02:28,490
All right.
51
00:02:28,490 --> 00:02:30,590
So we're going to simulate
some time passage here
52
00:02:30,590 --> 00:02:35,090
just by switching the archive
log a couple of times.
53
00:02:35,090 --> 00:02:35,690
All right.
54
00:02:35,690 --> 00:02:39,550
So those changes that we
made are now in the archive
55
00:02:39,550 --> 00:02:44,060
logs or switched from the
redo logs to the archive logs.
56
00:02:44,060 --> 00:02:46,910
And we want to get a hard date.
57
00:02:46,910 --> 00:02:51,400
So this is going to be the point
that we want to recover to.
58
00:02:51,400 --> 00:02:53,620
Hang onto that.
59
00:02:53,620 --> 00:02:58,180
Now we are ready
to drop our table.
60
00:02:58,180 --> 00:03:02,700
So if we were to select
star from help_me to list,
61
00:03:02,700 --> 00:03:04,700
that table is gone.
62
00:03:04,700 --> 00:03:06,840
And I'm going to go
back here and switch
63
00:03:06,840 --> 00:03:10,480
the log file one more time.
64
00:03:10,480 --> 00:03:10,980
OK.
65
00:03:10,980 --> 00:03:14,880
So at this point, we're told
we need to recover that table.
66
00:03:14,880 --> 00:03:17,280
So we need to get the
database into a state
67
00:03:17,280 --> 00:03:20,010
where it can do recoveries,
which is the mount state.
68
00:03:20,010 --> 00:03:22,780
So we're going to shut
down the database.
69
00:03:22,780 --> 00:03:26,130
Let me emphasize here that
the most important thing
70
00:03:26,130 --> 00:03:29,770
about this entire process is
that you have a good backup.
71
00:03:29,770 --> 00:03:31,560
If you attempt to do
this without a backup,
72
00:03:31,560 --> 00:03:34,680
you cannot do a recovery.
73
00:03:34,680 --> 00:03:35,640
startup mount.
74
00:03:38,520 --> 00:03:39,480
target time.
75
00:03:44,300 --> 00:03:46,210
So now we're going to
exit out of SQL*Plus.
76
00:03:46,210 --> 00:03:48,850
We could have done the shutdown
and start up in either SQL*Plus
77
00:03:48,850 --> 00:03:50,280
or RMAN.
78
00:03:50,280 --> 00:03:52,030
But we'll need to do
the recovery in RMAN,
79
00:03:52,030 --> 00:03:55,210
so we'll type in
RMAN connect target.
80
00:03:55,210 --> 00:03:57,280
And then we're going
to use an alter session
81
00:03:57,280 --> 00:04:01,270
command that's going to set
the time and date format.
82
00:04:01,270 --> 00:04:03,730
By default, the time
and date format actually
83
00:04:03,730 --> 00:04:05,290
only has the date.
84
00:04:05,290 --> 00:04:06,790
But we need to be more specific.
85
00:04:06,790 --> 00:04:09,550
We need to get the
entire date and the time.
86
00:04:09,550 --> 00:04:11,260
So we're going to have
to actually change
87
00:04:11,260 --> 00:04:14,200
the default format for
date and time information
88
00:04:14,200 --> 00:04:15,560
that RMAN uses.
89
00:04:15,560 --> 00:04:16,930
So we're going to
put that format
90
00:04:16,930 --> 00:04:18,700
in exactly the
same format that we
91
00:04:18,700 --> 00:04:22,480
have here and our target time.
92
00:04:22,480 --> 00:04:28,930
We say, alter session set
nls_date_format equal to--
93
00:04:28,930 --> 00:04:33,710
and inside of quotes we'll put
the same format, 2-digit day,
94
00:04:33,710 --> 00:04:39,800
3-digit month, 4-digit
year, 24-hour time, minutes,
95
00:04:39,800 --> 00:04:42,380
and seconds.
96
00:04:42,380 --> 00:04:45,870
So now when we address RMAN with
our time and date information,
97
00:04:45,870 --> 00:04:47,580
it will know what we mean.
98
00:04:47,580 --> 00:04:48,220
All right.
99
00:04:48,220 --> 00:04:50,200
So let's begin the recovery.
100
00:04:50,200 --> 00:04:52,090
We'll do this in a run block.
101
00:04:52,090 --> 00:04:55,120
And so what's going to
set this recovery apart
102
00:04:55,120 --> 00:04:58,030
from other recoveries
or a complete recovery
103
00:04:58,030 --> 00:05:01,560
is this command, set until time.
104
00:05:01,560 --> 00:05:08,620
And here, I'm going to
copy/paste the exact time
105
00:05:08,620 --> 00:05:12,670
that we want to recover
the database up to.
106
00:05:12,670 --> 00:05:15,530
We say restore database.
107
00:05:15,530 --> 00:05:18,290
It'll need to restore
the entire database.
108
00:05:18,290 --> 00:05:21,860
And then recover database up to
the point that we've specified
109
00:05:21,860 --> 00:05:23,120
here.
110
00:05:23,120 --> 00:05:25,820
Now, this is going to
replace all of the data files
111
00:05:25,820 --> 00:05:28,550
with data files from
the backup, and then
112
00:05:28,550 --> 00:05:32,720
roll those changes forward
up until this date and time.
113
00:05:32,720 --> 00:05:34,100
So this will take a little time.
114
00:05:44,040 --> 00:05:44,540
All right.
115
00:05:44,540 --> 00:05:47,870
So our restore and our
recovery have completed.
116
00:05:47,870 --> 00:05:51,020
So if we were to go back and
look at this a little bit,
117
00:05:51,020 --> 00:05:52,340
here's our command.
118
00:05:52,340 --> 00:05:54,920
Notice that the first
step is to restore.
119
00:05:54,920 --> 00:05:58,430
So it restores these data
files that it mentions here.
120
00:05:58,430 --> 00:06:01,790
And it reads them
from backup pieces.
121
00:06:01,790 --> 00:06:03,590
And then it starts
media recovery,
122
00:06:03,590 --> 00:06:05,330
and it has a list
of archive logs
123
00:06:05,330 --> 00:06:10,480
that it's going to draw from,
and then finishes the recovery.
124
00:06:10,480 --> 00:06:14,400
So now the database is in
a state that exact time
125
00:06:14,400 --> 00:06:16,330
that we specified.
126
00:06:16,330 --> 00:06:17,800
Now, are we finished?
127
00:06:17,800 --> 00:06:20,560
No, because we're still
in the mount state
128
00:06:20,560 --> 00:06:23,060
and we need to
open the database.
129
00:06:23,060 --> 00:06:25,810
However, we can't open
the database normally
130
00:06:25,810 --> 00:06:29,440
in this situation,
because all of the redo
131
00:06:29,440 --> 00:06:33,580
logs that we were using before
are now invalid, because we've
132
00:06:33,580 --> 00:06:35,650
recovered up to a
point in the past,
133
00:06:35,650 --> 00:06:39,310
and redo logs have the most
recent change information.
134
00:06:39,310 --> 00:06:41,830
So what we need to do
is open the database
135
00:06:41,830 --> 00:06:45,640
in a way that automatically
recreates the redo logs.
136
00:06:45,640 --> 00:06:50,340
And that is done, alter
database open reset logs.
137
00:06:50,340 --> 00:06:53,500
That's going to reset
the redo log files.
138
00:06:53,500 --> 00:06:55,480
Now, this is actually
rebuilding the redo logs,
139
00:06:55,480 --> 00:06:56,830
so this can take a little time.
140
00:07:00,170 --> 00:07:03,080
The database is
open for business.
141
00:07:03,080 --> 00:07:07,550
So let's exit out of
here, see how we did.
142
00:07:07,550 --> 00:07:10,500
Connect to Scott.
143
00:07:10,500 --> 00:07:14,770
select star from help_me.
144
00:07:14,770 --> 00:07:16,420
Now, if we did
everything correctly,
145
00:07:16,420 --> 00:07:19,340
we'll see the line
that we inserted.
146
00:07:19,340 --> 00:07:20,070
So we've done it.
147
00:07:20,070 --> 00:07:22,970
We've managed to do
an incomplete recovery
148
00:07:22,970 --> 00:07:27,140
to recover the database
to a point in the past.
11798
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.