之前也写过一篇类似的,虽然恢复不成问题,但总感觉有不对的地方,后面才了解到,以前自己有存在误区的地方,重新用此文方法简便得多。
环境:CentOS release 5.6 (Final)
Oracle Database Release 11.2.0.1.0
[root@OATest oabak]# tar -jxvf testoa_20140702.tar.bz2
2、还原文件
[root@OATest temp]# su - oracle
[oracle@OATest /]$ export ORACLE_SID=testoa
[oracle@OATest /]$ sqlplus "/as sysdba";
OPEN_MODE
--------------------
READ WRITE
3、关闭数据库
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
4、在sql模式下直接质数据库物理文件至相应的目录(先显示各类文件的路径所在,后拷贝到相应路径) --显示控制文件 select name from v$controlfile; --显示数据文件 select name from v$datafile; --显示延续性的初始化参数文件(延续性:对初始化参数的在线修改可以直接作用到参数文件中) show parameter spfile; --显示日志文件 select member from v$logfile; --orapw$ORACLE_SID密码文件:password file路径 在$ORACLE_HOME/dbs/orapw$ORACLE_SID //跟备份关系不大,可以随时生成。 [oracle@OATest temp]$ sqlplus "/as sysdba"; host cp /usr/oabak/temp/control01.ctl /app/oracle/oradata/testoa/control01.ctl host cp /usr/oabak/temp/control02.ctl /app/oracle/flash_recovery_area/testoa/control02.ctl host cp /usr/oabak/temp/system01.dbf /app/oracle/oradata/testoa/system01.dbf host cp /usr/oabak/temp/sysaux01.dbf /app/oracle/oradata/testoa/sysaux01.dbf host cp /usr/oabak/temp/undotbs01.dbf /app/oracle/oradata/testoa/undotbs01.dbf host cp /usr/oabak/temp/users01.dbf /app/oracle/oradata/testoa/users01.dbf host cp /usr/oabak/temp/redo03.log /app/oracle/oradata/testoa/redo03.log host cp /usr/oabak/temp/redo02.log /app/oracle/oradata/testoa/redo02.log host cp /usr/oabak/temp/redo01.log /app/oracle/oradata/testoa/redo01.log host cp /usr/oabak/temp/spfile${ORACLE_SID}.ora $ORACLE_HOME/dbs/ host cp /usr/oabak/temp/orapw${ORACLE_SID} $ORACLE_HOME/dbs/ |
--要删除临时文件, 重启的时候会自动创建temp01.dbf
若不删除临时文件,会出现下面的报错:
ORA-01187: cannot read from file because it failed verification tests
ORA-01110: data file 201: '/app/oracle/oradata/testoa/temp01.dbf'
恢复文件时候没有删除,旧的临时表空间数据文件(300MB),无法创建新的临时表空间文件(500MB) ..所以一直报错
5、启动数据库
SQL> startup ORACLE instance started. Total System Global Area 4275781632 bytes Fixed Size 2220200 bytes Variable Size 2113933144 bytes Database Buffers 2147483648 bytes Redo Buffers 12144640 bytes Database mounted. Database opened. SQL> exit |
6、修改用户密码
SQL> alter user oaadmin identified by oaadmin;
User altered.
7、解锁帐户
SQL> alter user oaadmin account unlock;
User altered.
上面第4步也可以利用一条命令直接处理:
select 'host cp /u03/backup/'||substr(name,(instr(name,'/',-1)+1))|| ' '||name from v$controlfile union all select 'host cp /u03/backup/'||substr(name,(instr(name,'/',-1)+1))|| ' '||name from v$controlfile union all select 'host cp /u03/backup/'||substr(member,(instr(member,'/',-1)+1)) ||' '||member from v$logfile union all select 'host cp /u03/backup/spfile${ORACLE_SID}.ora $ORACLE_HOME/dbs/' from dual union all select 'host cp /u03/backup/orapw${ORACLE_SID} $ORACLE_HOME/dbs/' from dual; |