一、数据库全备

RUN {
ALLOCATE CHANNEL ch00 DEVICE TYPE disk;
ALLOCATE CHANNEL ch01 DEVICE TYPE disk;
backup as compressed backupset database filesperset 5 format '/apps/oracle_backup_20141209/bk_%d_%T%s_%p' ;
backup current controlfile format '/apps/oracle_backup_20141209/ctl_%d_%T_%s';
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
}

数据库备份采用压缩备份,压缩比大概为8:1,250多G的数据库备份出来30G。

二、数据库恢复
2.1.准备工作
拷贝备份文件到目标服务器:scp oracle_backup_20141209/ 10.230.35.177:/apps/(注:生产环境备份目录和测试环境备份目录最好一致,这样省许多不必要的麻烦)

2.2.创建相关目录
mkdir -p /app/oracle/admin/orcl/adump
mkdir -p /app/oracle/admin/orcl/bdump
mkdir -p /app/oracle/admin/orcl/cdump
mkdir -p /app/oracle/admin/orcl/udump
mkdir -p /app/oracle/admin/orcl/pfile
mkdir -p /app/oracle/controlfile
mkdir -p /app/oracle/arch
mkdir -p /app/oracle/oradata/orcl
mkdir -p /app/oracle/tempfile
2.3.准备参数文件
使用oracle用户
vi initorcl.ora

*.audit_file_dest='/app/oracle/admin/orcl/adump'
*.background_dump_dest='/app/oracle/admin/orcl/bdump'
*.cluster_database=false
*.compatible='10.2.0.5.0'
*.control_files='/app/oracle/controlfile/orcl_control1','/app/oracle/controlfile/orcl_control2','/app/oracle/controlfile/orcl_control3'
*.core_dump_dest='/app/oracle/admin/orcl/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl'
*.job_queue_processes=10
*.log_archive_dest_1='location=/app/oracle/arch'
*.open_cursors=300
*.pga_aggregate_target=263997286
*.processes=1000
*.remote_login_passwordfile='exclusive'
*.sessions=1105
*.sga_max_size=1244245094
*.sga_target=1244245094
*.undo_management='AUTO'
*.undo_retention=0
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/app/oracle/admin/orcl/udump'

2.4.启动实例

$ export ORACLE_SID=orcl
sqlplus / as sysdba
startup nomount pfile='/app/oracle/initorcl.ora'

2.5.恢复控制文件

rman target /

set dbid=1340406187

restore controlfile from '/apps/oracle_backup_20141209/ctl_ORCL_20141209_5109';

2.6.恢复数据库

alter database mount;

run {
ALLOCATE CHANNEL ch00 DEVICE TYPE disk;
ALLOCATE CHANNEL ch01 DEVICE TYPE disk;
ALLOCATE CHANNEL ch02 DEVICE TYPE disk;
ALLOCATE CHANNEL ch03 DEVICE TYPE disk;

set newname for datafile '+ORCLDATA/orcl/datafile/system.256.812625405' to '/app/oracle/oradata/orcl/system.256.812625405'
set newname for datafile '+ORCLDATA/orcl/datafile/undotbs1.258.812625405' to '/app/oracle/oradata/orcl/undotbs1.258.812625405'
set newname for datafile '+ORCLDATA/orcl/datafile/sysaux.257.812625405' to '/app/oracle/oradata/orcl/sysaux.257.812625405'
set newname for datafile '+ORCLDATA/orcl/datafile/users.259.812625405' to '/app/oracle/oradata/orcl/users.259.812625405'
set newname for datafile '+ORCLDATA/orcl/datafile/undotbs2.264.812625489' to '/app/oracle/oradata/orcl/undotbs2.264.812625489'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_data_01.dbf' to '/app/oracle/oradata/orcl/haecm_data_01.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_index_01.dbf' to '/app/oracle/oradata/orcl/haecm_index_01.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/dms_data_01.dbf' to '/app/oracle/oradata/orcl/dms_data_01.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/dms_index_01.dbf' to '/app/oracle/oradata/orcl/dms_index_01.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_data_02.dbf' to '/app/oracle/oradata/orcl/haecm_data_02.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_index_02.dbf' to '/app/oracle/oradata/orcl/haecm_index_02.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_data_03.dbf' to '/app/oracle/oradata/orcl/haecm_data_03.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_index_03.dbf' to '/app/oracle/oradata/orcl/haecm_index_03.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/system_01.dbf' to '/app/oracle/oradata/orcl/system_01.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/dms_data_02.dbf' to '/app/oracle/oradata/orcl/dms_data_02.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_data_04.dbf' to '/app/oracle/oradata/orcl/haecm_data_04.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/sysaux_02.dbf' to '/app/oracle/oradata/orcl/sysaux_02.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/dms_index_02.dbf' to '/app/oracle/oradata/orcl/dms_index_02.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_data_05.dbf' to '/app/oracle/oradata/orcl/haecm_data_05.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_index_04.dbf' to '/app/oracle/oradata/orcl/haecm_index_04.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_data_06.dbf' to '/app/oracle/oradata/orcl/haecm_data_06.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_index_05.dbf' to '/app/oracle/oradata/orcl/haecm_index_05.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/dms_data_03.dbf' to '/app/oracle/oradata/orcl/dms_data_03.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_data_07.dbf' to '/app/oracle/oradata/orcl/haecm_data_07.dbf'
set newname for datafile '+ORCLDATA/orcl/datafile/haecm_index_06.dbf' to '/app/oracle/oradata/orcl/haecm_index_06.dbf'
restore database;
switch datafile all;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;
}

