oracle rac搭建单实例DG步骤(阅读全篇后再做)
环境介绍
主库:
主机名 | rac01 | rac02 |
实体IP | 10.206.132.232 | 10.206.132.233 |
私有IP | 192.168.56.12 | 192.168.56.13 |
虚拟IP | 10.206.132.237 | 10.206.132.238 |
SCAN IP | 10.206.132.239 | |
实例名 | racdb1 | racdb2 |
数据库名 | racdb | |
数据文件目录 | DGDATA01,DGDATA02(ASM磁盘) |
备库:
主机名 | dr-rac |
实体IP | 10.206.132.245 |
虚拟IP | 10.206.132.246 |
实例名 | racdb |
数据库名 | racdb |
数据文件目录 | /oradata01/racdb/,/oradata02/racdb |
数据文件目录备库和主库的ASM目录数量和大小要一致,后面会讲原因
1.安装oracle软体(和rac数据库的软体版本一致,本实验使用的是11GR2)
2.主库开启归档并打开force logging
打开force logging
SQL> alter database force logging; Database altered. SQL> select force_logging from v$database; FOR --- YES
打开归档
关闭数据库(两个节点执行)
$ sqlplus / as sysdba
SQL> shutdown immediate;
将数据库打开至mount状态(两个节点执行)
SQL> startup mount;
修改数据库的归档模式(任一节点即可)
SQL> alter database archivelog;
修改归档路径(两个节点执行)
SQL> alter system set log_archive_dest_1='location=/archlog/racdb';
打开数据库(两个节点)
SQL> alter database open;
3.主库全备(任一节点执行)
$ rman target / run{ allocate channel c1 device type disk format '/oggdata/backup/full_%d_%T_%s_%p.bak'; allocate channel c2 device type disk format '/oggdata/backup/full_%d_%T_%s_%p.bak'; allocate channel c3 device type disk format '/oggdata/backup/full_%d_%T_%s_%p.bak'; sql 'alter system archive log current'; backup as compressed backupset database plus archivelog; backup current controlfile; backup spfile; }
4.将全备文件传送至备库
$ scp * 10.206.132.245:/data/backup
6.将主库的参数文件传送至备库
SQL> create pfile='/tmp/initracdb.ora' from spfile; $ scp /tmp/initracdb.ora 10.206.132.245:/oracle/11204/dbs
根据实际的情况,RAC的参数文件和单实例的参数文件有一定的差别,所以我一般会从一个单实例数据库创建一个pfile传送过来并修改
7.修改参数文件并创建参数文件所需目录
其中以双下划线开头的是oracle自动内存管理生成的,可以直接删除,如
testdb.__db_cache_size=1862270976 testdb.__java_pool_size=16777216 testdb.__large_pool_size=33554432 testdb.__oracle_base='/oracle'#ORACLE_BASE set from environment testdb.__pga_aggregate_target=838860800 testdb.__sga_target=2483027968 testdb.__shared_io_pool_size=0 testdb.__shared_pool_size=503316480 testdb.__streams_pool_size=33554432
其中以单下划线开头的是隐含参数,根据实际情况修改
修改SGA,PGA
修改控制文件位置
*.control_files='/oradata01/racdb/control01.ctl','/oradata01/racdb/control02.ctl'
创建目录
*.audit_file_dest='/oracle/admin/racdb/adump'
*.db_recovery_file_dest='/oracle/fast_recovery_area'
其他参数根据实际情况修改,删除或者添加
8.创建spfile并打开实例
SQL> create spfile from pfile; SQL> startup nomount;
9.还原standby controlfile
进入主库查看controlfile的备份片
[oracle@rac01 ~]$ rman target / RMAN> list backup of controlfile; ------------------------------------------------------------------------------------ BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 26 Full 17.67M DISK 00:00:01 15-APR-20 BP Key: 26 Status: AVAILABLE Compressed: NO Tag: TAG20200415T150050 Piece Name: /oggdata/backup/full_RACDB_20200415_26_1.bak Control File Included: Ckp SCN: 558979 Ckp time: 15-APR-20 ------------------------------------------------------------------------------------
备库进入rman进行还原
[oracle@dr-rac dbs]$ rman target / RMAN> restore standby controlfile from '/data/backup/full_RACDB_20200415_26_1.bak';
10.将数据库启动至mount状态并进行数据库还原(备库)
mount数据库
[oracle@dr-rac dbs]$ sqlplus / as sysdba SQL> alter database mount;
此时遇到了一个问题,在RAC数据库中数据文件(包括临时表空间,在线联机日志)是在ASM磁盘内的,例如+DGDATA01等,在单实例上面是系统目录,如何对应
查看当前数据文件的状态
SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- +DGDATA01/racdb/datafile/system.260.1037709075 +DGDATA01/racdb/datafile/sysaux.261.1037709079 +DGDATA01/racdb/datafile/undotbs1.262.1037709081 +DGDATA01/racdb/datafile/undotbs2.264.1037709089 +DGDATA01/racdb/datafile/users.265.1037709091 +DGDATA02/racdb/datafile/mytbs01.dbf SQL> select name from v$tempfile; NAME -------------------------------------------------------------------------------- +DGDATA01/racdb/tempfile/temp.263.1037709085 SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- +DGDATA01/racdb/redo01.log +DGDATA01/racdb/redo02.log +DGDATA01/racdb/redo03.log +DGDATA01/racdb/redo04.log
因此我们需要在RMAN中将恢复的目录对应起来(下面的脚本根据自己实际情况进行修改)
DECLARE dir VARCHAR2 (100); CURSOR dbfs IS SELECT FILE_NAME FROM DBA_DATA_FILES; BEGIN FOR dbf IN dbfs LOOP SELECT SUBSTR (dbf.FILE_NAME, 2, INSTR (dbf.FILE_NAME, '/', 1) - 2) INTO DIR FROM DUAL; IF (DIR = 'DGDATA01') THEN DBMS_OUTPUT.PUT_LINE('SET NEWNAME FOR DATAFILE '''||dbf.FILE_NAME||''' TO ''/oradata01'||substr(dbf.file_name,instr(dbf.file_name,'/',1),length(dbf.file_name))||''';'); ELSIF (DIR = 'DGDATA02') THEN DBMS_OUTPUT.PUT_LINE('SET NEWNAME FOR DATAFILE '''||dbf.FILE_NAME||''' TO ''/oradata02'||substr(dbf.file_name,instr(dbf.file_name,'/',1),length(dbf.file_name))||''';'); END IF; END LOOP; END; ---------------------------------------------------------------------------------------------------------------------- SET NEWNAME FOR DATAFILE '+DGDATA01/racdb/datafile/system.260.1037709075' TO '/oradata01/racdb/datafile/system.260.1037709075'; SET NEWNAME FOR DATAFILE '+DGDATA01/racdb/datafile/sysaux.261.1037709079' TO '/oradata01/racdb/datafile/sysaux.261.1037709079'; SET NEWNAME FOR DATAFILE '+DGDATA01/racdb/datafile/undotbs1.262.1037709081' TO '/oradata01/racdb/datafile/undotbs1.262.1037709081'; SET NEWNAME FOR DATAFILE '+DGDATA01/racdb/datafile/undotbs2.264.1037709089' TO '/oradata01/racdb/datafile/undotbs2.264.1037709089'; SET NEWNAME FOR DATAFILE '+DGDATA01/racdb/datafile/users.265.1037709091' TO '/oradata01/racdb/datafile/users.265.1037709091'; SET NEWNAME FOR DATAFILE '+DGDATA02/racdb/datafile/mytbs01.dbf' TO '/oradata02/racdb/datafile/mytbs01.dbf'; ----------------------------------------------------------------------------------------------------------------------
使用RMAN进行数据库的还原(备库),恢复之前要在对应的目录下建立子文件夹(如racdb/datafile)
[oracle@dr-rac dbs]$ rman target / RMAN> catalog start with '/data/backup'; run { SET NEWNAME FOR DATAFILE '+DGDATA01/racdb/datafile/system.260.1037709075' TO '/oradata01/racdb/datafile/system.260.1037709075'; SET NEWNAME FOR DATAFILE '+DGDATA01/racdb/datafile/sysaux.261.1037709079' TO '/oradata01/racdb/datafile/sysaux.261.1037709079'; SET NEWNAME FOR DATAFILE '+DGDATA01/racdb/datafile/undotbs1.262.1037709081' TO '/oradata01/racdb/datafile/undotbs1.262.1037709081'; SET NEWNAME FOR DATAFILE '+DGDATA01/racdb/datafile/undotbs2.264.1037709089' TO '/oradata01/racdb/datafile/undotbs2.264.1037709089'; SET NEWNAME FOR DATAFILE '+DGDATA01/racdb/datafile/users.265.1037709091' TO '/oradata01/racdb/datafile/users.265.1037709091'; SET NEWNAME FOR DATAFILE '+DGDATA02/racdb/datafile/mytbs01.dbf' TO '/oradata02/racdb/datafile/mytbs01.dbf'; allocate channel c1 device type disk; allocate channel c2 device type disk; allocate channel c3 device type disk; restore database; release channel c1; release channel c2; release channel c3; }
11.修改controlfile中redo和tempfile的位置,以便打开后自动创建(前提还是要创建好对应的目录,否则一会儿数据库打不开)
SQL> alter database rename file '+DGDATA01/racdb/tempfile/temp.263.1037709085' to '/oradata01/racdb/tempfile/temp.263.1037709085';
DECLARE dir VARCHAR2 (100); CURSOR LFS IS SELECT MEMBER FROM v$logfile; BEGIN FOR LF IN LFS LOOP SELECT SUBSTR (LF.MEMBER, 2, INSTR (LF.MEMBER, '/', 1) - 2) INTO DIR FROM DUAL; IF (DIR = 'DGDATA01') THEN DBMS_OUTPUT.PUT_LINE('ALTER DATABASE RENAME FILE '''||LF.MEMBER||''' TO ''/oradata01'||substr(LF.MEMBER,instr(LF.MEMBER,'/',1),length(LF.MEMBER))||''';'); ELSIF (DIR = 'DGDATA02') THEN DBMS_OUTPUT.PUT_LINE('ALTER DATABASE RENAME FILE '''||LF.MEMBER||''' TO ''/oradata02'||substr(LF.MEMBER,instr(LF.MEMBER,'/',1),length(LF.MEMBER))||''';'); END IF; END LOOP; END; ------------------------------------------------------------------------------- ALTER DATABASE RENAME FILE '+DGDATA01/racdb/redo01.log' TO '/oradata01/racdb/redo01.log'; ALTER DATABASE RENAME FILE '+DGDATA01/racdb/redo02.log' TO '/oradata01/racdb/redo02.log'; ALTER DATABASE RENAME FILE '+DGDATA01/racdb/redo03.log' TO '/oradata01/racdb/redo03.log'; ALTER DATABASE RENAME FILE '+DGDATA01/racdb/redo04.log' TO '/oradata01/racdb/redo04.log'; -------------------------------------------------------------------------------
12.打开数据库
这时候报错
SQL> alter database open; alter database open * ERROR at line 1: ORA-10458: standby database requires recovery ORA-01157: cannot identify/lock data file 1 - see DBWR trace file ORA-01110: data file 1: '+DGDATA01/racdb/datafile/system.260.1037709075'
这是因为控制文件中的datafile的路径没有改变,两种办法解决
第一种,修改控制文件中数据文件的路径
DECLARE dir VARCHAR2 (100); CURSOR dbfs IS SELECT FILE_NAME FROM DBA_DATA_FILES; BEGIN FOR dbf IN dbfs LOOP SELECT SUBSTR (dbf.FILE_NAME, 2, INSTR (dbf.FILE_NAME, '/', 1) - 2) INTO DIR FROM DUAL; IF (DIR = 'DGDATA01') THEN DBMS_OUTPUT.PUT_LINE('ALTER DATABASE RENAME FILE '''||dbf.FILE_NAME||''' TO ''/oradata01'||substr(dbf.file_name,instr(dbf.file_name,'/',1),length(dbf.file_name))||''';'); ELSIF (DIR = 'DGDATA02') THEN DBMS_OUTPUT.PUT_LINE('ALTER DATABASE RENAME FILE '''||dbf.FILE_NAME||''' TO ''/oradata02'||substr(dbf.file_name,instr(dbf.file_name,'/',1),length(dbf.file_name))||''';'); END IF; END LOOP; END; ----------------------------------------------------------------------------- ALTER DATABASE RENAME FILE '+DGDATA01/racdb/datafile/system.260.1037709075' TO '/oradata01/racdb/datafile/system.260.1037709075'; ALTER DATABASE RENAME FILE '+DGDATA01/racdb/datafile/sysaux.261.1037709079' TO '/oradata01/racdb/datafile/sysaux.261.1037709079'; ALTER DATABASE RENAME FILE '+DGDATA01/racdb/datafile/undotbs1.262.1037709081' TO '/oradata01/racdb/datafile/undotbs1.262.1037709081'; ALTER DATABASE RENAME FILE '+DGDATA01/racdb/datafile/undotbs2.264.1037709089' TO '/oradata01/racdb/datafile/undotbs2.264.1037709089'; ALTER DATABASE RENAME FILE '+DGDATA01/racdb/datafile/users.265.1037709091' TO '/oradata01/racdb/datafile/users.265.1037709091'; ALTER DATABASE RENAME FILE '+DGDATA02/racdb/datafile/mytbs01.dbf' TO '/oradata02/racdb/datafile/mytbs01.dbf'; -----------------------------------------------------------------------------
第二种,在还原控制文件之前,我们在参数文件中加入如下两个参数
alter system set log_file_name_convert='+DGDATA01/racdb/','/oradata01/racdb/','+DGDATA02/racdb/','/oradata02/racdb/' scope=spfile; alter system set db_file_name_convert='+DGDATA01/racdb/datafile/','/oradata01/racdb/datafile/','+DGDATA02/racdb/datafile/','/oradata02/racdb/datafile/' scope=spfile;
第二种还原的控制文件中datafile和logfile自动会定位到正确的目录,同时在第十步中也不需要前面NET NEWNAME,直接还原即可,因此强烈建议这两个参数在还原控制文件之前加入。
参数一定要注意,前面最后加/,后面也要加/,否则替换的时候会出错,例如'+DGDATA01/racdb/','/oradata01/racdb',会把+DGDATA01/racdb/redo01.log对应成/oradata01/racdbredo01.log
再次打开数据时,又报错了
SQL> alter database open; alter database open * ERROR at line 1: ORA-10458: standby database requires recovery ORA-01152: file 1 was not restored from a sufficiently old backup ORA-01110: data file 1: '/oradata01/racdb/datafile/system.260.1037709075'
这是因为我们没有恢复数据库,使用rman恢复数据库,有两种方法
第一种,恢复数据库(这里面的SCN也可以从RMAN的list backup of archivelog all里面看到归档的最高SCN)
恢复之前要加上这两个参数的原因可以看后面的试验
SQL> alter system set db_file_name_convert='+DGDATA01/racdb/datafile','/oradata01/racdb/datafile','+DGDATA02/racdb/datafile','/oradata02/racdb/datafile' scope=spfile;
SQL> alter system set standby_file_management=auto;
查看主库当前的SCN SQL> select current_scn from v$database; 主库归档当前的REDO SQL> alter system archive log current; 将主库的归档传送至备库 $ scp /archlog/readb/* 10.206.132.245:/oradata02/archlog 备库恢复 RMAN> catalog start with '/oradata02/archlog'; RMAN> recover database until scn 565400; 打开数据库 SQL> alter database open;
第二种,不用管,继续配置DG库,之后会自动将归档传过来并应用
13.配置备库的监听
从其他库copy过来一个修改即可
$ cd /oracle/11204/network/admin/ $ scp listener.ora 10.206.132.245:`pwd`
$ vi listener.ora
$ lsnrctl star
14.将主库(任一节点)的口令文件传过来
$ cd $ORACLE_HOME/dbs $ scp orapwracdb1 10.206.132.245:/oracle/11204/dbs/orapwracdb
15.修改主库的TNS(加入自己和备库的TNS)并传送到另一个节点和备库
$ vi tnsnames.ora ------------------------------------------------------------------------------- RACDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.206.132.239)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = racdb) ) ) STANDBY_RACDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.206.132.245)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = racdb) ) ) ------------------------------------------------------------------------------- $ scp tnsnames.ora 10.206.132.233:/oracle/home/network/admin/ $ scp tnsnames.ora 10.206.132.245:/oracle/11204/network/admin
16.修改备库的参数
alter system set db_unique_name='standby_racdb' scope=spfile; alter system set db_file_name_convert='+DGDATA01/racdb/datafile','/oradata01/racdb/datafile','+DGDATA02/racdb/datafile','/oradata02/racdb/datafile' scope=spfile; alter system set log_file_name_convert='+DGDATA01/racdb/','/oradata01/racdb','+DGDATA02/racdb','/oradata02/racdb' scope=spfile; 重啟數據庫 alter system set log_archive_config='dg_config=(racdb,standby_racdb)'; alter system set log_archive_dest_1='LOCATION=/oradata02/archlog valid_for=(all_logfiles,all_roles) db_unique_name=standby_racdb'; alter system set log_archive_dest_2='service=racdb async valid_for=(online_logfiles, primary_role) db_unique_name=racdb'; alter system set log_archive_dest_state_1=enable; alter system set log_archive_dest_state_2=enable; alter system set fal_server=racdb; alter system set fal_client=standby_racdb; alter system set standby_file_management=auto; alter system set log_archive_max_processes=30;
18.修改主库参数(我的参数文件时共享的,因此修改一个节点即可)
alter system set db_file_name_convert='/oradata01/racdb/datafile','+DGDATA01/racdb/datafile','/oradata02/racdb/datafile','+DGDATA02/racdb/datafile' scope=spfile; alter system set log_file_name_convert='/oradata01/racdb','+DGDATA01/racdb/','/oradata02/racdb','+DGDATA02/racdb' scope=spfile; 重啟數據庫(根据实际业务,可以先修改,等无业务期间重启实例) alter system set log_archive_config='dg_config=(racdb,standby_racdb)'; alter system set log_archive_dest_1='LOCATION=/archlog/racdb valid_for=(all_logfiles,all_roles) db_unique_name=racdb'; alter system set log_archive_dest_2='service=standby_racdb async valid_for=(online_logfiles, primary_role) db_unique_name=standby_racdb'; alter system set log_archive_dest_state_1=enable; alter system set log_archive_dest_state_2=enable; alter system set fal_server=standby_racdb; alter system set fal_client=racdb; alter system set standby_file_management=auto; alter system set log_archive_max_processes=30;
19.打开备库的日志应用
SQL> alter database recover managed standby database disconnect;
20.新建表并插入数据测试
create table testdg(id number); insert into testdg values (1); commit; #因为没有添加standby_logfile因此无法实时应用,需要切换归档 alter system archive log current;
同时发现REDO产生了,应该是修改主库参数文件后传送过来或备库应用日志的时候产生的。
tempfile是在备库打开(open)的时候产生的。
实验
主备目录不相同的情况下,如果全备之后,增加了数据文件或者修改了数据文件的大小,在恢复备库的时候,会发生什么
试验一:主库全备后,增加数据文件的大小
alter database datafile '+DGDATA02/racdb/datafile/mytbs01.dbf' resize 2g; alter system archive log current; select current_scn from v$database; 614673 alter system archive log current; $ scp 2_17_1037709071.dbf 2_18_1037709071.dbf 1_30_1037709071.dbf 1_31_1037709071.dbf 10.206.132.245:/oradata02/archlog RMAN> catalog start with '/oradata02/archlog'; SQL> shutdown immediate; SQL> startup mount; RMAN> recover database until scn 614673; # cd /oradata02/racdb/datafile # du -sh mytbs01.dbf ---------------------------------------- 2.1G mytbs01.dbf ----------------------------------------
通过上述实验,发现只要数据文件已经被还原,那么增加数据文件的大小会自动应用到对应的目录上面(感觉应该是根据的数据文件号)
实验二:主库全备后,增加数据文件
alter tablespace mytbs add datafile '+DGDATA02/racdb/datafile/mytbs02.dbf' size 1g; alter system archive log current; select current_scn from v$database; 615468 alter system archive log current; $ scp 2_19_1037709071.dbf 2_20_1037709071.dbf 1_32_1037709071.dbf 1_33_1037709071.dbf 10.206.132.245:/oradata02/archlog RMAN> catalog start with '/oradata02/archlog'; SQL> shutdown immediate; SQL> startup mount; RMAN> recover database until scn 615468; creating datafile file number=7 name=+DGDATA02/racdb/datafile/mytbs02.dbf RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 04/16/2020 08:24:27 RMAN-20505: create datafile during recovery ORA-01119: error in creating database file '+DGDATA02/racdb/datafile/mytbs02.dbf' ORA-17502: ksfdcre:3 Failed to create file +DGDATA02/racdb/datafile/mytbs02.dbf ORA-15001: diskgroup "DGDATA02" does not exist or is not mounted ORA-15077: could not locate ASM instance serving a required diskgroup ORA-29701: unable to connect to Cluster Synchronization Service RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/oradata02/archlog/2_19_1037709071.dbf' ORA-00283: recovery session canceled due to errors ORA-01274: cannot add datafile '+DGDATA02/racdb/datafile/mytbs02.dbf' - file could not be created 此時,我們加入參數 SQL> alter system set db_file_name_convert='+DGDATA01/racdb/datafile','/oradata01/racdb/datafile','+DGDATA02/racdb/datafile','/oradata02/racdb/datafile' scope=spfile; SQL> shutdown immediate; SQL> startup mount; RMAN> recover database until scn 615468; Starting recover at 16-APR-20 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=67 device type=DISK RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 04/16/2020 08:29:08 RMAN-06094: datafile 7 must be restored RMAN> restore datafile 7; Starting restore at 16-APR-20 using channel ORA_DISK_1 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of restore command at 04/16/2020 08:29:44 RMAN-06085: must use SET NEWNAME command to restore datafile /oracle/11204/dbs/UNNAMED00007 run{ SET NEWNAME FOR DATAFILE '/oracle/11204/dbs/UNNAMED00007' TO '/oradata02/racdb/datafile/mytbs02.dbf'; restore datafile 7; } datafile 7 is already restored to file /oradata02/racdb/datafile/mytbs02.dbf restore not done; all files read only, offline, or already restored Finished restore at 16-APR-20 進入系統,發現/oradata02/racdb/datafile/mytbs02.dbf已經存在,此時,我們只需要修改數據文件即可 SQL> alter database rename file '/oracle/11204/dbs/UNNAMED00007' to '/oradata02/racdb/datafile/mytbs02.dbf'; 此時再次測試 alter tablespace mytbs add datafile '+DGDATA02/racdb/datafile/mytbs03.dbf' size 1g; alter system archive log current; select current_scn from v$database; 616851 alter system archive log current; $ scp 2_21_1037709071.dbf 2_22_1037709071.dbf 1_34_1037709071.dbf 1_35_1037709071.dbf 10.206.132.245:/oradata02/archlog RMAN> catalog start with '/oradata02/archlog'; RMAN> recover database until scn 616851; RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 04/16/2020 08:55:11 RMAN-20505: create datafile during recovery ORA-01119: error in creating database file '+DGDATA02/racdb/datafile/mytbs03.dbf' ORA-17502: ksfdcre:3 Failed to create file +DGDATA02/racdb/datafile/mytbs03.dbf ORA-15001: diskgroup "DGDATA02" does not exist or is not mounted ORA-15077: could not locate ASM instance serving a required diskgroup ORA-29701: unable to connect to Cluster Synchronization Service RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/oradata02/archlog/1_34_1037709071.dbf' ORA-00283: recovery session canceled due to errors ORA-01274: cannot add datafile '+DGDATA02/racdb/datafile/mytbs03.dbf' - file could not be created run{ SET NEWNAME FOR DATAFILE '/oracle/11204/dbs/UNNAMED00008' TO '/oradata02/racdb/datafile/mytbs03.dbf'; restore datafile 8; } SQL> alter database rename file '/oracle/11204/dbs/UNNAMED00008' to '/oradata02/racdb/datafile/mytbs03.dbf'; RMAN> recover database until scn 616851;
通过实验发现,在主库全备后增加数据文件在恢复的时候由于目录不对应,会报错
此时决定加入另外一个参数alter system set standby_file_management=auto,看恢复的时候是否可以自动创建对应的文件
SQL> alter system set db_file_name_convert='+DGDATA01/racdb/datafile','/oradata01/racdb/datafile','+DGDATA02/racdb/datafile','/oradata02/racdb/datafile' scope=spfile; SQL> alter system set standby_file_management=auto; SQL> shutdown immediate; SQL> startup mount; RMAN> catalog start with '/oradata02/archlog'; RMAN> recover database until scn 616851;
全备是在经过试验之前的,也就是没有mytbs02.dbf,mytbs03.dbf,mytbs04.dbf,增加两个db_file_name_convert,standby_file_management参数后,恢复过程没有报错,因此这两个参数应该在恢复之前加上。