源端
服务器主机名 rac05 rac06
公共IP地址(eth0) 10.15.8.15 10.15.8.16
虚拟IP地址(eth0) 10.15.8.17 10.15.8.18
私有IP地址(eth1) 1.1.1.9 1.1.1.10
ORACLE RAC SID bol1 bol2
集群实例名称 bol
SCAN IP 10.15.8.19
操作系统 CentOS 6.5(vm)
存储 ASM(vm)
ORACLE 11.2.0.4
目标端(实例已安装运行)
服务器主机名 rac01 rac02
公共IP地址(eth0) 10.15.7.20 10.15.7.21
虚拟IP地址(eth0) 10.15.7.22 10.15.7.23
私有IP地址(eth1) 1.1.1.5 1.1.1.6
ORACLE RAC SID bol1 bol2
集群实例名称 bol
SCAN IP 10.15.7.24
操作系统 CentOS 6.5(vbox)
存储 ASM(openfiler)
ORACLE 11.2.0.4
1 源端rman备份并cp到目标端
RUN_STR="
$RMAN target / <<EOF
run
{
configure RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
configure controlfile autobackup on;
configure backup OPTIMIZATION ON;
allocate channel c1 device type disk;
backup skip inaccessible filesperset 5 database format=‘/home/oracle/backup/bol_fullbak_%U_%T‘ tag=‘bol_fullbak‘;
sql ‘alter system archive log current‘;
backup format ‘/home/oracle/backup/arch_%U_%T‘ skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT;
backup format=‘/home/oracle/backup/%T_%d_%s_%p_%I.ctl‘ current controlfile;
backup spfile tag=‘spfile‘ format=‘/home/oracle/backup/bol_spfile_%U_%T‘;
release channel c1;
}
report obsolete;
delete noprompt obsolete;
crosscheck backup;
delete noprompt expired backup;
list backup summary;
EOF"
[[email protected] backup]$ scp *_20190402 20190402_BOL_96_1_4224128722.ctl [email protected]:/home/oracle/backup/.
关闭集群参数并关闭数据库实例准备恢复
[[email protected] ~]$ sqlplus / as sysdba
SQL> alter system set cluster_database=true scope=spfile sid=‘*‘;
[[email protected] ~]$ srvctl stop database -d bol
启动到nomount状态
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2257352 bytes
Variable Size 562040376 bytes
Database Buffers 213909504 bytes
Redo Buffers 6791168 bytes
因实例名称一致,spfile文件不需要恢复,保留原参数文件以及相关配置。
口令文件也保留
恢复控制文件
[[email protected] backup]$ rman target/
RMAN> restore controlfile from ‘/home/oracle/backup/20190402_BOL_96_1_4224128722.ctl‘;
Starting restore at 02-APR-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=141 instance=bol1 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=+DATA/bol/controlfile/current.256.1004464153
output file name=+FRA/bol/controlfile/current.256.1004464155
Finished restore at 02-APR-19
通过备份的控制文件启动到mount状态
注:具体哪个文件还原控制文件,可参数源端运行 list backup of controlfile 可知
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> crosscheck backupset;
RMAN> catalog start with ‘/home/oracle/backup‘;
RMAN> list backup summary;
查看与记录数据库信息
查看源端数据文件及编号
SQL> set pagesize 999;
SQL> set linesize 200;
SQL> col NAME for a65
SQL> select file#,name from v$datafile;
FILE# NAME
---------- -----------------------------------------------------------------
1 +DATA/bol/datafile/system.259.1001415513
2 +DATA/bol/datafile/sysaux.260.1001415515
3 +DATA/bol/datafile/undotbs1.261.1001415517
4 +DATA/bol/datafile/undotbs2.263.1001415521
5 +DATA/bol/datafile/users.264.1001415523
6 +DATA/bol/datafile/sde_tbs.dbf
7 +DATA/bol/datafile/cad.dbf
8 +DATA/bol/datafile/scott1.dbf
8 rows selected.
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------
+DATA/bol/onlinelog/group_1.257.1001415511
+FRA/bol/onlinelog/group_1.257.1001415511
+DATA/bol/onlinelog/group_2.258.1001415511
+FRA/bol/onlinelog/group_2.258.1001415511
+DATA/bol/onlinelog/group_3.265.1001416789
+FRA/bol/onlinelog/group_3.259.1001416791
+DATA/bol/onlinelog/group_4.266.1001416791
+FRA/bol/onlinelog/group_4.260.1001416791
+FRA/bol/onlinelog/group_11.263.1002035351
+FRA/bol/onlinelog/group_12.264.1002035357
+FRA/bol/onlinelog/group_13.265.1002035361
+FRA/bol/onlinelog/group_14.266.1002035365
+FRA/bol/onlinelog/group_15.267.1002035371
+FRA/bol/onlinelog/group_16.268.1002035375
+FRA/bol/onlinelog/group_17.269.1002035379
+FRA/bol/onlinelog/group_18.270.1002035383
+FRA/bol/onlinelog/group_19.271.1002035389
+FRA/bol/onlinelog/group_20.272.1002035393
18 rows selected.
SQL> select name from v$tempfile;
NAME
-----------------------------------------------------------------
+DATA/bol/tempfile/temp.262.1001415517
--查看源端数据文件构造RMAN RUN脚本。
--SQL> select ‘set newname for datafile ‘||file_id||‘ to ‘‘‘||‘+DATA‘||‘‘‘;‘ cmd from dba_data_files order by file_id;
--SQL> select ‘set newname for tempfile ‘||file_id||‘ to ‘‘‘||‘+DATA‘||‘‘‘;‘ cmd from dba_temp_files;
---这里由于是rac到rac,而且路径一样,就不用set newname
恢复数据文件
#通过RMAN重命名数据文件进行恢复到本地的文件系统上。
rman target /
run {
restore database;
switch datafile all;
switch tempfile all;
}
恢复数据库
RMAN> list backup of archivelog all;
------- ---------- ----------- ------------ ---------------
87 7.00K DISK 00:00:00 02-APR-19
BP Key: 87 Status: AVAILABLE Compressed: NO Tag: TAG20190402T144623
Piece Name: /home/oracle/backup/arch_2vtu03n0_1_1_20190402
List of Archived Logs in backup set 87
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 225 6226208 02-APR-19 6226219 02-APR-19
2 127 6226204 02-APR-19 6226224 02-APR-19
注:根据备份集可以先恢复到SCN为 6226219 ,如果直接 recover database 会因丢失部分日志报错,但可以忽略
RMAN> recover database until scn 6226219;
打开数据库
采用resetlogs打开数据库
说明:采用rman备份没有redolog文件,以及采用恢复的控制文件进行恢复,恢复时采用不完全恢复。
需要使用resetlogs方式打开数据库。
SQL> alter database open resetlogs;
Database altered.
SQL> select * from v$option where parameter=‘Real Application Clusters‘;
SQL> show parameter cluster
SQL> show parameter thread
SQL> show parameter instance_number
SQL> alter system set cluster_database=true scope=spfile sid=‘*‘;
--SQL> alter system set cluster_database_instances=2 scope=spfile sid=‘*‘;
--SQL> alter system set instance_number=1 scope=spfile sid=‘bol1‘;
--SQL> alter system set instance_number=2 scope=spfile sid=‘bol2‘;
--SQL> alter system set thread=1 scope=spfile sid=‘bol1‘;
--SQL> alter system set thread=2 scope=spfile sid=‘bol2‘;
--创建节点2的UNDO表空间(节点1上操作即可)
SQL> show parameter undo_tablespace
--SQL> create undo tablespace UNDOTBS2 datafile ‘+DATA/bol/datafile/undotbs02.dbf‘ size 100M;
--SQL> alter system set undo_tablespace=‘UNDOTBS2‘ scope=spfile sid=‘bol2‘;
--重建temp表空间
因为在 recover 的时候不会对temp 表空间进行recover。所以recover 后,我们要手工重建temp表空间
--SQL> alter tablespace temp add tempfile ‘+DATA‘ size 100M;
SQL> select name from v$tempfile;
NAME
-----------------------------------------------------------------
+DATA/bol/tempfile/temp.280.1004543753
$ srvctl stop database -d bol -o immediate
$ srvctl start database -d bol -o open
SQL> select instance_number,instance_name ,host_name from gv$instance;
2 bol2 rac02
1 bol1 rac01
执行catclust.sql脚本创建相关视图
--SQL> @$ORACLE_HOME/rdbms/admin/catclust.sql
SQL> @/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/catclust.sql
SQL> select group#,member from v$logfile order by group#;
[[email protected] ~]$ srvctl status database -d bol
Instance bol1 is running on node rac01
Instance bol2 is running on node rac02
[[email protected] ~]$ srvctl config database -d bol
Database unique name: bol
Database name: bol
Oracle home: /u01/app/oracle/product/11.2.0/db_1
Oracle user: oracle
Spfile: +DATA/bol/spfilebol.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: bol
Database instances: bol1,bol2
Disk Groups: DATA,FRA
Mount point paths:
Services:
Type: RAC
Database is administrator managed
原文地址:https://www.cnblogs.com/yhq1314/p/10643359.html