rman异机恢复(RAC双节点恢复到单节点)

一、数据库全备

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这是因为没有拷归档

把归档放在相应目录后执行recover database;
恢复多个归档日志
run {
ALLOCATE CHANNEL ch00 TYPE ‘SBT_TAPE‘ connect ‘sys/[email protected]‘;
ALLOCATE CHANNEL ch01 TYPE ‘SBT_TAPE‘ connect ‘sys/[email protected]‘;
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/[email protected]‘;
ALLOCATE CHANNEL ch01 TYPE ‘SBT_TAPE‘ connect ‘sys/[email protected]‘;
SET ARCHIVELOG DESTINATION TO ‘/rac_arch1‘;
RESTORE ARCHIVELOG SEQUENCE 21519 thread 1;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
}

补充删除归档不能同操作系统命令rm要用delete noprompt archivelog 归档的路径和名字
delete noprompt archivelog ‘/rac_arch2/2_21519_812625454.dbf‘;
delete noprompt archivelog ‘/rac_arch2/2_21525_812625454.dbf‘;

归档都有后再执行recover database;
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

时间: 2024-11-29 12:09:50

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

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

Oracle 官网有关单实例迁移到RAC的一个步骤说明: How to Convert 10g Single-Instance database to 10g RAC using Manual Conversion procedure [ID 747457.1] http://blog.csdn.net/tianlesoftware/archive/2010/12/09/6065903.aspx   RMAN 备份异机恢复 并创建新DBID http://blog.csdn.net/tianle

Oracle12c RAC RMAN异机恢复

######################################################## #编辑pfile文件initspdb.ora vi /oracle/app/oracle/product/12.2.0/db_1/dbs/initspdb.ora audit_file_dest='/oracle/app/oracle/admin/spdb/adump' audit_trail='db' compatible='12.2.0' control_files='/orac

window Oracle 10g RMAN异机异目录恢复

1.实验环境简介                                  1.1  SOA原数据库                                                                                                                                                           数据库名        COMSOA 实例名          COMSOA DB

rman异机恢复

rman异机恢复 注意事项: 1.源数据库与目标数据库的目录结构相同 2.目标数据库只需要安装ORACLE软件(但是参数文件中指定的目录要创建) 3.要将源数据库的数据文件,参数文件,控制文件,密码文件,归档日志统统备份 1.源数据库备份 参数文件与控制文件自动备份 CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/home/oracle/r

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

一.RMAN异机恢复实验 2011年3月23日00:44 1.环境介绍: 主机1: 操作系统 REDHAT5.5 IP地址 172.16.1.120 主机名 sigle 数据库版本 10.2.0.4 数据库名 orcl DBID 1305151947 catalog win_yjr catalog用户 sigle/sigle 主机2: 操作系统 REDHAT5.5 IP地址 172.16.1.121 主机名 clone_sigle 数据库版本 10.2.0.4     2.本次恢复实验目的: 主

Linux平台下RMAN异机恢复总结

下面总结.整理一下RMAN异机恢复这方面的知识点,这篇笔记在个人笔记里面躺了几年了,直到最近偶然被翻看到,遂整理.总结一下.如下所示,个人将整个RMAN异机恢复分为准备工作和操作步骤两大部分.当然,准备工作里面,有些步骤不是必须的,可以跳过或忽略的.这个取决于你的实际环境和你对RMAN异机恢复的熟悉程度. 准备工作 1:了解一下目标服务器与源服务器的操作系统版本信息 需要对比一下目标服务器与源服务器的操作系统版本是否一致,具体来说,操作系统版本信息.内核信息(例如Oracle Linux是否使用

RMAN异机还原遭遇ORA-19698错误案例

实验环境: 操作系统    :Oracle Linux Server release 5.7 64 bit 数据库版本:Oracle Database 10g Release 10.2.0.4.0 - 64bit Production 案例说明: 为了测试.验证备份的有效性,需要将服务器A上的数据库的备份集还原到服务器B上,服务器B上已经创建了相同名称的ORACLE_SID和DB Name,对应数据文件目录环境完全一致 Step 1: startup nomount Step 2:  resto

使用rman异机复制数据库

源端数据库:192.168.1.210 sid:orcl hostname:Nagiostest ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/11.2 目标数据库:192.168.1.211 sid:orcl hostname:OEL6 ORACLE_BASE=/u01/app/oracle ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 这里是相同实例名的复制,如果实例

RMAN 异机恢复数据(Oracle 11g)

1 备份参数文件 $ORACLE_HOME$/dbs 2 按照RAMN备份时的路径复制文件及备份 要求完全按照原服务器路径来 3 删除旧库 [email protected]>shutdown immediate; [email protected]>startup mount restrict; [email protected]>drop database; 4 还原参数文件 cp /backup/other/* /app/oracle/product/11.2.0/dbhome_1

如何使用 RMAN 异机恢复部分表空间

在oracle 数据库的日常维护和使用期间难免会遇到误删数据(drop,delete, truncate)当我们使用常规手段(flashback query ,flashback drop)也无法恢复数据时,我们可以使用最近的逻辑备份,在异机使用dmp 来恢复相应的表,但是如果没有这些逻辑备份,但是有一个最近的rman 全备,那么我们就可以利用这个备份来恢复被误删的表空间,从而实现数据的恢复,这里我以NBU 的备份环境为例简单描述下如何来回复部分 表空间: -------在nomount 状态