4. 将数据库由文件系统迁移到ASM
(1) 添加和修改初始化参数
查看存在的ASM磁盘组:
[Oracle@rac1 dbs]$ export ORACLE_SID=+ASM1
[oracle@rac1 dbs]$ sqlplus / as sysdba
SQL> select name from v$asm_diskgroup;
NAME
------------------------------
DATA
FRA
SQL>
修改和添加初始化参数:
[oracle@rac1 dbs]$ vi $ORACLE_HOME/dbs/initorcl1.ora
将
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
变为
*.db_recovery_file_dest='+FRA'
添加:
*.db_create_file_dest='+DATA'
(2) 创建SPFILE
从pfile中清除 *.control_files,然后创建spfile
[oracle@rac1 dbs]$ vi $ORACLE_HOME/dbs/initorcl1.ora
删除control_files这一行
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/oradata/orcl/control02.ctl','/u01/app/oracle/oradata/orcl/control03.ctl'
[oracle@rac1 dbs]$ export ORACLE_SID=orcl1
[oracle@rac1 dbs]$ sqlplus "/as sysdba"
Connected to an idle instance.
SQL> create spfile from pfile;
File created.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 608174080 bytes
Fixed Size 1275128 bytes
Variable Size 163580680 bytes
Database Buffers 440401920 bytes
Redo Buffers 2916352 bytes
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
[oracle@rac1 dbs]$
(3) 恢复数据库
[oracle@rac1 dbs]$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Wed Nov 14 14:52:12 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: orcl (not mounted)
RMAN> restore controlfile from '/u02/backup_db/ORCL_25_798936484_1_full_ctl.bus';
Starting restore at 14-NOV-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=150 instance=orcl1 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
output filename=+DATA/orcl/controlfile/current.395.799339993
output filename=+FRA/orcl/controlfile/current.289.799339995
Finished restore at 14-NOV-12
RMAN>
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> report schema;
Starting implicit crosscheck backup at 14-NOV-12
allocated channel: ORA_DISK_1
Crosschecked 6 objects
Finished implicit crosscheck backup at 14-NOV-12
Starting implicit crosscheck copy at 14-NOV-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 14-NOV-12
searching for all files in the recovery area
cataloging files...
no files cataloged
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 0 SYSTEM *** /u01/app/oracle/oradata/orcl/system01.dbf
2 0 UNDOTBS1 *** /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 0 SYSAUX *** /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 0 USERS *** /u01/app/oracle/oradata/orcl/users01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /u01/app/oracle/oradata/orcl/temp01.dbf
RMAN>
根据上面的输出,我们可以看到单节点的数据库,以前的数据文件的存放路径;我们要对其进行修改,让其数据文件存放到磁盘组中,在RMAN中执行下面的语句。
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
set newname for datafile 1 to '+DATA';
set newname for datafile 2 to '+DATA';
set newname for datafile 3 to '+DATA';
set newname for datafile 4 to '+DATA';
restore database;
}
RMAN> run {
2> allocate channel d1 type disk;
3> allocate channel d2 type disk;
4> allocate channel d3 type disk;
5>
6> set newname for datafile 1 to '+DATA';
7> set newname for datafile 2 to '+DATA';
8> set newname for datafile 3 to '+DATA';
9> set newname for datafile 4 to '+DATA';
10> restore database;
11> }
released channel: ORA_DISK_1
allocated channel: d1
channel d1: sid=150 instance=orcl1 devtype=DISK
allocated channel: d2
channel d2: sid=146 instance=orcl1 devtype=DISK
allocated channel: d3
channel d3: sid=145 instance=orcl1 devtype=DISK
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 14-NOV-12
channel d1: starting datafile backupset restore
channel d1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to +DATA
restoring datafile 00003 to +DATA
channel d1: reading from backup piece /u02/backup_db/ORCL_21_798936465_1_full_db.bus
channel d2: starting datafile backupset restore
channel d2: specifying datafile(s) to restore from backup set
restoring datafile 00001 to +DATA
restoring datafile 00004 to +DATA
channel d2: reading from backup piece /u02/backup_db/ORCL_20_798936465_1_full_db.bus
channel d1: restored backup piece 1
piece handle=/u02/backup_db/ORCL_21_798936465_1_full_db.bus tag=FULL_DB_BK
channel d1: restore complete, elapsed time: 00:00:26
channel d2: restored backup piece 1
piece handle=/u02/backup_db/ORCL_20_798936465_1_full_db.bus tag=FULL_DB_BK
channel d2: restore complete, elapsed time: 00:00:41
Finished restore at 14-NOV-12
released channel: d1
released channel: d2
released channel: d3
RMAN>
RMAN> switch database to copy;
datafile 1 switched to datafile copy "+DATA/orcl/datafile/system.401.799340335"
datafile 2 switched to datafile copy "+DATA/orcl/datafile/undotbs1.330.799340335"
datafile 3 switched to datafile copy "+DATA/orcl/datafile/sysaux.416.799340333"
datafile 4 switched to datafile copy "+DATA/orcl/datafile/users.351.799340335"
RMAN> recover database;
Starting recover at 14-NOV-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=150 instance=orcl1 devtype=DISK
starting media recovery
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=16
channel ORA_DISK_1: reading from backup piece /u02/backup_db/ORCL_24_798936483_1_full_arch.bus
channel ORA_DISK_1: restored backup piece 1
piece handle=/u02/backup_db/ORCL_24_798936483_1_full_arch.bus tag=FULL_DB_BK
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archive log filename=+FRA/orcl/archivelog/2012_11_14/thread_1_seq_16.290.799340411 thread=1 sequence=16
channel default: deleting archive log(s)
archive log filename=+FRA/orcl/archivelog/2012_11_14/thread_1_seq_16.290.799340411 recid=19 stamp=799340412
unable to find archive log
archive log thread=1 sequence=17
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/14/2012 15:00:19
RMAN-06054: media recovery requesting unknown log: thread 1 seq 17 lowscn 417407
RMAN> exit
Recovery Manager complete.
[oracle@rac1 dbs]$