一、源服务器备份数据库
1,查看数据库的实例名和DBID
connected to target database: DB3 (DBID=2060124769, not open)
2,进行全备份
backup AS COMPRESSED BACKUPSET database
include current controlfile format '/orabak/db_%d_%T_%s'
plus archivelog format '/orabak/arch_%d_%T_%s' ;
二、将备份复制到异地
[root@linux u01]# cd bak
[root@linux bak]# ll
total 1141356
-rw-r--r--. 1 root root 1158914048 Jun 13 23:44 db_full_03s6nrh9_1_1.bkp
-rw-r--r--. 1 root root 9830400 Jun 13 23:44 db_full_04s6nrjl_1_1.bkp
[root@linux bak]# cd ..
[root@linux u01]#
[root@linux u01]#
[root@linux u01]#
[root@linux u01]# chown -R oracle:ioinstall /u01
[root@linux u01]# ll
total 12
drwxr-xr-x. 2 oracle oinstall 4096 Jun 13 23:55 bak
drwxr-xr-x. 8 oracle oinstall 4096 Aug 20 2009 database
drwxr-xr-x. 3 oracle oinstall 4096 Jun 12 05:01 oracle
三、创建spfile文件>恢复控制文件>启动到mount>恢复数据库>打开数据库
[oracle@linux ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jun 13 23:56:29 2017
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> set dbid=358286784;
executing command: SET DBID
RMAN> EXIT
Recovery Manager complete.
[oracle@linux ~]$ sqsqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 14 00:04:21 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> cretae spfile from pfile='/u01/bak/xxx.ora';
File created.
SQL> startup nomount;
ORA-16032: parameter LOG_ARCHIVE_DEST destination string cannot be translated
ORA-07286: sksagdi: cannot obtain device information.
Linux-x86_64 Error: 2: No such file or directory
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 417546240 bytes
Fixed Size 2213936 bytes
Variable Size 343934928 bytes
Database Buffers 62914560 bytes
Redo Buffers 8482816 bytes
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@linux ~]$ cd /u01
[oracle@linux u01]$ ll
total 16
drwxr-xr-x. 2 oracle oinstall 4096 Jun 14 00:06 arch
drwxr-xr-x. 2 oracle oinstall 4096 Jun 14 00:03 bak
drwxr-xr-x. 8 oracle oinstall 4096 Aug 20 2009 database
drwxr-xr-x. 3 oracle oinstall 4096 Jun 12 05:01 oracle
[oracle@linux u01]$ cd bak
[oracle@linux bak]$ ll
total 1141360
-rw-r--r--. 1 oracle oinstall 1158914048 Jun 13 23:44 db_full_03s6nrh9_1_1.bkp
-rw-r--r--. 1 oracle oinstall 9830400 Jun 13 23:44 db_full_04s6nrjl_1_1.bkp
-rw-r--r--. 1 oracle oinstall 950 Jun 14 00:01 xxx.ora
[root@linux u01]# su - oracle
[oracle@linux ~]$ rman tagetrget /
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Jun 14 00:06:43 2017
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD (not mounted)
RMAN> restore controlfile from '/u01/bak/db_full_04s6nrjl_1_1.bkp';
Starting restore at 14-JUN-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=125 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/oracle/app/oracle/oradata/prod/control01.ctl
output file name=/u01/oracle/app/oracle/flash_recovery_area/prod/control02.ctl
Finished restore at 14-JUN-17
RMAN> alter database open;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 06/14/2017 00:10:34
ORA-01507: database not mounted
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> restore database from '/u01/bak/db_full_03s6nrh9_1_1.bkp';
Starting restore at 14-JUN-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=125 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/14/2017 00:11:49
RMAN-06509: only SPFILE or control file can be restored from AUTOBACKUP
RMAN> restore databsae ;
Starting restore at 14-JUN-17
using channel ORA_DISK_1
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 /u01/oracle/app/oracle/oradata/prod/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/oracle/app/oracle/oradata/prod/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/oracle/app/oracle/oradata/prod/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oracle/app/oracle/oradata/prod/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/oracle/app/oracle/oradata/prod/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/bak/db_full_03s6nrh9_1_1.bkp
channel ORA_DISK_1: piece handle=/u01/bak/db_full_03s6nrh9_1_1.bkp tag=TAG20170613T234337
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 14-JUN-17
[root@linux ~]# su - oracle
[oracle@linux ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 14 00:57:08 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 417546240 bytes
Fixed Size 2213936 bytes
Variable Size 343934928 bytes
Database Buffers 62914560 bytes
Redo Buffers 8482816 bytes
Database mounted.
[oracle@linux ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Jun 14 00:57:49 2017
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD (DBID=358286784, not open)
RMAN> recover database;
--因为没有备份归档日志,所以这里不用执行recover
Starting recover at 14-JUN-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK
starting media recovery
archived log for thread 1 with sequence 5 is already on disk as file /u01/oracle/app/oracle/oradata/prod/redo02.log
unable to find archived log
archived log thread=1 sequence=27
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/14/2017 00:58:12
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 27 and starting SCN of 1082331
RMAN> alter database open resetlogs;
database opened
RMAN> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@linux ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 14 00:59:18 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>