ITPub博客

首页 > 数据库 > Oracle > 一次利用rman备份作的数据库复制实验

一次利用rman备份作的数据库复制实验

原创 Oracle 作者:lzcbj2002 时间:2007-05-17 12:40:30 0 删除 编辑
rman,复制[@more@]

一次数据库复制试验

环境sun v490,solaris 9,oracle 9201

数据库的备份
1、定时
0 4 * * * /space/oracle_backup/db_backup.sh >> /space/oracle_backup/backup.log 2>&1
2、shell脚本内容#!/bin/sh
. /oracle/.bash_profile
echo "Beginning time:" `date +'%Y-%m-%d %H:%M'`
env
/oracle/OraHome/bin/rman @/space/oracle_backup/backup.rman
echo "End time:" `date +'%Y-%m-%d %H:%M'
3、rman备份脚本内容connect target /
connect catalog rman/password@db_rman2;
list backup;
report obsolete;
delete obsolete;
backup filesperset 50 database tag oooooooooo include current controlfile format '/oracle/oradata/backup/n%d.dbf.%T';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup filesperset 50 format '/oracle/oradata/backup/log_t%t_s%s_p%p' archivelog all delete input;
quit


数据库复制
1、准备阶段
在另外一台机器上面,创建SID与原数据库一致的数据库,字符集一致,目录结构一致(记得分区一定要有足够的空间),归档模式一致。然后注册到同一个catalog中
。
然后以nomount模式启动该数据库SQL> startup nomount;
ORACLE instance started.

Total System Global Area 1410828920 bytes
Fixed Size 731768 bytes
Variable Size 570425344 bytes
Database Buffers 838860800 bytes
Redo Buffers 811008 bytes
将rman备份从源数据库所在机器拷贝至目的服务器,目录结构要求一致
另外需要拷贝$ORACLE_HOME/dbs目录下的另外2个文件。
一个是密码文件,orapw$SID
另外一个我的实验里是
c-3999769622-20070516-02,其中3999769622是源数据库的DBID,看来以后做备份的时候需要把这个作一下备份,不然恢复的时候会出错啦!
出错的提示类似下面的输出
RMAN> restore controlfile;

Starting restore at 17-MAY-07

allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=13 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: restoring controlfile
output filename=/oracle/oracle9i/oradata/colorok/control01.ctl
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/17/2007 10:13:19
ORA-19505: failed to identify file "/oracle/OraHome/dbs/c-3999769622-20070516-02"
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
拷贝该文件过来后的输出类似
RMAN> restore controlfile;

Starting restore at 17-MAY-07

using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: restoring controlfile
output filename=/oracle/oracle9i/oradata/colorok/control01.ctl
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/OraHome/dbs/c-3999769622-20070516-02 tag=null params=NULL
channel ORA_DISK_1: restore complete
replicating controlfile
input filename=/oracle/oracle9i/oradata/colorok/control01.ctl
output filename=/oracle/oracle9i/oradata/colorok/control02.ctl
output filename=/oracle/oracle9i/oradata/colorok/control03.ctl
Finished restore at 17-MAY-07


2、复制阶段
connect target /;
connect catalog
rman/password@rman
set dbid=3999769622 这个dbid可以查看备份日志获得
restore controlfile;
run
{
allocate channel c1 type disk;
restore database;
release channel c1;
}
alter database mount;
run
{
allocate channel c1 type disk;
restore archivelog all;
release channel c1;
}
recover database;
recover database;
alter database open resetlogs;
完毕,下面是我的实验的输出!

RMAN> connect target /;

connected to target database: colorok (not mounted)

RMAN> connect catalog rman/pawssword@rman

connected to recovery catalog database

RMAN> set dbid=3999769622

executing command: SET DBID

RMAN> restore controlfile;

Starting restore at 17-MAY-07

allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=11 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: restoring controlfile
output filename=/oracle/oracle9i/oradata/colorok/control01.ctl
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/OraHome/dbs/c-3999769622-20070516-02 tag=null params=NULL
channel ORA_DISK_1: restore complete
replicating controlfile
input filename=/oracle/oracle9i/oradata/colorok/control01.ctl
output filename=/oracle/oracle9i/oradata/colorok/control02.ctl
output filename=/oracle/oracle9i/oradata/colorok/control03.ctl
Finished restore at 17-MAY-07

RMAN> run
2> {
3> allocate channel c1 type disk;
4> restore database;
5> release channel c1;
6> }

released channel: ORA_DISK_1
allocated channel: c1
channel c1: sid=11 devtype=DISK

Starting restore at 17-MAY-07

channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oracle/oracle9i/oradata/colorok/system01.dbf
.......(省略)

to /oracle/oracle9i/oradata/colorok/undotbs2_03.dbf
channel c1: restored backup piece 1
piece handle=/oracle/oradata/backup/nCOLOROK.dbf.20070516 tag=COLOROK params=NULL
channel c1: restore complete
Finished restore at 17-MAY-07

released channel: c1

RMAN> alter database mount;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 05/17/2007 11:24:53
ORA-01991: invalid password file '/oracle/OraHome/dbs/orapwcolorok'

(这里可以看出密码文件的作用了)

RMAN> alter database mount;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 05/17/2007 11:25:36
ORA-01100: database already mounted

RMAN> run
2> {
allocate channel c1 type disk;
restore archivelog all;
3> 4> 5> release channel c1;
}6>

allocated channel: c1
channel c1: sid=11 devtype=DISK

Starting restore at 17-MAY-07

channel c1: starting archive log restore to default destination
channel c1: restoring archive log
archive log thread=1 sequence=5717
......(省略)

archive log thread=1 sequence=5731
channel c1: restoring archive log
archive log thread=1 sequence=5732
channel c1: restoring archive log
archive log thread=1 sequence=5733
released channel: c1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/17/2007 11:26:16
ORA-19505: failed to identify file "/oracle/oradata/backup/log_t622095333_s1515_p1"
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3


RMAN> recover database;

Starting recover at 17-MAY-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=11 devtype=DISK

starting media recovery

channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=5862
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=5863
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=5864
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/oradata/backup/log_t622749440_s1525_p1 tag=TAG20070516T175720 params=NULL
channel ORA_DISK_1: restore complete
archive log filename=/oracle/oracle9i/oradata/colorok/archive/1_5862.dbf thread=1 sequence=5862
archive log filename=/oracle/oracle9i/oradata/colorok/archive/1_5863.dbf thread=1 sequence=5863
archive log filename=/oracle/oracle9i/oradata/colorok/archive/1_5864.dbf thread=1 sequence=5864
unable to find archive log
archive log thread=1 sequence=5865
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 05/17/2007 11:42:09
RMAN-06054: media recovery requesting unknown log: thread 1 scn 1986123297

RMAN> recover database;

Starting recover at 17-MAY-07
using channel ORA_DISK_1

starting media recovery

unable to find archive log
archive log thread=1 sequence=5865
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 05/17/2007 11:48:29
RMAN-06054: media recovery requesting unknown log: thread 1 scn 1986123297

RMAN> alter database open resetlogs;

database opened
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

RMAN> exit

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/137423/viewspace-915329/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论
  • 博文量
    5
  • 访问量
    21583