数据库存储的是普通的文件系统,现在将数据库迁移到ASM存储中。
准备ASM环境:
[oracle@kel ~]$ asmcmd ASMCMD> ls ASM/ KEL/ ASMCMD>
对数据库做一个全备份,利用备份来恢复数据文件,从而达到转移存储的目的:
RMAN> run 2> { 3> backup as copy database format '+KEL'; 4> }
SQL> show parameter db_recovery_file NAME TYPE VALUE ------------------------------------ ---------------------- ------------------------------ db_recovery_file_dest string /home/oracle/flash_recovery_ar ea db_recovery_file_dest_size big integer 2G
DB_RECOVERY_FILE_DEST_SIZE specifies (in bytes) the hard limit on the total space to be used by target database recovery files created in the flash recovery area
修改参数如下:(闪回区创建在磁盘组中)
SQL> alter system set db_recovery_file_dest_size=3g scope=both; System altered. SQL> alter system set db_recovery_file_dest='+KEL' scope=both; System altered.
SQL> show parameter db_create_ NAME TYPE VALUE ------------------------------------ ---------------------- ------------------------------ db_create_file_dest string db_create_online_log_dest_1 string db_create_online_log_dest_2 string db_create_online_log_dest_3 string db_create_online_log_dest_4 string db_create_online_log_dest_5 string
DB_CREATE_FILE_DEST initializationparameter in your initialization parameter file to identify the defaultlocation for the database server to create:
Datafiles
Tempfiles
Redo log files
Control files
Block change tracking files
修改参数如下:(将联机日志和自动创建数据文件位置指定为磁盘组,并且是多路复用)
SQL> alter system set db_create_file_dest='+KEL' scope=both; System altered. SQL> alter system set db_create_online_log_dest_1='+KEL' scope=both; System altered. SQL> alter system set db_create_online_log_dest_2='+ASM' scope=both; System altered.
SQL> select group#,member from v$logfile; GROUP# MEMBER ---------- ---------------------------------------- 3 /home/oracle/oradata/ipap/redo03.log 2 /home/oracle/oradata/ipap/redo02.log 1 /home/oracle/oradata/ipap/redo01.log
添加日志组:
SQL> alter database add logfile member '+ASM','+KEL' to group 1; Database altered. SQL> alter database add logfile member '+ASM','+KEL' to group 2; Database altered.
SQL> alter database add logfile member '+ASM','+KEL' to group 3; Database altered.删除原来的联机日志组:
SQL> alter system switch logfile; System altered. SQL> alter database drop logfile member '/home/oracle/oradata/ipap/redo01.log'; Database altered. SQL> alter system switch logfile; System altered. SQL> alter database drop logfile member '/home/oracle/oradata/ipap/redo02.log'; Database altered. SQL> alter system switch logfile; System altered. SQL> alter database drop logfile member '/home/oracle/oradata/ipap/redo03.log'; Database altered.
SQL> select group#,status from v$log; GROUP# STATUS ---------- -------------------------------- 1 CURRENT 2 ACTIVE 3 ACTIVE
SQL> alter database drop standby logfile group 4; Database altered. SQL> alter database add standby logfile group 4 size 50m; Database altered.
SQL> select group#,member from v$logfile order by 1; GROUP# MEMBER ------ ------------------------------------------------ 1 +KEL/ipap/onlinelog/group_1.260.850694639 1 +ASM/ipap/onlinelog/group_1.265.850694631 2 +ASM/ipap/onlinelog/group_2.261.850694671 2 +KEL/ipap/onlinelog/group_2.262.850694685 3 +ASM/ipap/onlinelog/group_3.259.850694709 3 +KEL/ipap/onlinelog/group_3.264.850694717 4 +ASM/ipap/onlinelog/group_4.257.850695777 4 +KEL/ipap/onlinelog/group_4.275.850695773 8 rows selected.
SQL> select ts#,name from v$tempfile; TS# NAME ---------- --------------------------------------------- 3 /home/oracle/oradata/ipap/temp01.dbf
SQL> select ts#,name from v$tablespace where ts#=3; TS# NAME ---------- --------------------------------------------- 3 TEMP
SQL> alter tablespace temp add tempfile size 300m; Tablespace altered.
SQL> select name from v$tempfile; NAME --------------------------------------------- +KEL/ipap/tempfile/temp.277.850696379 /home/oracle/oradata/ipap/temp01.dbf删除旧的临时表空间文件:
SQL> alter database tempfile '/home/oracle/oradata/ipap/temp01.dbf' drop ; Database altered.再次确认临时表空间:
SQL> select name from v$tempfile; NAME --------------------------------------------- +KEL/ipap/tempfile/temp.277.850696379
查看当前控制文件位置:
SQL> show parameter control_files NAME TYPE VALUE ------------------------------------ ---------------------- ------------------------------ control_files string /home/oracle/oradata/ipap/cont rol01.ctl, /home/oracle/oradat a/ipap/control02.ctl, /home/or acle/oradata/ipap/control03.ct l
SQL> alter system set control_files='+KEL/ipap/controlfile/control01.ctl','+KEL/ipap/controlfile/control02.ctl','+KEL/ipap/controlfile/control03.ctl' scope=spfile; System altered.
SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down.
SQL> startup nomount;
首先恢复控制文件:
RMAN> restore controlfile from autobackup; Starting restore at 20-JUN-14 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=151 devtype=DISK recovery area destination: +KEL database name (or database unique name) used for search: IPAP channel ORA_DISK_1: autobackup found in the recovery area channel ORA_DISK_1: autobackup found: +kel/IPAP/AUTOBACKUP/2014_06_20/s_850696380.278.850696381 channel ORA_DISK_1: control file restore from autobackup complete output filename=+KEL/ipap/controlfile/control01.ctl output filename=+KEL/ipap/controlfile/control02.ctl output filename=+KEL/ipap/controlfile/control03.ctl Finished restore at 20-JUN-14
RMAN> alter database mount; database mounted released channel: ORA_DISK_1
RMAN> switch database to copy; Starting implicit crosscheck backup at 20-JUN-14 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=151 devtype=DISK Crosschecked 10 objects Finished implicit crosscheck backup at 20-JUN-14 Starting implicit crosscheck copy at 20-JUN-14 using channel ORA_DISK_1 Crosschecked 4 objects Finished implicit crosscheck copy at 20-JUN-14 searching for all files in the recovery area cataloging files... cataloging done List of Cataloged Files ======================= File Name: +kel/IPAP/AUTOBACKUP/2014_06_20/s_850696380.278.850696381 datafile 1 switched to datafile copy "+KEL/ipap/datafile/system.259.850692939" datafile 2 switched to datafile copy "+KEL/ipap/datafile/undotbs1.257.850693039" datafile 3 switched to datafile copy "+KEL/ipap/datafile/sysaux.258.850693003" datafile 4 switched to datafile copy "+KEL/ipap/datafile/users.256.850693045"
RMAN> recover database; Starting recover at 20-JUN-14 using channel ORA_DISK_1 starting media recovery archive log thread 1 sequence 8 is already on disk as file +KEL/ipap/archivelog/2014_06_20/thread_1_seq_8.266.850695305 archive log thread 1 sequence 9 is already on disk as file +KEL/ipap/archivelog/2014_06_20/thread_1_seq_9.267.850695485 archive log thread 1 sequence 10 is already on disk as file +KEL/ipap/archivelog/2014_06_20/thread_1_seq_10.268.850695485 archive log thread 1 sequence 11 is already on disk as file +KEL/ipap/archivelog/2014_06_20/thread_1_seq_11.269.850695489 archive log thread 1 sequence 12 is already on disk as file +KEL/ipap/archivelog/2014_06_20/thread_1_seq_12.271.850695533 archive log thread 1 sequence 13 is already on disk as file +KEL/ipap/archivelog/2014_06_20/thread_1_seq_13.273.850695551 archive log thread 1 sequence 14 is already on disk as file +ASM/ipap/onlinelog/group_1.265.850694631 archive log filename=+KEL/ipap/archivelog/2014_06_20/thread_1_seq_8.266.850695305 thread=1 sequence=8 archive log filename=+KEL/ipap/archivelog/2014_06_20/thread_1_seq_9.267.850695485 thread=1 sequence=9 archive log filename=+KEL/ipap/archivelog/2014_06_20/thread_1_seq_10.268.850695485 thread=1 sequence=10 archive log filename=+KEL/ipap/archivelog/2014_06_20/thread_1_seq_11.269.850695489 thread=1 sequence=11 archive log filename=+KEL/ipap/archivelog/2014_06_20/thread_1_seq_12.271.850695533 thread=1 sequence=12 archive log filename=+KEL/ipap/archivelog/2014_06_20/thread_1_seq_13.273.850695551 thread=1 sequence=13 archive log filename=+ASM/ipap/onlinelog/group_1.265.850694631 thread=1 sequence=14 media recovery complete, elapsed time: 00:00:04 Finished recover at 20-JUN-14
RMAN> alter database open resetlogs; database opened
控制文件:
SQL> select name from v$controlfile; NAME -------------------------------------------------------------------------------- +KEL/ipap/controlfile/control01.ctl +KEL/ipap/controlfile/control02.ctl +KEL/ipap/controlfile/control03.ctl
SQL> select name,status from v$datafile; NAME STATUS -------------------------------------------------- -------------- +KEL/ipap/datafile/system.259.850692939 SYSTEM +KEL/ipap/datafile/undotbs1.257.850693039 ONLINE +KEL/ipap/datafile/sysaux.258.850693003 ONLINE +KEL/ipap/datafile/users.256.850693045 ONLINE
SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- +KEL/ipap/onlinelog/group_4.275.850695773 +ASM/ipap/onlinelog/group_4.257.850695777 +ASM/ipap/onlinelog/group_1.265.850694631 +KEL/ipap/onlinelog/group_1.260.850694639 +ASM/ipap/onlinelog/group_2.261.850694671 +KEL/ipap/onlinelog/group_2.262.850694685 +ASM/ipap/onlinelog/group_3.259.850694709 +KEL/ipap/onlinelog/group_3.264.850694717 8 rows selected.
SQL> select name,status from v$tempfile; NAME STATUS -------------------------------------------------- -------------- +KEL/ipap/tempfile/temp.277.850696379 ONLINE