2,利用scp拷贝到异机
[oracle@db101 ab]$ ls
liu0stl8tun_1_1 liu0ttl8u58_1_1
[oracle@db101 ab]$ scp *
oracle@192.168.3.3:/home/oracle/ab/
oracle@192.168.3.3's password:
liu0stl8tun_1_1 100%
2144MB 12.1MB/s 02:57
liu0ttl8u58_1_1 100%
7264KB 7.1MB/s 00:
3,异机关库并设置为主库的数据库id即dbid
rman>set dbid 85555655666(主库的id号)
4,需要拷贝主库的参数文件到异机库
[oracle@db101 dbs]$ scp initecom.ora
oracle@192.168.3.3:/oracle/app/oracle/product/10.2.0/db_1/dbs/
oracle@192.168.3.3's password:
initecom.ora 100% 960 0.9KB/s 00:00
5,异机库启动到nomount状态
rman>startup nomunt
6,利用主库的备份文件恢复控制文件
RMAN> restore controlfile from
'/home/oracle/ab/liu0ttl8u58_1_1';
Starting restore at 20-DEC-18
using target database control file instead of recovery
catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time:
00:00:04
output filename=/oracle/app/oradata/ecom/control01.ctl
output filename=/oracle/app/oradata/ecom/control02.ctl
output filename=/oracle/app/oradata/ecom/control03.ctl
Finished restore at 20-DEC-18
RMAN> restore
database;
Starting restore at 20-DEC-18
using channel ORA_DISK_1
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
===========================================================
RMAN-03002: failure of restore command at 12/20/2018
21:10:47
ORA-01507: database not
mounted
说明restore命令需要在mount之后次可以执行
7,数据库启动到mount状态
RMAN> startup mount
database is already started
database mounted
released channel: ORA_DISK_1
8,修复数据
RMAN> restore database;
Starting restore at 20-DEC-18
Starting implicit crosscheck backup at 20-DEC-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 22 objects
Finished implicit crosscheck backup at 20-DEC-18
Starting implicit crosscheck copy at 20-DEC-18
using channel ORA_DISK_1
Finished implicit crosscheck copy at 20-DEC-18
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from
backup set
restoring datafile 00001 to
/oracle/app/oradata/ecom/system01.dbf
restoring datafile 00002 to
/oracle/app/oradata/ecom/undotbs01.dbf
restoring datafile 00003 to
/oracle/app/oradata/ecom/sysaux01.dbf
restoring datafile 00004 to
/oracle/app/oradata/ecom/users01.dbf
restoring datafile 00005 to
/oracle/app/oradata/ecom/dd01.dbf
restoring datafile 00006 to
/oracle/app/oradata/ecom/liu.dbf
channel ORA_DISK_1: reading from backup piece
/home/oracle/ab/liu0stl8tun_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/ab/liu0stl8tun_1_1
tag=TAG20181220T173727
channel ORA_DISK_1: restore complete, elapsed time:
00:04:11
Finished restore at 20-DEC-18
9,恢复数据库
RMAN> recover database;
Starting recover at 20-DEC-18
using channel ORA_DISK_1
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
===========================================================
RMAN-03002: failure of recover command at 12/20/2018
21:18:00
ORA-19698:
/oracle/app/oradata/ecom/redo01.log is from different database:
id=3675719757, db_name=ECOM
说明数据库的dbid不一样,无法恢复,需要提前设置,倘若忘记设置,以下可以关库在重新设置
RMAN> set dbid 3676077492
executing command: SET DBID
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
===========================================================
RMAN-03002: failure of CSET command at 12/20/2018
21:19:53
RMAN-06188: cannot use command when connected to a mounted
target database
RMAN> shutdown immediate
database dismounted
Oracle instance shut down
RMAN> set dbid 3676077492
executing command: SET DBID
RMAN> startup mount
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area 285212672 bytes
Fixed Size 1218992
bytes
Variable Size 75499088 bytes
Database Buffers 205520896 bytes
Redo Buffers 2973696 bytes
RMAN> recover database;
Starting recover at 20-DEC-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
===========================================================
RMAN-03002: failure of recover command at 12/20/2018
21:21:31
ORA-19698: /oracle/app/oradata/ecom/redo01.log is from
different database: id=3675719757, db_name=ECOM
说明数据库的日志不一致,需要拷贝主库的当前日志过来(我这里是rman全备份后,没有归档可以只拷贝当前日志,倘若你有过归档需要你把归档和当前日志组一起拷贝过来)
----还是出现这个错误,从错误里可以看到两个错误点一是日志不同,而是数据库dbid不同,需要把这两处都修改一致才可以recover
10,copy主库的日志(或归档+当前)到异机库
scp *.log
oracle@192.168.3.3:/oracle/app/oradata/ecom/
11,恢复数据库
RMAN> recover database;
Starting recover at 20-DEC-18
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 46 is already on disk as file
/oracle/app/oradata/ecom/redo03.log
archive log filename=/oracle/app/oradata/ecom/redo03.log
thread=1 sequence=46
media recovery complete, elapsed time: 00:00:03
Finished recover at 20-DEC-18
12,修改数据库以resetlogs方式开启数据库
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for
database open
SQL> alter database open noresetlogs;
alter database open noresetlogs
*
ERROR at line 1:
ORA-01588: must use RESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.----成功开启数据库