[oracle@gtser1 ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.5.0 - Production on MonFeb 25 16:41:04 2013
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and RealApplication Testing options
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +FRA
Oldest online log sequence 13
Next log sequence to archive 15
Current log sequence 15
--检查参数文件、控制文件位置
SQL> show parameter spfile;
NAME TYPE VALUE
------------------------------------ -----------------------------------------
spfile string +DATA01/gt10g/parameterfile/sp
file.268.808331735
SQL> show parameter control_files;
NAME TYPE VALUE
------------------------------------ -----------------------------------------
control_files string +DATA01/gt10g/controlfile/curr
ent.270.808328193
--备份参数文件
SQL> create pfile='/tmp/pfile1' from spfile;
File created.
--查看现有数据文件位置
SQL> select name from v$datafile
2 union all
3 select name from v$controlfile
4 union all
5 select name from v$tempfile
6 union all
7 select member from v$logfile;
NAME
--------------------------------------------------------------------------------
+DATA01/gt10g/datafile/system.271.808328265
+DATA01/gt10g/datafile/undotbs1.273.808328327
+DATA01/gt10g/datafile/sysaux.272.808328281
+DATA01/gt10g/datafile/users.269.808328331
+DATA01/gt10g/datafile/gtlions.281.808328327
+DATA01/gt10g/datafile/gtlions.256.808328331
+DATA01/gt10g/controlfile/current.270.808328193
+DATA01/gt10g/tempfile/temp.262.808328581
+DATA01/gt10g/tempfile/gtlionstemp.263.808328591
+DATA01/gt10g/onlinelog/group_4.259.808328481
+DATA01/gt10g/onlinelog/group_5.260.808328487
NAME
--------------------------------------------------------------------------------
+DATA01/gt10g/onlinelog/group_6.261.808328491
12 rows selected.
--查看OMF相关参数
SQL> show parameter db_create_file_dest;
NAME TYPE VALUE
------------------------------------ -----------------------------------------
db_create_file_dest string +data01
SQL> show parameter db_recovery_file_dest_size;
show parameter db_recovery_file_dest;
NAME TYPE VALUE
------------------------------------ -----------------------------------------
db_recovery_file_dest_size big integer 1G
SQL>
NAME TYPE VALUE
------------------------------------ -----------------------------------------
db_recovery_file_dest string +fra
db_recovery_file_dest_size big integer 1G
SQL> show parameter log_archive_dest_1;
NAME TYPE VALUE
------------------------------------ -----------------------------------------
log_archive_dest_1 string location=+fra
log_archive_dest_10 string
--清空文件系统目录
SQL> host
[oracle@gtser1 ~]$ rm -RF/u01/oracle/10g/oradata/gt10g/*
rm:无效选项 -- F
请尝试执行“rm --help”来获取更多信息。
rm:无效选项 -- F
[oracle@gtser1 ~]$ rm -Rf/u01/oracle/10g/oradata/gt10g/*
[oracle@gtser1 ~]$ ls/u01/oracle/10g/oradata/gt10g/
[oracle@gtser1 ~]$ exit
exit
--修改控制文件到文件系统
SQL> alter system setcontrol_files='/u01/oracle/10g/oradata/gt10g/control1.ctl' scope=spfile;
System altered.
--修改OMF相关参数
SQL> alter system reset db_create_file_destscope=spfile sid='*';
System altered.
SQL> alter system resetdb_recovery_file_dest_size scope=spfile sid='*';
System altered.
SQL> alter system reset db_recovery_file_destscope=spfile sid='*';
System altered.
--备份生成spfile、pfile
SQL> create pfile from spfile;
File created.
SQL> create spfile from pfile;
File created.
SQL> exit
Disconnected from Oracle Database 10g EnterpriseEdition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and RealApplication Testing options
--切换RMAN操作
[oracle@gtser1 ~]$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Productionon Mon Feb 25 16:42:41 2013
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: GT10G(DBID=2268277830)
--查看现有用户文件信息
RMAN> report schema;
using target database control file instead of recoverycatalog
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- -------------------------------
1 440 SYSTEM *** +DATA01/gt10g/datafile/system.271.808328265
2 25 UNDOTBS1 *** +DATA01/gt10g/datafile/undotbs1.273.808328327
3 250 SYSAUX *** +DATA01/gt10g/datafile/sysaux.272.808328281
4 5 USERS *** +DATA01/gt10g/datafile/users.269.808328331
5 10 GTLIONS *** +DATA01/gt10g/datafile/gtlions.281.808328327
6 10 GTLIONS *** +DATA01/gt10g/datafile/gtlions.256.808328331
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- -------------------------------
1 100 GTLIONSTEMP 100 +DATA01/gt10g/tempfile/gtlionstemp.263.808328591
2 100 TEMP 100 +DATA01/gt10g/tempfile/temp.262.808328581
--备份数据文件到文件系统
RMAN> backup as copy datafile 1 format'/u01/oracle/10g/oradata/gt10g/system01.dbf';
Starting backup at 25-FEB-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001name=+DATA01/gt10g/datafile/system.271.808328265
outputfilename=/u01/oracle/10g/oradata/gt10g/system01.dbf tag=TAG20130225T164424recid=151 stamp=808332266
channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
copying current control file
RMAN-03009: failure of backup command onORA_DISK_1 channel at 02/25/2013 16:44:28
ORA-01580: error creating control backup file/u01/oracle/10g/oradata/gt10g/system01.dbf
ORA-27038: created file already exists
Additional information: 1
continuing other job steps, job failed will notbe re-run
channel ORA_DISK_1: starting full datafilebackupset
channel ORA_DISK_1: specifying datafile(s) inbackupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 25-FEB-13
RMAN-00571:===========================================================
RMAN-00569: =============== ERROR MESSAGE STACKFOLLOWS ===============
RMAN-00571:===========================================================
RMAN-03009: failure of backup command onORA_DISK_1 channel at 02/25/2013 16:44:29
ORA-19504: failed to create file"/u01/oracle/10g/oradata/gt10g/system01.dbf"
ORA-27038: created file already exists
Additional information: 1
RMAN> backup as copy datafile 2 format'/u01/oracle/10g/oradata/gt10g/undotbs1.dbf';
Starting backup at 25-FEB-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002name=+DATA01/gt10g/datafile/undotbs1.273.808328327
outputfilename=/u01/oracle/10g/oradata/gt10g/undotbs1.dbf tag=TAG20130225T164526recid=152 stamp=808332326
channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:01
Finished backup at 25-FEB-13
RMAN> backup as copy datafile 3 format'/u01/oracle/10g/oradata/gt10g/sysaux01.dbf';
Starting backup at 25-FEB-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003name=+DATA01/gt10g/datafile/sysaux.272.808328281
outputfilename=/u01/oracle/10g/oradata/gt10g/sysaux01.dbf tag=TAG20130225T164533recid=153 stamp=808332334
channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:03
Finished backup at 25-FEB-13
RMAN> backup as copy datafile 4 format '/u01/oracle/10g/oradata/gt10g/users01.dbf';
Starting backup at 25-FEB-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004name=+DATA01/gt10g/datafile/users.269.808328331
output filename=/u01/oracle/10g/oradata/gt10g/users01.dbftag=TAG20130225T164541 recid=154 stamp=808332345
channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:07
Finished backup at 25-FEB-13
RMAN> backup as copy datafile 5 format'/u01/oracle/10g/oradata/gt10g/gtlions01.dbf';
Starting backup at 25-FEB-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005name=+DATA01/gt10g/datafile/gtlions.281.808328327
outputfilename=/u01/oracle/10g/oradata/gt10g/gtlions01.dbf tag=TAG20130225T164551recid=155 stamp=808332352
channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:01
Finished backup at 25-FEB-13
RMAN> backup as copy datafile 6 format'/u01/oracle/10g/oradata/gt10g/gtlions02.dbf';
Starting backup at 25-FEB-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00006name=+DATA01/gt10g/datafile/gtlions.256.808328331
outputfilename=/u01/oracle/10g/oradata/gt10g/gtlions02.dbf tag=TAG20130225T164556recid=156 stamp=808332356
channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:01
Finished backup at 25-FEB-13
RMAN> backup as copy current controlfileformat '/tmp/controfile1';
Starting backup at 25-FEB-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying current control file
RMAN-00571:===========================================================
RMAN-00569: =============== ERROR MESSAGE STACKFOLLOWS ===============
RMAN-00571:===========================================================
RMAN-03009: failure of backup command onORA_DISK_1 channel at 02/25/2013 16:46:02
ORA-01580: error creating control backup file/tmp/controfile1
ORA-27038: created file already exists
Additional information: 1
--备份控制文件到文件系统
RMAN> backup as copy current controlfileformat '/tmp/controfile1';
Starting backup at 25-FEB-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=/tmp/controfile1tag=TAG20130225T164617 recid=157 stamp=808332377
channel ORA_DISK_1: datafile copy complete, elapsedtime: 00:00:01
Finished backup at 25-FEB-13
--关闭数据库
RMAN> shutdown immediate;
database closed
database dismounted
Oracle instance shut down
--启动到nomount状态
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area 520093696 bytes
Fixed Size 2097496 bytes
Variable Size 138415784 bytes
Database Buffers 373293056 bytes
Redo Buffers 6287360 bytes
--还原控制文件
RMAN> restore controlfile from'/tmp/controfile1';
Starting restore at 25-FEB-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: copied control file copy
outputfilename=/u01/oracle/10g/oradata/gt10g/control1.ctl
Finished restore at 25-FEB-13
--启动数据库到mount状态
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
--切换数据文件到copy
RMAN> switch database to copy;
datafile 1 switched to datafile copy"/u01/oracle/10g/oradata/gt10g/system01.dbf"
datafile 2 switched to datafile copy"/u01/oracle/10g/oradata/gt10g/undotbs1.dbf"
datafile 3 switched to datafile copy"/u01/oracle/10g/oradata/gt10g/sysaux01.dbf"
datafile 4 switched to datafile copy"/u01/oracle/10g/oradata/gt10g/users01.dbf"
datafile 5 switched to datafile copy"/u01/oracle/10g/oradata/gt10g/gtlions01.dbf"
datafile 6 switched to datafile copy"/u01/oracle/10g/oradata/gt10g/gtlions02.dbf"
--恢复数据库
RMAN> recover database;
Starting recover at 25-FEB-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=153 devtype=DISK
starting media recovery
archive log thread 1 sequence 15 is already ondisk as file +DATA01/gt10g/onlinelog/group_6.261.808328491
archive logfilename=+DATA01/gt10g/onlinelog/group_6.261.808328491 thread=1 sequence=15
media recovery complete, elapsed time: 00:00:00
Finished recover at 25-FEB-13
--打开数据库
RMAN> alter database open resetlogs;
database opened
--切换SQL*PLUS操作
[oracle@gtser1 ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.5.0 - Production on MonFeb 25 16:53:19 2013
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and RealApplication Testing options
--迁移REDO到文件系统
SQL> alter database add logfile group 1'/u01/oracle/10g/oradata/gt10g/redo1.log' size 30m;
Database altered.
SQL> alter database add logfile group 2'/u01/oracle/10g/oradata/gt10g/redo2.log' size 30m;
Database altered.
SQL> alter database add logfile group 3'/u01/oracle/10g/oradata/gt10g/redo3.log' size 30m;
Database altered.
--删除旧REDO文件
SQL> alter database drop logfile group 4;
alter database drop logfile group 4
*
ERROR at line 1:
ORA-01623: log 4 is current log for instancegt10g (thread 1) - cannot drop
ORA-00312: online log 4 thread 1:
'+DATA01/gt10g/onlinelog/group_4.259.808328481'
SQL> alter database drop logfile group 5;
Database altered.
SQL> alter database drop logfile group 6;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> alter database drop logfile group 4;
Database altered.
--迁移TEMP到文件系统,并删除旧TEMP文件
SQL> alter tablespace temp add tempfile'/u01/oracle/10g/oradata/gt10g/temp01.dbf' size 100m;
Tablespace altered.
SQL> alter tablespace temp drop tempfile'+DATA01/gt10g/tempfile/temp.262.808328581';
Tablespace altered.
SQL> alter tablespace gtlionstemp add tempfile'/u01/oracle/10g/oradata/gt10g/gtlionstemp01.dbf' size 100m;
Tablespace altered.
SQL> alter tablespace gtlionstemp droptempfile '+DATA01/gt10g/tempfile/gtlionstemp.263.808328591';
Tablespace altered.
--检查迁移结果
SQL> Select Name
2 From V$datafile
3 Union All
4 Select Name
5 From V$controlfile
6 Union All
7 Select Name
8 From V$tempfile
9 Union All
10 Select Member From V$logfile;
NAME
--------------------------------------------------------------------------------
/u01/oracle/10g/oradata/gt10g/system01.dbf
/u01/oracle/10g/oradata/gt10g/undotbs1.dbf
/u01/oracle/10g/oradata/gt10g/sysaux01.dbf
/u01/oracle/10g/oradata/gt10g/users01.dbf
/u01/oracle/10g/oradata/gt10g/gtlions01.dbf
/u01/oracle/10g/oradata/gt10g/gtlions02.dbf
/u01/oracle/10g/oradata/gt10g/control1.ctl
/u01/oracle/10g/oradata/gt10g/gtlionstemp01.dbf
/u01/oracle/10g/oradata/gt10g/temp01.dbf
/u01/oracle/10g/oradata/gt10g/redo1.log
/u01/oracle/10g/oradata/gt10g/redo2.log
NAME
--------------------------------------------------------------------------------
/u01/oracle/10g/oradata/gt10g/redo3.log
12 rows selected.
SQL> show parameter spfile;
NAME TYPE VALUE
------------------------------------ -----------------------------------------
spfile string /u01/oracle/10g/product/10.2.0
/db_1/dbs/spfilegt10g.ora
RMAN> report schema;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- -------------------------------
1 440 SYSTEM *** /u01/oracle/10g/oradata/gt10g/system01.dbf
2 25 UNDOTBS1 *** /u01/oracle/10g/oradata/gt10g/undotbs1.dbf
3 250 SYSAUX *** /u01/oracle/10g/oradata/gt10g/sysaux01.dbf
4 5 USERS *** /u01/oracle/10g/oradata/gt10g/users01.dbf
5 10 GTLIONS *** /u01/oracle/10g/oradata/gt10g/gtlions01.dbf
6 10 GTLIONS *** /u01/oracle/10g/oradata/gt10g/gtlions02.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- -------------------------------
2 100 GTLIONSTEMP 100 /u01/oracle/10g/oradata/gt10g/gtlionstemp01.dbf
3 100 TEMP 100 /u01/oracle/10g/oradata/gt10g/temp01.dbf
-The End-