使用裸设备配置ASM实例
http://www.cnblogs.com/myrunning/p/4270849.html
1.查看我们创建的磁盘组
[[email protected] ~]$ export ORACLE_SID=+ASM [[email protected] ~]$ sqlplus ‘/as sysdba‘ SQL*Plus: Release 10.2.0.4.0 - Production on Mon Feb 2 13:37:25 2015 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> select name,total_mb,free_mb from v$asm_diskgroup; NAME TOTAL_MB FREE_MB ------------------------------ ---------- ---------- DATA 4094 4042 FLA 4094 4042
2.启动数据库实例查看数据文件等
SQL> select * from v$dbfile; FILE# NAME ---------- -------------------------------------------------- 4 /u02/app/oradata/ZDJS/users01.dbf 3 /u02/app/oradata/ZDJS/sysaux01.dbf 2 /u02/app/oradata/ZDJS/undotbs01.dbf 1 /u02/app/oradata/ZDJS/system01.dbf 5 /u02/app/oradata/ZDJS/example01.dbf 6 /u02/app/oradata/ZDJS/rlsc01.dbf 6 rows selected. SQL> select file#,name from v$tempfile; FILE# NAME ---------- -------------------------------------------------- 1 /u02/app/oradata/ZDJS/temp01.dbf SQL> show parameter control_ NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_file_record_keep_time integer 7 control_files string /u02/app/oradata/ZDJS/control0 1.ctl, /u02/app/oradata/ZDJS/c ontrol02.ctl, /u02/app/oradata /ZDJS/control03.ctl SQL> show parameter spfile NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ spfile string /u02/app/product/10.2.0/db_1/d bs/spfileZDJS.ora SQL> select group#,member from v$logfile; GROUP# MEMBER ---------- -------------------------------------------------- 3 /u02/app/oradata/ZDJS/redo03.log 2 /u02/app/oradata/ZDJS/redo02.log 1 /u02/app/oradata/ZDJS/redo01.log
3.对RDBMS做一个备份
[[email protected] ~]$ rman target / Recovery Manager: Release 10.2.0.4.0 - Production on Mon Feb 2 13:54:00 2015 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: ZDJS (DBID=3501190711) RMAN> backup as copy database format ‘+DATA‘; Starting backup at 02-FEB-15 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=144 devtype=DISK channel ORA_DISK_1: starting datafile copy input datafile fno=00001 name=/u02/app/oradata/ZDJS/system01.dbf output filename=+DATA/zdjs/datafile/system.256.870616471 tag=TAG20150202T135428 recid=3 stamp=870616521 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:55 channel ORA_DISK_1: starting datafile copy input datafile fno=00002 name=/u02/app/oradata/ZDJS/undotbs01.dbf output filename=+DATA/zdjs/datafile/undotbs1.257.870616525 tag=TAG20150202T135428 recid=4 stamp=870616567 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:46 channel ORA_DISK_1: starting datafile copy input datafile fno=00003 name=/u02/app/oradata/ZDJS/sysaux01.dbf output filename=+DATA/zdjs/datafile/sysaux.258.870616569 tag=TAG20150202T135428 recid=5 stamp=870616596 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35 channel ORA_DISK_1: starting datafile copy input datafile fno=00005 name=/u02/app/oradata/ZDJS/example01.dbf output filename=+DATA/zdjs/datafile/example.259.870616605 tag=TAG20150202T135428 recid=6 stamp=870616616 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile copy input datafile fno=00006 name=/u02/app/oradata/ZDJS/rlsc01.dbf output filename=+DATA/zdjs/datafile/rlsc.260.870616621 tag=TAG20150202T135428 recid=7 stamp=870616629 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile copy input datafile fno=00004 name=/u02/app/oradata/ZDJS/users01.dbf output filename=+DATA/zdjs/datafile/users.261.870616635 tag=TAG20150202T135428 recid=8 stamp=870616636 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting datafile copy copying current control file output filename=+DATA/zdjs/controlfile/backup.262.870616639 tag=TAG20150202T135428 recid=9 stamp=870616641 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset including current SPFILE in backupset channel ORA_DISK_1: starting piece 1 at 02-FEB-15 channel ORA_DISK_1: finished piece 1 at 02-FEB-15 piece handle=+DATA/zdjs/backupset/2015_02_02/nnsnf0_tag20150202t135428_0.263.870616647 tag=TAG20150202T135428 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 Finished backup at 02-FEB-15
4.修改RDBMS参数
SQL> alter system set db_recovery_file_dest_size=3g scope=both; System altered. SQL> alter system set db_recovery_file_dest=‘+FLA‘ scope=both; System altered. SQL> alter system set db_create_file_dest=‘+DATA‘ scope=both; System altered. SQL> alter system set db_create_online_log_dest_1=‘+DATA‘ scope=spfile; System altered.
5.迁移联机日志到ASM磁盘
SQL> select a.group#,a.status,b.member from v$log a,v$logfile b 2 where a.group#=b.group#; GROUP# STATUS MEMBER ---------- ---------------- -------------------------------------------------- 3 INACTIVE /u02/app/oradata/ZDJS/redo03.log 2 INACTIVE /u02/app/oradata/ZDJS/redo02.log 1 CURRENT /u02/app/oradata/ZDJS/redo01.log SQL> alter database add logfile member ‘+DATA‘,‘+FLA‘ to group 1; Database altered. SQL> alter database add logfile member ‘+DATA‘,‘+FLA‘ to group 2; Database altered. SQL> alter database add logfile member ‘+DATA‘,‘+FLA‘ to group 3; Database altered. SQL> select a.group#,a.status,b.member from v$log a,v$logfile b 2 where a.group#=b.group#; GROUP# STATUS MEMBER ---------- ---------------- -------------------------------------------------- 3 INACTIVE /u02/app/oradata/ZDJS/redo03.log 2 INACTIVE /u02/app/oradata/ZDJS/redo02.log 1 CURRENT /u02/app/oradata/ZDJS/redo01.log 1 CURRENT +DATA/zdjs/onlinelog/group_1.264.870617701 1 CURRENT +FLA/zdjs/onlinelog/group_1.256.870617713 2 INACTIVE +DATA/zdjs/onlinelog/group_2.265.870617759 2 INACTIVE +FLA/zdjs/onlinelog/group_2.257.870617769 3 INACTIVE +DATA/zdjs/onlinelog/group_3.266.870618057 3 INACTIVE +FLA/zdjs/onlinelog/group_3.258.870618067 9 rows selected.
删除原来的状态为INACTIVE的联机日志,通过alter system switch logfile;命令切换日志
SQL> alter database drop logfile member ‘/u02/app/oradata/ZDJS/redo01.log‘; Database altered. SQL> alter database drop logfile member ‘/u02/app/oradata/ZDJS/redo02.log‘; Database altered. SQL> alter database drop logfile member ‘/u02/app/oradata/ZDJS/redo03.log‘; Database altered. SQL> select a.group#,a.status,b.member from v$log a,v$logfile b 2 where a.group#=b.group# order by group#; GROUP# STATUS MEMBER ---------- ---------------- -------------------------------------------------- 1 CURRENT +DATA/zdjs/onlinelog/group_1.264.870617701 1 CURRENT +FLA/zdjs/onlinelog/group_1.256.870617713 2 INACTIVE +DATA/zdjs/onlinelog/group_2.265.870617759 2 INACTIVE +FLA/zdjs/onlinelog/group_2.257.870617769 3 INACTIVE +DATA/zdjs/onlinelog/group_3.266.870618057 3 INACTIVE +FLA/zdjs/onlinelog/group_3.258.870618067 6 rows selected.
6.迁移临时表空间到ASM磁盘
SQL> select tablespace_name,file_name,bytes/1024/1024 size_m 2 from dba_temp_files; TABLESPACE_NAME FILE_NAME SIZE_M -------------------- ---------------------------------------- ---------- TEMP /u02/app/oradata/ZDJS/temp01.dbf 30 SQL> alter tablespace temp add tempfile size 100m; Tablespace altered. SQL> select tablespace_name,file_name,bytes/1024/1024 size_m 2 from dba_temp_files; TABLESPACE_NAME FILE_NAME SIZE_M -------------------- ---------------------------------------- ---------- TEMP +DATA/zdjs/tempfile/temp.267.870619111 100 TEMP /u02/app/oradata/ZDJS/temp01.dbf 30 SQL> alter database tempfile ‘/u02/app/oradata/ZDJS/temp01.dbf‘ drop ; Database altered. SQL> select tablespace_name,file_name,bytes/1024/1024 size_m 2 from dba_temp_files; TABLESPACE_NAME FILE_NAME SIZE_M -------------------- ---------------------------------------- ---------- TEMP +DATA/zdjs/tempfile/temp.267.870619111 100
7.迁移控制文件、数据文件到ASM磁盘
在整个迁移过程中,只有这一步需要对数据库实例进行关闭、启动;这一步实际就是一个完全恢复的过程。
SQL> show parameter control NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_file_record_keep_time integer 7 control_files string /u02/app/oradata/ZDJS/control0 1.ctl, /u02/app/oradata/ZDJS/c ontrol02.ctl, /u02/app/oradata /ZDJS/control03.ctl SQL> alter system set control_files=‘+DATA/ZDJS/CONTROLFILE/control01.ctl‘, 2 ‘+DATA/ZDJS/CONTROLFILE/control02.ctl‘,‘+DATA/ZDJS/CONTROLFILE/control03.ctl‘ 3 scope=spfile; System altered. SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup nomount ORACLE instance started. Total System Global Area 608174080 bytes Fixed Size 1268896 bytes Variable Size 197133152 bytes Database Buffers 402653184 bytes Redo Buffers 7118848 bytes
把数据库启动到nomount状态后使用rman进行恢复:
[[email protected] ~]$ rman target / Recovery Manager: Release 10.2.0.4.0 - Production on Mon Feb 2 14:55:01 2015 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: ZDJS (not mounted) RMAN> restore controlfile from ‘/u02/app/oradata/ZDJS/control01.ctl‘; Starting restore at 02-FEB-15 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=155 devtype=DISK channel ORA_DISK_1: copied control file copy output filename=+DATA/zdjs/controlfile/control01.ctl output filename=+DATA/zdjs/controlfile/control02.ctl output filename=+DATA/zdjs/controlfile/control03.ctl Finished restore at 02-FEB-15
使用rman从最近的控制文件直接恢复控制文件,我们使用asmcmd工具确认一下恢复的控制文件是否存在:
ASMCMD> pwd +DATA/ZDJS/CONTROLFILE ASMCMD> ls Backup.262.870616639 control01.ctl control02.ctl control03.ctl current.268.870620187 current.269.870620189 current.270.870620189
mount数据库后使用rman switch数据库:
SQL> alter database mount; Database altered.
[[email protected] ~]$ rman target / Recovery Manager: Release 10.2.0.4.0 - Production on Mon Feb 2 15:00:57 2015 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: ZDJS (DBID=3501190711, not open) RMAN> list copy; using target database control file instead of recovery catalog List of Datafile Copies Key File S Completion Time Ckp SCN Ckp Time Name ------- ---- - --------------- ---------- --------------- ---- 3 1 A 02-FEB-15 901700 02-FEB-15 +DATA/zdjs/datafile/system.256.870616471 4 2 A 02-FEB-15 901709 02-FEB-15 +DATA/zdjs/datafile/undotbs1.257.870616525 5 3 A 02-FEB-15 901720 02-FEB-15 +DATA/zdjs/datafile/sysaux.258.870616569 8 4 A 02-FEB-15 901739 02-FEB-15 +DATA/zdjs/datafile/users.261.870616635 6 5 A 02-FEB-15 901731 02-FEB-15 +DATA/zdjs/datafile/example.259.870616605 7 6 A 02-FEB-15 901735 02-FEB-15 +DATA/zdjs/datafile/rlsc.260.870616621 List of Control File Copies Key S Completion Time Ckp SCN Ckp Time Name ------- - --------------- ---------- --------------- ---- 9 A 02-FEB-15 901740 02-FEB-15 +DATA/zdjs/controlfile/backup.262.870616639 2 A 02-FEB-15 901040 02-FEB-15 +DATA/zdjs/controlfile/backup.256.870616081 List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - --------- ---- 1 1 35 A 20-JAN-15 /u02/ZDJS_ARCH/1_35_869134589.dbf 2 1 36 A 02-FEB-15 /u02/ZDJS_ARCH/1_36_869134589.dbf 3 1 37 A 02-FEB-15 /u02/ZDJS_ARCH/1_37_869134589.dbf 4 1 38 A 02-FEB-15 /u02/ZDJS_ARCH/1_38_869134589.dbf 5 1 39 A 02-FEB-15 /u02/ZDJS_ARCH/1_39_869134589.dbf 6 1 40 A 02-FEB-15 /u02/ZDJS_ARCH/1_40_869134589.dbf 7 1 41 A 02-FEB-15 /u02/ZDJS_ARCH/1_41_869134589.dbf 8 1 42 A 02-FEB-15 /u02/ZDJS_ARCH/1_42_869134589.dbf 9 1 43 A 02-FEB-15 /u02/ZDJS_ARCH/1_43_869134589.dbf RMAN> switch database to copy; datafile 1 switched to datafile copy "+DATA/zdjs/datafile/system.256.870616471" datafile 2 switched to datafile copy "+DATA/zdjs/datafile/undotbs1.257.870616525" datafile 3 switched to datafile copy "+DATA/zdjs/datafile/sysaux.258.870616569" datafile 4 switched to datafile copy "+DATA/zdjs/datafile/users.261.870616635" datafile 5 switched to datafile copy "+DATA/zdjs/datafile/example.259.870616605" datafile 6 switched to datafile copy "+DATA/zdjs/datafile/rlsc.260.870616621" RMAN> recover database; --切换后现在使用的是磁盘组里的备份文件,所有我们需要进行恢复 Starting recover at 02-FEB-15 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=151 devtype=DISK starting media recovery archive log thread 1 sequence 35 is already on disk as file /u02/ZDJS_ARCH/1_35_869134589.dbf archive log thread 1 sequence 36 is already on disk as file /u02/ZDJS_ARCH/1_36_869134589.dbf archive log thread 1 sequence 37 is already on disk as file /u02/ZDJS_ARCH/1_37_869134589.dbf archive log thread 1 sequence 38 is already on disk as file /u02/ZDJS_ARCH/1_38_869134589.dbf archive log thread 1 sequence 39 is already on disk as file /u02/ZDJS_ARCH/1_39_869134589.dbf archive log thread 1 sequence 40 is already on disk as file /u02/ZDJS_ARCH/1_40_869134589.dbf archive log thread 1 sequence 41 is already on disk as file /u02/ZDJS_ARCH/1_41_869134589.dbf archive log thread 1 sequence 42 is already on disk as file /u02/ZDJS_ARCH/1_42_869134589.dbf archive log thread 1 sequence 43 is already on disk as file /u02/ZDJS_ARCH/1_43_869134589.dbf archive log filename=/u02/ZDJS_ARCH/1_35_869134589.dbf thread=1 sequence=35 archive log filename=/u02/ZDJS_ARCH/1_36_869134589.dbf thread=1 sequence=36 archive log filename=/u02/ZDJS_ARCH/1_37_869134589.dbf thread=1 sequence=37 archive log filename=/u02/ZDJS_ARCH/1_38_869134589.dbf thread=1 sequence=38 archive log filename=/u02/ZDJS_ARCH/1_39_869134589.dbf thread=1 sequence=39 archive log filename=/u02/ZDJS_ARCH/1_40_869134589.dbf thread=1 sequence=40 archive log filename=/u02/ZDJS_ARCH/1_41_869134589.dbf thread=1 sequence=41 media recovery complete, elapsed time: 00:00:06 Finished recover at 02-FEB-15 RMAN> alter database open; database opened
8.验证迁移后的文件
SQL> select * from v$dbfile; FILE# NAME ---------- -------------------------------------------------- 4 +DATA/zdjs/datafile/users.261.870616635 3 +DATA/zdjs/datafile/sysaux.258.870616569 2 +DATA/zdjs/datafile/undotbs1.257.870616525 1 +DATA/zdjs/datafile/system.256.870616471 5 +DATA/zdjs/datafile/example.259.870616605 6 +DATA/zdjs/datafile/rlsc.260.870616621 6 rows selected. SQL> select file#,name from v$tempfile; FILE# NAME ---------- -------------------------------------------------- 2 +DATA/zdjs/tempfile/temp.267.870619111 SQL> show parameter control_ NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_file_record_keep_time integer 7 control_files string +DATA/zdjs/controlfile/control 01.ctl, +DATA/zdjs/controlfile /control02.ctl, +DATA/zdjs/con trolfile/control03.ctl SQL> select group#,member from v$logfile; GROUP# MEMBER ---------- -------------------------------------------------- 1 +DATA/zdjs/onlinelog/group_1.264.870617701 1 +FLA/zdjs/onlinelog/group_1.256.870617713 2 +DATA/zdjs/onlinelog/group_2.265.870617759 2 +FLA/zdjs/onlinelog/group_2.257.870617769 3 +DATA/zdjs/onlinelog/group_3.266.870618057 3 +FLA/zdjs/onlinelog/group_3.258.870618067 6 rows selected.
#ASM和OS文件系统之间交换可以使用dbms_file_transfer包或rman的convert方法
时间: 2024-10-09 23:22:45