recover database;
会报RMAN-06025: no backup of log thread 1 seq 23672 lowscn 1173065498 found to restore

恢复多个归档日志
run {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' connect 'sys/xxxx@orcl1';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE' connect 'sys/xxxx@orcl2';
SET ARCHIVELOG DESTINATION TO '/rac_arch1';
RESTORE ARCHIVELOG SEQUENCE between 5550 and 5564 thread 2;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
}

恢复单个归档日志23672

run {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' connect 'sys/xxxx@orcl1';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE' connect 'sys/xxxx@orcl2';
SET ARCHIVELOG DESTINATION TO '/rac_arch1';
RESTORE ARCHIVELOG SEQUENCE 21519 thread 1;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
}

补充:删除归档尽量不用操作系统命令rm(若用rm需要在rman中执行crosscheck archivelog all;)要用delete noprompt archivelog 归档的路径和名字
delete noprompt archivelog '/rac_arch2/2_21519_812625454.dbf';
delete noprompt archivelog '/rac_arch2/2_21525_812625454.dbf';

把归档放在pfile文件指定的归档路径中,然后rman下注册归档:catalog start with '/oracle/arch';

执行recover database;

归档都有后再执行recover database;

RENAME REDO
alter database rename file '+ORCLDATA/orcl/onlinelog/group_11.log' to '/app/oracle/oradata/orcl/redo1.log';
alter database rename file '+ORCLDATA/orcl/onlinelog/group_12.log' to '/app/oracle/oradata/orcl/redo2.log';
alter database rename file '+ORCLDATA/orcl/onlinelog/group_21.log' to '/app/oracle/oradata/orcl/redo3.log';
alter database rename file '+ORCLDATA/orcl/onlinelog/group_31.log' to '/app/oracle/oradata/orcl/redo4.log';
alter database rename file '+ORCLDATA/orcl/onlinelog/group_41.log' to '/app/oracle/oradata/orcl/redo5.log';
alter database rename file '+ORCLDATA/orcl/onlinelog/group_51.log' to '/app/oracle/oradata/orcl/redo6.log';
alter database rename file '+ORCLDATA/orcl/onlinelog/group_52.log' to '/app/oracle/oradata/orcl/redo7.log';
alter database rename file '+ORCLDATA/orcl/onlinelog/group_61.log' to '/app/oracle/oradata/orcl/redo8.log';
alter database rename file '+ORCLDATA/orcl/onlinelog/group_22.log' to '/app/oracle/oradata/orcl/redo9.log';
alter database rename file '+ORCLDATA/orcl/onlinelog/group_32.log' to '/app/oracle/oradata/orcl/redo10.log';
alter database rename file '+ORCLDATA/orcl/onlinelog/group_42.log' to '/app/oracle/oradata/orcl/redo11.log';
alter database rename file '+ORCLDATA/orcl/onlinelog/group_62.log' to '/app/oracle/oradata/orcl/redo12.log';
2.7.打开数据库
SQL> alter database open resetlogs;

若不执行alter database rename file '+ORCLDATA/orcl/onlinelog/group_42.log' to '/app/oracle/oradata/orcl/redo11.log'; 这些语句
会报错如下:
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00349: failure obtaining block size for
'+ORCLDATA/orcl/onlinelog/group_42.log'
2.8.数据库整理

SQL> set linesize 200 pagesize 200
SQL> select GROUP#,THREAD#,STATUS ,ARCHIVED from v$log;
SQL> alter database disable thread 2 ;
SQL> alter system archive log current;
SQL> select GROUP#,THREAD#,STATUS ,ARCHIVED from v$log;
SQL> alter database drop logfile group 3; --根据实际情况调整
SQL> select GROUP#,THREAD#,STATUS ,ARCHIVED from v$log;

alter database rename file '+ORCLDATA/orcl/tempfile/temp.263.812625459' to '/app/oracle/tempfile/temp1.dbf';

删除thread 2 的日志组如:alter database drop logfile group 2;

创建监听 、tnsnames.ora

