首页 > 数据库 > Oracle > RMAN不停机搭建DG
前面pfile参数等配置 参考如下:
http://blog.itpub.net/29990276/viewspace-1683772/
点击( 此处 )折叠或打开
run{
allocate channel c1
type
disk
;
allocate channel c2
type
disk
;
sql
'alter system archive log current'
;
backup format
'/backup/db_%U_%T'
skip inaccessible filesperset 5 database
;
sql
'alter system archive log current'
;
backup format
'/backuparch/arch_%U_%T'
skip inaccessible filesperset 5 archivelog all delete input
;
backup current controlfile
for
standby format
=
'/backup/control_%U'
;
release channel c1
;
release channel c2
;
}
scp备份集到备库相应的目录
点击( 此处 )折叠或打开
[ oracle@primary backuparch ] $ scp * 192 . 168 . 6 . 31 : / backuparch/
oracle@192
.
168
.
6
.
31
's password:
arch_05q8hd9e_1_1_20150603 100% 61MB 15.2MB/s 00:04
arch_06q8hd9e_1_1_20150603 100% 9477KB 9.3MB/s 00:00
arch_07q8hd9f_1_1_20150603 100% 66MB 16.5MB/s 00:04
arch_08q8hd9g_1_1_20150603 100% 12MB 12.3MB/s 00:00
[oracle@primary backuparch]$ cd /backup
[
oracle@primary backup
]
$
ll
total 1154188
-
rw
-
r
-
-
-
-
-
1 oracle oinstall 9797632 Jun 3 02
:
15 control_09q8hd9i_1_1
-
rw
-
r
-
-
-
-
-
1 oracle oinstall 711983104 Jun 3 02
:
15 db_01q8hd8h_1_1_20150603
-
rw
-
r
-
-
-
-
-
1 oracle oinstall 449028096 Jun 3 02
:
15 db_02q8hd8h_1_1_20150603
-
rw
-
r
-
-
-
-
-
1 oracle oinstall 9797632 Jun 3 02
:
15 db_03q8hd9a_1_1_20150603
-
rw
-
r
-
-
-
-
-
1 oracle oinstall 98304 Jun 3 02
:
15 db_04q8hd9a_1_1_20150603
[
oracle@primary backup
]
$
scp
*
192
.
168
.
6
.
31
:
/
backup
oracle@192 . 168 . 6 . 31's password:
...
...
备库duplicate登陆
点击( 此处 )折叠或打开
[
oracle@standby ~
]
$
rman target sys/oracle@bj auxiliary sys/oracle@sh
Recovery Manager
:
Release 11
.
2
.
.
3
.
0
-
Production on Tue Jun 2 11
:
18
:
17 2015
Copyright
(
c
)
1982
,
2011
,
Oracle
and
/
or
its affiliates
.
All rights reserved
.
connected to target database
:
BEIJING
(
DBID
=
845781194
)
connected to auxiliary database : BEIJING ( not mounted )
点击( 此处 )折叠或打开
RMAN
>
duplicate target database
for
standby nofilenamecheck dorecover
;
Starting Duplicate Db at 02
-
JUN
-
15
using target database control file instead
of
recovery catalog
allocated channel
:
ORA_AUX_DISK_1
channel ORA_AUX_DISK_1
:
SID
=
19 device
type
=
DISK
contents
of
Memory Script
:
{
set until scn 1134882
;
restore clone standby controlfile
;
}
executing Memory Script
executing command
:
SET until clause
Starting restore at 02
-
JUN
-
15
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1
:
starting datafile backup set restore
channel ORA_AUX_DISK_1
:
restoring control file
channel ORA_AUX_DISK_1
:
reading from backup piece /backup/db_03q8hd9a_1_1_20150603
channel ORA_AUX_DISK_1
:
piece handle
=
/
backup/db_03q8hd9a_1_1_20150603 tag
=
TAG20150603T021440
channel ORA_AUX_DISK_1
:
restored backup piece 1
channel ORA_AUX_DISK_1
:
restore complete
,
elapsed time
:
00
:
00
:
02
output file
name
=
/
u01/app/oracle/oradata/shanghai/control01
.
ctl
output file
name
=
/
u01/app/oracle/fast_recovery_area/shanghai/control02
.
ctl
Finished restore at 02
-
JUN
-
15
contents
of
Memory Script
:
{
sql clone
'alter database mount standby database'
;
}
executing Memory Script
sql statement
:
alter database mount standby database
contents
of
Memory Script
:
{
set until scn 1134882
;
set newname
for
tempfile 1 to
"/u01/app/oracle/oradata/shanghai/temp01.dbf"
;
switch clone tempfile all
;
set newname
for
datafile 1 to
"/u01/app/oracle/oradata/shanghai/system01.dbf"
;
set newname
for
datafile 2 to
"/u01/app/oracle/oradata/shanghai/sysaux01.dbf"
;
set newname
for
datafile 3 to
"/u01/app/oracle/oradata/shanghai/undotbs01.dbf"
;
set newname
for
datafile 4 to
"/u01/app/oracle/oradata/shanghai/users01.dbf"
;
set newname
for
datafile 5 to
"/u01/app/oracle/oradata/shanghai/example01.dbf"
;
restore
clone database
;
}
executing Memory Script
executing command
:
SET until clause
executing command
:
SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/shanghai/temp01
.
dbf
in
control file
executing command
:
SET NEWNAME
executing command
:
SET NEWNAME
executing command
:
SET NEWNAME
executing command
:
SET NEWNAME
executing command
:
SET NEWNAME
Starting restore at 02
-
JUN
-
15
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1
:
starting datafile backup set restore
channel ORA_AUX_DISK_1
:
specifying datafile
(
s
)
to restore from backup set
channel ORA_AUX_DISK_1
:
restoring datafile 00001 to /u01/app/oracle/oradata/shanghai/system01
.
dbf
channel ORA_AUX_DISK_1
:
restoring datafile 00005 to /u01/app/oracle/oradata/shanghai/example01
.
dbf
channel ORA_AUX_DISK_1
:
reading from backup piece /backup/db_01q8hd8h_1_1_20150603
channel ORA_AUX_DISK_1
:
piece handle
=
/
backup/db_01q8hd8h_1_1_20150603 tag
=
TAG20150603T021440
channel ORA_AUX_DISK_1
:
restored backup piece 1
channel ORA_AUX_DISK_1
:
restore complete
,
elapsed time
:
00
:
00
:
15
channel ORA_AUX_DISK_1
:
starting datafile backup set restore
channel ORA_AUX_DISK_1
:
specifying datafile
(
s
)
to restore from backup set
channel ORA_AUX_DISK_1
:
restoring datafile 00002 to /u01/app/oracle/oradata/shanghai/sysaux01
.
dbf
channel ORA_AUX_DISK_1
:
restoring datafile 00003 to /u01/app/oracle/oradata/shanghai/undotbs01
.
dbf
channel ORA_AUX_DISK_1
:
restoring datafile 00004 to /u01/app/oracle/oradata/shanghai/users01
.
dbf
channel ORA_AUX_DISK_1
:
reading from backup piece /backup/db_02q8hd8h_1_1_20150603
channel ORA_AUX_DISK_1
:
piece handle
=
/
backup/db_02q8hd8h_1_1_20150603 tag
=
TAG20150603T021440
channel ORA_AUX_DISK_1
:
restored backup piece 1
channel ORA_AUX_DISK_1
:
restore complete
,
elapsed time
:
00
:
00
:
15
Finished restore at 02
-
JUN
-
15
contents
of
Memory Script
:
{
switch clone datafile all
;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID
=
4 STAMP
=
881320957 file
name
=
/
u01/app/oracle/oradata/shanghai/system01
.
dbf
datafile 2 switched to datafile copy
input datafile copy RECID
=
5 STAMP
=
881320957 file
name
=
/
u01/app/oracle/oradata/shanghai/sysaux01
.
dbf
datafile 3 switched to datafile copy
input datafile copy RECID
=
6 STAMP
=
881320957 file
name
=
/
u01/app/oracle/oradata/shanghai/undotbs01
.
dbf
datafile 4 switched to datafile copy
input datafile copy RECID
=
7 STAMP
=
881320957 file
name
=
/
u01/app/oracle/oradata/shanghai/users01
.
dbf
datafile 5 switched to datafile copy
input datafile copy RECID
=
8 STAMP
=
881320957 file
name
=
/
u01/app/oracle/oradata/shanghai/example01
.
dbf
contents
of
Memory Script
:
{
set until scn 1134882
;
recover
standby
clone database
delete archivelog
;
}
executing Memory Script
executing command
:
SET until clause
Starting recover at 02
-
JUN
-
15
using channel ORA_AUX_DISK_1
starting media recovery
channel ORA_AUX_DISK_1
:
starting archived log restore to default destination
channel ORA_AUX_DISK_1
:
restoring archived log
archived log thread
=
1 sequence
=
14
channel ORA_AUX_DISK_1
:
restoring archived log
archived log thread
=
1 sequence
=
15
channel ORA_AUX_DISK_1
:
reading from backup piece /backuparch/arch_08q8hd9g_1_1_20150603
channel ORA_AUX_DISK_1
:
piece handle
=
/
backuparch/arch_08q8hd9g_1_1_20150603 tag
=
TAG20150603T021509
channel ORA_AUX_DISK_1
:
restored backup piece 1
channel ORA_AUX_DISK_1
:
restore complete
,
elapsed time
:
00
:
00
:
01
archived log file
name
=
/
arch/1_14_881314188
.
dbf thread
=
1 sequence
=
14
channel clone_default
:
deleting archived log
(
s
)
archived log file
name
=
/
arch/1_14_881314188
.
dbf RECID
=
1 STAMP
=
881320959
archived log file
name
=
/
arch/1_15_881314188
.
dbf thread
=
1 sequence
=
15
channel clone_default
:
deleting archived log
(
s
)
archived log file
name
=
/
arch/1_15_881314188
.
dbf RECID
=
2 STAMP
=
881320959
media recovery complete
,
elapsed time
:
00
:
00
:
00
Finished recover at 02
-
JUN
-
15
Finished Duplicate Db at 02 - JUN - 15
中间有
alter database mount standby database;过程,一条命令搞定所有,但是不会做路径的转换,这时我们在pfile添加covert。
执行之后,数据库是mount状态,这时候我们就可以打开备库了。
点击( 此处 )折叠或打开
SQL
>
alter database open
;
Database altered
.
SQL
>
select open_mode from v$database
;
OPEN_MODE
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
READ ONLY
添加standby redo log和online redo log
应用
点击( 此处 )折叠或打开
SQL
>
alter database recover managed standby database disconnect from session
;
Database altered .
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29990276/viewspace-1684408/ ,如需转载,请注明出处,否则将追究法律责任。