Chinaunix首页 | 论坛 | 博客
  • 博客访问: 237998
  • 博文数量: 59
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 592
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-01 12:51
个人简介

你们都是我的客户,所以,我对你们是透明的

文章分类

全部博文(59)

文章存档

2016年(29)

2015年(30)

分类: Oracle

2016-03-16 16:06:04

生产备份
run{
allocate channel ch1 type disk;
sql 'alter system archive log current';
backup as compressed backupset database format '/oracle/backups/hisdb_%T_%U';
sql 'alter system archive log current';
backup as compressed backupset archivelog all format '/oracle/backups/hisarc_%T_%U';
backup current controlfile format '/oracle/backups/hiscon_%T_%U';
release channel ch1;
}

备端创建文件夹,把备份片拷贝过去
[oracle@ha ~]$ mkdir -p $ORACLE_BASE/admin/his/{b,c,u}dump
[oracle@ha ~]$ mkdir -p $ORACLE_BASE/admin/his/pfile
[oracle@ha ~]$ mkdir -p $ORACLE_BASE/oradata/his
创建密码文件
[oracle@ha ~]$ orapwd file=$ORACLE_HOME/dbs/orapwhis password=oracle entries=10

1、恢复spfile
RMAN> startup nomount
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/oracle/app/product/11.2.0/dbhome_1/dbs/inithis.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area    1068937216 bytes
Fixed Size                     2260088 bytes
Variable Size                281019272 bytes
Database Buffers             780140544 bytes
Redo Buffers                   5517312 bytes
RMAN>

RMAN> restore spfile from '/oracle/backups/testdb_20160316_0fr0ko30_1_1';
Starting restore at 16-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /oracle/backups/testdb_20160316_0fr0ko30_1_1
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 16-MAR-16
RMAN>

2、恢复控制文件
RMAN> shutdown immediate
using target database control file instead of recovery catalog
Oracle instance shut down

RMAN> startup nomount
connected to target database (not started)
Oracle instance started
Total System Global Area     363266048 bytes
Fixed Size                     2253304 bytes
Variable Size                171970056 bytes
Database Buffers             184549376 bytes
Redo Buffers                   4493312 bytes
RMAN>

RMAN> restore controlfile from '/oracle/backups/testcon_20160316_0hr0ko38_1_1';
Starting restore at 16-MAR-16
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/oracle/oradata/orcl/control01.ctl
output file name=/oracle/oradata/orcl/control02.ctl
output file name=/oracle/oradata/orcl/control03.ctl
Finished restore at 16-MAR-16
RMAN>


3、还原恢复
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> run {
2> restore database;
3> recover database;
4> }
Starting restore at 16-MAR-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
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 /oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /oracle/backups/testdb_20160316_0er0ko0l_1_1
channel ORA_DISK_1: piece handle=/oracle/backups/testdb_20160316_0er0ko0l_1_1 tag=TAG20160316T150701
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:15
Finished restore at 16-MAR-16
Starting recover at 16-MAR-16
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=131
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=132
channel ORA_DISK_1: reading from backup piece /oracle/backups/testarc_20160316_0gr0ko35_1_1
channel ORA_DISK_1: piece handle=/oracle/backups/testarc_20160316_0gr0ko35_1_1 tag=TAG20160316T150820
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/oracle/app/product/11.2.0/dbhome_1/dbs/arch1_131_904597832.dbf thread=1 sequence=131
archived log file name=/oracle/app/product/11.2.0/dbhome_1/dbs/arch1_132_904597832.dbf thread=1 sequence=132
unable to find archived log
archived log thread=1 sequence=133
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 03/16/2016 15:48:21
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 133 and starting SCN of 2532515
RMAN>


4、
RMAN> run{   
2> set until sequence=133;
3> restore database;
4> recover database;
5> }
executing command: SET until clause
Starting restore at 16-MAR-16
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 /oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /oracle/backups/testdb_20160316_0er0ko0l_1_1
channel ORA_DISK_1: piece handle=/oracle/backups/testdb_20160316_0er0ko0l_1_1 tag=TAG20160316T150701
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:16
Finished restore at 16-MAR-16
Starting recover at 16-MAR-16
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 131 is already on disk as file /oracle/app/product/11.2.0/dbhome_1/dbs/arch1_131_904597832.dbf
archived log for thread 1 with sequence 132 is already on disk as file /oracle/app/product/11.2.0/dbhome_1/dbs/arch1_132_904597832.dbf
archived log file name=/oracle/app/product/11.2.0/dbhome_1/dbs/arch1_131_904597832.dbf thread=1 sequence=131
archived log file name=/oracle/app/product/11.2.0/dbhome_1/dbs/arch1_132_904597832.dbf thread=1 sequence=132
media recovery complete, elapsed time: 00:00:01
Finished recover at 16-MAR-16
RMAN>

[oracle@ha oracle]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Mar 16 15:54:31 2016
Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
MOUNTED
SQL>

如果要打开,resetlogs模式打开
SQL> alter database open resetlogs;
Database altered.

SQL> select count(*) from test;
  COUNT(*)
----------
     82327

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /oracle/app/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence     1
Next log sequence to archive   1
Current log sequence           1
SQL>
阅读(1659) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~