rman > catalog start with '/home/oracle/backup'; rman > list backup summary; 执行下列run脚本(根据数据文件的不同作相应修改) RMAN> run{ set newname for datafile '/home/oracle/u01/app/oracle/oradata/testcadb/users01.dbf' to '+DATA1/testcadb/users01.dbf'; set newname for datafile '/home/oracle/u01/app/oracle/oradata/testcadb/undotbs01.dbf' to '+DATA1/testcadb/undotbs01.dbf'; set newname for datafile '/home/oracle/u01/app/oracle/oradata/testcadb/sysaux01.dbf' to '+DATA1/testcadb/sysaux01.dbf'; set newname for datafile '/home/oracle/u01/app/oracle/oradata/testcadb/system01.dbf' to '+DATA1/testcadb/system01.dbf'; set newname for datafile '/home/oracle/oradata/orcl/ebank_data.dbf' to '+DATA1/testcadb/ebank_data.dbf'; restore database; switch datafile all; } 或者: RMAN> run{ set newname for datafile 1 to '+DATA1/testcadb/users01.dbf'; set newname for datafile 2 to '+DATA1/testcadb/undotbs01.dbf'; set newname for datafile 3 to '+DATA1/testcadb/sysaux01.dbf'; set newname for datafile 4 to '+DATA1/testcadb/system01.dbf'; set newname for datafile 5 to '+DATA1/testcadb/ebank_data.dbf'; restore database; switch datafile all; } 查看备份的归档(如果是非归档模式的备份没有数据) RMAN> list backup of archivelog all; 根据scn恢复数据库 RMAN> recover database until scn 2896925; 或者如果没有归档,直接恢复数据库 RMAN> recover database;
尝试打开数据库:
1 2 3 4 5 6 7 8 9
shell > sqlplus / as sysdba sql > alter database open resetlogs; alter database open resetlogs * ERROR at line 1: ORA-00344: unable to re-create online log '/home/oracle/u01/app/oracle/oradata/testcadb/redo01.log' ORA-27040: file create error, unable to create file Linux-x86_64 Error: 2: No such file or directory Additional information: 1
sql > select group#,thread#,members,archived,status from v$log;
GROUP# THREAD# MEMBERS ARCHIV STATUS ---------- ---------- ---------- ------ -------------------------------- 1 1 1 NO CLEARING 3 1 1 NO CLEARING_CURRENT 2 1 1 NO CLEARING Elapsed: 00:00:00.03 删除原来的logfile sql > alter database drop logfile group 1; 新增logfile(要保证redolog路径存在) sql > alter database add logfile group 1 '+ARCH/testcadb/redolog/redo01.log' size 100M; sql > alter database drop logfile group 2; sql > alter database add logfile group 2 '+ARCH/testcadb/redolog/redo02.log' size 100M; sql > alter database drop logfile group 3; 提示日志无法删除 sql > alter database drop logfile group 3; alter database drop logfile group 3 * ERROR at line 1: ORA-01623: log 3 is current log for instance testcadb1 (thread 1) - cannot drop ORA-00312: online log 3 thread 1: '/home/oracle/u01/app/oracle/oradata/testcadb/redo03.log' 对文件进行重命名 sql > alter database rename file '/home/oracle/u01/app/oracle/oradata/testcadb/redo03.log' to '+ARCH/testcadb/redolog/redo03.log'; sql > alter database clear logfile group 3; 因为日志文件大小还是按原来的大小,需要重新建 sql > alter database drop logfile group 3; sql > alter database add logfile group 3 '+ARCH/testcadb/redolog/redo03.log' size 100M; 打开数据库 sql > alter database open resetlogs; 如果原库版本不一样(源库11.2.0.3目标库11.2.0.4)需要升级数据库 sql > startup mount; sql > alter database open upgrade; sql > select status from v$Instance; sql > @$ORACLE_HOME/rdbms/admin/catupgrd.sql;
启动库之后临时表空间是不可用的,需要重新配置临时表空间:
1 2 3 4 5 6
sql > select * from dba_temp_files; select * from dba_temp_files * ERROR at line 1: ORA-01157: cannot identify/lock data file 201 - see DBWR trace file ORA-01110: data file 201: '/home/oracle/u01/app/oracle/oradata/testcadb/temp01.dbf'
更换临时表空间
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
创建中转临时表空间 sql > create TEMPORARY TABLESPACE TEMP2 TEMPFILE '+DATA1/testcadb/TEMP02.DBF' SIZE 2048M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE 5120M; 切换默认临时表空间 sql > alter database default temporary tablespace temp2; sql > sql > drop tablespace temp including contents and datafiles; sql > create TEMPORARY TABLESPACE TEMP TEMPFILE '+DATA1/testcadb/TEMP01.DBF' SIZE 2048M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE 5120M; sql > alter database default temporary tablespace temp; 或者 sql > alter user *** temporary tablespace temp;(修改单独某个用户的临时表空间)
sql > drop tablespace temp2 including contents and datafiles; sql > select * from v$log; GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARCHIV STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME ---------- ---------- ---------- ---------- ---------- ---------- ------ -------------------------------- ------------- ------------------- ------------ ------------------- 1 1 25 104857600 512 1 NO INACTIVE 64817466 2018:12:19 14:19:09 64828852 2018:12:19 14:21:47 2 1 26 104857600 512 1 NO CURRENT 64828852 2018:12:19 14:21:47 2.8147E+14 3 1 24 52428800 512 1 NO INACTIVE 64807090 2018:12:19 14:18:29 64817466 2018:12:19 14:19:09
添加thread 2对应的logfile,用于分配给节点2
1 2 3
sql > alter database add logfile thread 2 group 4 '+ARCH/testcadb/redolog/redo04.log' size 100m; sql > alter database add logfile thread 2 group 5 '+ARCH/testcadb/redolog/redo05.log' size 100m; sql > alter database add logfile thread 2 group 6 '+ARCH/testcadb/redolog/redo06.log' size 100m;
启动thread2
1 2 3 4 5 6
sql > select thread#,status,enabled from v$thread; THREAD# STATUS ENABLED ---------- ------------ ---------------- 1 OPEN PUBLIC 2 CLOSED DISABLED sql > alter database enable thread 2;
配置两个节点信息
1 2 3 4 5 6
sql > alter system set thread=1 scope=spfile sid='testcadb1'; sql > alter system set thread=2 scope=spfile sid='testcadb2'; sql > alter system set instance_number=1 scope=spfile sid='testcadb1'; sql > alter system set instance_number=2 scope=spfile sid='testcadb2'; sql > alter system set cluster_database_instances=2 scope=spfile; sql > alter system set cluster_database=true scope=spfile;
为节点2添加undo表空间
1 2 3
sql > select substr(file_name,1,60) UNDO_FILES from dba_data_files where tablespace_name = 'UNDOTBS1' sql > create undo tablespace undotbs2 datafile '+data1/testcadb/undotbs02.dbf' size 200M; sql > alter system set undo_tablespace='undotbs2' scope=spfile sid='testcadb2';
关闭节点1并重新启动,如果不重新启动节点1,直接启动节点2报一下错误:
1
ORA-01102: cannot mount database in EXCLUSIVE mode
启动节点2(在节点2操作) 节点2:注意audit目录是否存在,不存在手动创建一下
1 2 3 4 5 6
shell > mkdir -p /u01/app/oracle/admin/testcadb/adump shell > export ORACLE_SID=testcadb2 shell > sqlplus / as sysdba sql > startup nomount; sql > alter database mount; sql > alter database open;
sql > show parameter remote_listener; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ remote_listener string racscan:1521 #grid用户执行: shell > lsnrctl status LISTENER_SCAN1 #如果没有注册监听信息,按下面方法配置 alter system set remote_listener = 'racscan:1521' sid='*' scope=both; alter system register; lsnrctl status LISTENER_SCAN1
14、因为恢复过来的数据库没有passwordfile,存在sys用户远程登录问题
查看remote_login_passwordfile设置值
1 2 3 4 5 6 7
sql > show parameter remote_login_passwordfile; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ remote_login_passwordfile string EXCLUSIVE
修改值使用下面方法,修改完成之后,需要重新启动数据库才能生效: alter system set remote_login_passwordfile='exclusive' scope=spfile sid='*';