rman异机恢复(RAC双节点恢复到单节点)的更多相关文章

  1. Oracle 单实例 迁移到 RAC 实例 -- 使用RMAN 异机恢复

    Oracle 官网有关单实例迁移到RAC的一个步骤说明: How to Convert 10g Single-Instance database to 10g RAC using Manual Con ...

  2. Oracle12c RAC RMAN异机恢复

    ######################################################## #编辑pfile文件initspdb.ora vi /oracle/app/oracl ...

  3. RMAN异机恢复遭遇ORA-01547、ORA-01152、ORA-01110错误案例

    测试环境:     操作系统  :  Red Hat Enterprise Linux ES release 4 (Nahant Update 4)   VMWARE     数据库     :  O ...

  4. Linux平台下RMAN异机恢复总结

    下面总结.整理一下RMAN异机恢复这方面的知识点,这篇笔记在个人笔记里面躺了几年了,直到最近偶然被翻看到,遂整理.总结一下.如下所示,个人将整个RMAN异机恢复分为准备工作和操作步骤两大部分.当然,准 ...

  5. RMAN异机恢复实验---转载

    一.RMAN异机恢复实验 2011年3月23日00:44 1.环境介绍: 主机1: 操作系统 REDHAT5.5 IP地址 172.16.1.120 主机名 sigle 数据库版本 10.2.0.4 ...

  6. Oracle RMAN 异机恢复一例

    背景介绍:本例需求是将NBU备份的oracle数据库恢复到另一主机上. NBU环境配置.异机上的Oracle软件安装配置忽略,下面只介绍OracleDB恢复的过程. ----------------- ...

  7. NBU Rman异机恢复Oracle

    前段时间一个亿级分区表,被分割成历史表和业务表,历史表中保留15天以外的数据,每天都会从业务表中的15天外的数据copy到历史表,并删除业务表15天外的数据,逻辑也很简单,但插入历史表的where 条 ...

  8. oracle rman异机恢复

      Oracle源主机 Oracle目标主机 主机平台 CentOS6.2(final) CentOs6.2(FInal) 主机名 vick rman IP地址 192.168.1.11 192.16 ...

  9. rman异机恢复,全部恢复和增量恢复

    1.首先准备工作:hostname 192.168.222.11 ol7.localdomain ol7建立相关目录:mkdir -p /u01/app/oracle/oradata/DB11G/mk ...

  10. RMAN异机恢复步骤及故障处理

    一.測试机安装OS+Oracle Software.包含配置oracle用户.组和环境变量(略) 二.開始异机恢复 1. 复制源库最新备份集.初始化參数.password文件到測试机 [oracle@ ...

随机推荐

  1. Problem A+B(Big Integer)

    /*======================================================================== Problem A+B(Big Integer) ...

  2. java8新语法

    Lambda表达式和函数接口(Functional Interface) // lambda expressions public static void DemoLambda() { // 不使用l ...

  3. deb、rpm、tar.gz三种Linux软件包的区别

    初接解LINUX的,同样都是for linux,但rpm.tar.gz.deb包还是有很大区别的, 这种区别可使安装过程进行不下去.那我们应该下载什么格式的包呢? rpm包-在红帽LINUX.SUSE ...

  4. phpcms日期时间

    PHPCMS V9调用时间标签 |日期时间格式化 转载 2016-06-17 14:58:54 标签:php PHPCMS V9 如何调用时间标签,下面分享常见的调用时间标签 |日期时间格式化 1.日 ...

  5. 移动设备上的媒体查询 CSS media queries for mobile device

    CSS的媒体查询虽然在传统的互联网页面可能发挥的余地不是很大,但是自从苹果和安卓的风靡之后,移动平台上的web开发变得越来越流行了,同时CSS的媒体查询可谓派上了大用场了. 以下为翻译内容,原文来自这 ...

  6. asp.net get App_Data 目录几种方法 path

    方法一 //ASP.NET MVC1 -> MVC3 string path = HttpContext.Current.Server.MapPath("~/App_Data/some ...

  7. ARM各种版本号知识以及型号的发展(三星为例)

    1.ARM型号的发展历史 2.单片机.工业上一般使用RTOS(实时操作系统),Linux.Android用在影音娱乐等对实时性要求没那么高的场合: 3.ARM内核版本号和Soc版本号是由ARM确定的, ...

  8. ulipad 常用快捷键

    快捷键名称 对应功能 F1 (M)UliPad Help Document(帮助文档) F2 (M)Directory Browser(目录浏览)(3.1版新增) F3 (M)Find Next(查找 ...

  9. MVC:上传文件

    今天写了一个使用MVC上传的DEMO,很简单不超过10行代码.代码如下(关注重点,所以尽量精简掉其他代码): 项目结构

  10. ahk鼠标连击工具

    ;x = 0开始点击,x = 1暂停点击 ^::ck_start() ^::ck_end() ck_start() { x = { Click } } ck_end() { x = else x = ...