1、接上一步骤,备份控制文件
alter database backup controlfile to trace resetlogs;
2、关库
shutdown immediate;
exit
3、进入控制文件备份目录
cd /u01/app/oracle/diag/rdbms/testdb2/testdb2/trace/
tail -200 alert_testdb2.log
找到下面这句话:
alter database backup controlfile to trace resetlogs
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/testdbutf8/testdb2/trace/testdb2_ora_20847.trc
Completed: alter database backup controlfile to trace resetlogs
4、复制一份备份文件
cp testdb2_ora_20847.trc testdb2.sql
5、编辑testdb2.sql
去掉多余部分,替换所有testdbutf8为testdb2
把CREATE CONTROLFILE REUSE 改为 CREATE CONTROLFILE SET
注释掉 --RECOVER DATABASE USING BACKUP CONTROLFILE
最终结果如下:
vi testdb2.sql
STARTUP NOMOUNT
CREATE CONTROLFILE SET DATABASE "TESTDB2" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oradata/datafile/testdb2/redo01.log' SIZE 500M BLOCKSIZE 512,
GROUP 2 '/oradata/datafile/testdb2/redo02.log' SIZE 500M BLOCKSIZE 512,
GROUP 3 '/oradata/datafile/testdb2/redo03.log' SIZE 500M BLOCKSIZE 512,
GROUP 4 '/oradata/datafile/testdb2/redo04.log' SIZE 500M BLOCKSIZE 512,
GROUP 5 '/oradata/datafile/testdb2/redo05.log' SIZE 500M BLOCKSIZE 512
DATAFILE
'/oradata/datafile/testdb2/system01.dbf',
'/oradata/datafile/testdb2/sysaux01.dbf',
'/oradata/datafile/testdb2/undotbs01.dbf',
'/oradata/datafile/testdb2/users01.dbf'
CHARACTER SET AL32UTF8
;
--RECOVER DATABASE USING BACKUP CONTROLFILE
ALTER DATABASE OPEN RESETLOGS;
ALTER TABLESPACE TEMP ADD TEMPFILE '/oradata/datafile/testdb2/temp01.dbf'
SIZE 61865984 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
6、生成pfile
sqlplus / as sysdba
create pfile='?/dbs/inittestdb2.ora' from spfile;
7、修改目录
--闪回恢复区
cd /u01/app/oracle/fast_recovery_area
mv testdbutf8 testdb2
mv TESTDBUTF8 TESTDB2
--数据文件目录
cd /oradata/datafile
mv testdbutf8 testdb2
--日志文件目录
cd /u01/app/oracle/diag/rdbms
mv testdbutf8 testdb2
cd /u01/app/oracle/admin
mv testdbutf8 testdb2
8、备份老控制文件
cd /oradata/datafile/testdb2
mv control01.ctl control01.ctl.bak
cd /u01/app/oracle/fast_recovery_area/testdb2
mv control02.ctl control02.ctl.bak