使用rman把单机的备份集恢复到RAC的方法

简介: 环境准备在ASM磁盘组里面创建相应的目录

环境准备

在ASM磁盘组里面创建相应的目录

[oracle@db01 ~]$ . oraenv
ORACLE_SID = [ORCL1] ? +ASM1
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@db01 ~]$ asmcmd
ASMCMD> cd DATA
ASMCMD> mkdir ORCL
ASMCMD> cd ORCL
ASMCMD> mkdir CONTROLFILE
ASMCMD> mkdir DATAFILE
ASMCMD> mkdir ONLINELOG
ASMCMD> cd ..
ASMCMD> ls
DATA/
RECO/
ASMCMD> cd RECO
ASMCMD> mkdir ORCL
ASMCMD> cd ORCL
ASMCMD> mkdir CONTROLFILE
ASMCMD> mkdir ONLINELOG
ASMCMD> mkdir ARCHIVELOG



创建对应文件系统的目录

参数audit_file_dest 对应的目录要在每个节点上都创建


[root@db01 ~]# mkdir -p /u01/app/oracle/admin/ORCL/adump
[root@db02 ~]# mkdir -p /u01/app/oracle/admin/ORCL/adump

恢复spfile

RMAN> RESTORE SPFILE FROM '/backup_files/c-1039438773-20160405-01';


如果没有spfile,需要手工创建pfile,命名为initORCL1.ora (init{SID}.ora).


*.aq_tm_processes=2
*.audit_file_dest='/u01/app/oracle/admin/ORCL/adump'
*.audit_trail='db'
*.cluster_database=true
*.cluster_database_instances=2
*.compatible='11.2.0.4.0'
*.control_files='+DATA/ORCL/controlfile/current.1842.908572993','+RECO/ORCL/controlfile/current.21318.908572995'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_create_online_log_dest_1='+DATA'
*.db_files=300
*.db_name='ORCL'
*.db_recovery_file_dest='+RECO'
*.db_recovery_file_dest_size=3221225472000
*.db_unique_name='ORCL'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
ORCL2.instance_number=2
ORCL1.instance_number=1
*.job_queue_processes=1000
ORCL1.local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.225.16)(PORT=1521))))'
ORCL2.local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.225.14)(PORT=1521))))'
*.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST'
*.memory_max_target=20G
*.memory_target=20G
*.open_cursors=300
*.processes=5000
*.remote_listener='orcl-scan:1521'
*.remote_login_passwordfile='exclusive'
*.sessions=5505
*.shared_servers=0
ORCL2.thread=2
ORCL1.thread=1
*.undo_retention=1440
ORCL2.undo_tablespace='UNDOTBS2'
ORCL1.undo_tablespace='UNDOTBS1'


名字转换

*.log_file_name_convert='+OLD_DATA','+NEW_DATA','+OLD_RECO','+NEW_RECO'
*.db_file_name_convert='+OLD_DATA','+NEW_DATA'


配置文件/etc/oratab :

配置文件/etc/oratab的内容:


ORCL1:/u01/app/oracle/product/11.2.0.4/dbhome_1:N


恢复第一节点

启动到nomount状态

[oracle@db01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Sep 30 15:20:57 2020
SQL> startup nomount pfile=’/backup_files/pfile_ORCL.ora’;
SQL> startup nomount pfile=’/backup_files/pfile_ORCL.ora’;


恢复controlfile


RMAN> RESTORE CONTROLFILE from '/backup_files/c-1039438773-20200405-01';

启动到mount状态并恢复

启动到mount状态


SQL> startup mount pfile='/backup_files/pfile_ORCL.ora';


开始恢复

rman << EOF
connect target /
run
{
set DBID=1039438773;
sql 'alter database mount';
set newname for datafile 1 to '+YENI_DATA';
set newname for datafile 2 to '+YENI_DATA';
set newname for datafile 3 to '+YENI_DATA';
set newname for datafile 4 to '+YENI_DATA';
set newname for datafile 5 to '+YENI_DATA';
set newname for datafile 6 to '+YENI_DATA';
set newname for datafile 7 to '+YENI_DATA';
set newname for datafile 8 to '+YENI_DATA';
set newname for datafile 9 to '+YENI_DATA';
set newname for datafile 10 to '+YENI_DATA';
set newname for datafile 11 to '+YENI_DATA';
set newname for datafile 12 to '+YENI_DATA';
restore database;
restore archivelog all;
switch database to copy;
set until time "to_date('2016-04-06:00:00:00','yyyy-mm-dd:hh24:mi:ss')";
recover database;
}
EOF


recover数据库

SQL> recover database using backup controlfile until cancel;
ORA-00279: change 562385338311 generated at 04/05/2016 17:44:09 needed for
thread 1
ORA-00289: suggestion : +RECO
ORA-00280: change 562385338311 for thread 1 is in sequence #1607
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/backup_files/ONLINELOG/group_12.11832.858521665
ORA-00279: change 562385338311 generated at needed for thread 2
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/backup_files/ONLINELOG/group_22.2629.858521677
Log applied.
Media recovery complete.



打开数据库

RMAN> alter database open;


RMAN> alter database open resetlogs;
database opened

配置第一个数据库实例

修改sys的密码

SQL> alter user sys identified by your_sys_password;


创建口令文件

[oracle@db01 ~]$ cd $ORACLE_HOME/dbs
[oracle@db01 ~]$ orapwd file=orapwORCL1 password=Welcome1 entries=5


如果必要,增加redo

SQL> ALTER DATABASE ADD LOGFILE MEMBER '+RECO' TO GROUP 1;
SQL> ALTER DATABASE ADD LOGFILE MEMBER '+RECO' TO GROUP 2;
SQL> ALTER DATABASE ADD LOGFILE MEMBER '+RECO' TO GROUP 3;


配置监听

SQL> show parameter listener
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
listener_networks string
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=172.
16.225.16)(PORT=1521))))
remote_listener string orcl-scan:1521


在crs中增加数据库

[oracle@db01 ]$ srvctl add database -d ORCL -o /u01/app/oracle/product/11.2.0.4/dbhome_1 -p '+DATA/ORCL/spfileORCL.ora' -n ORCL
[oracle@db01 ]$ srvctl add instance -d ORCL -i ORCL1 -n db01
[oracle@db01 ]$ srvctl add instance -d ORCL -i ORCL2 -n db02

配置第二个节点

拷贝文件:

db01:$ORACLE_HOME/dbs/initORCL1.ora --> db02:$ORACLE_HOME/dbs/initORCL2.ora
db01:$ORACLE_HOME/dbs/orapwORCL1 --> db02:$ORACLE_HOME/dbs/orapwORCL2


配置undo

CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE 
'+DATA' SIZE 10G AUTOEXTEND ON NEXT 5M MAXSIZE UNLIMITED
ONLINE
RETENTION NOGUARANTEE
BLOCKSIZE 8K
FLASHBACK ON;


创建redo

SQL> ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 4 '+DATA' SIZE 500m;
Database altered.
SQL> ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 5 '+DATA' SIZE 500m;
Database altered.
SQL> ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 6 '+DATA' SIZE 500m;
Database altered.
SQL> ALTER DATABASE ADD LOGFILE MEMBER '+RECO' TO GROUP 4;
Database altered.
SQL> ALTER DATABASE ADD LOGFILE MEMBER '+RECO' TO GROUP 5;
Database altered.
SQL> ALTER DATABASE ADD LOGFILE MEMBER '+RECO' TO GROUP 6;
Database altered.
相关文章
|
数据库
rac 转换单机
rac 转换单机
152 0
|
Oracle 关系型数据库 测试技术
Oracle 11G ADG 搭建 RAC to Single 详细教程(RMAN DUPLICATE)
经过交流群中朋友的多次要求,这次给大家分享一下 RAC to Single 的 ADG 搭建教程!
Oracle 11G ADG 搭建 RAC to Single 详细教程(RMAN DUPLICATE)
|
数据库
rac 转单机
rac 转单机
120 0
|
数据库
|
Oracle 关系型数据库 数据库
RAC到单机搭建DataGuard
一、环境信息 1、服务器:Cetnos 7.22、数据库版本:11.2.0.43、RAC -> 单机 二、环境准备      目标是搭建RAC到单机的Activity DataGuard,首先RAC环境是准备完善的,接下来需要搭建一个单机环境。
1980 0
|
4月前
|
运维 Oracle 前端开发
Oracle 11g RAC集群日常运维命令总结
Oracle 11g RAC集群日常运维命令总结
107 2