11gR1版本 asmcmd的新命令--cp、md_backup、md_restore
参考原文:
ASMCMD - New commands in 11gR1 (Doc ID 451900.1)
适用于:
Oracle Database - Enterprise Edition - Version 11.1.0.6 to 11.1.0.7 [Release 11.1]
Information in this document applies to any platform.
***Checked for relevance on 02-Jan-2013***
目的:
oracle 已经为asmcmd命令引入了3个新功能:以提高 crash和 修复坏块时的节点可恢复性;拷贝文件;在asm磁盘组中list asm磁盘
asmcmd 也能用于 asm磁盘组元数据的backup 和restore。
这提供了创建 一个 与 预先已经存在的磁盘组使用 相同的磁盘路径,磁盘名称,故障组,属性,模板和别名目录结构 的 磁盘组的方法。
范围:
asmcmd中引入的新功能。
细节:
第一个:ASMCMD cp command
asmcmd cp命令允许你在文件系统和 asm磁盘组之间拷贝文件,cp也能用于2个asm 磁盘组之间拷贝。
- ASM Diskgroup to OS file system
- OS file system to ASM Diskgroup
- ASM Diskgroup to another diskgroup
ASM Diskgroup to OS File system
ASMCMD> cp +DGEXT/orcl/datafile/tbsext.256.628847401 /home/oracle/tbsext.dbf
source +DGEXT/orcl/datafile/tbsext.256.628847401
target /home/oracle/tbsext.dbf
copying file(s)...
file, /home/oracle/tbsext.dbf, copy committed.
OS File system to ASM Diskgroup
ASMCMD> cp /home/oracle/tbsext.dbf +DGEXTBK/prod/datafile/tbsext.dbf
source /home/oracle/tbsext.dbf
target +DGEXTBK/prod/datafile/tbsext.dbf
copying file(s)...
file, +DGEXTBK/prod/datafile/tbsext.dbf, copy committed.
ASM Diskgroup to another diskgroup
SQL> create diskgroup dgext external redundancy disk ‘/dev/raw/raw1‘,‘/dev
/raw/raw2‘;
Diskgroup created.
SQL> create diskgroup DGEXTBK external redundancy disk ‘/dev/raw/raw3‘,‘/dev/raw /raw4‘;
Diskgroup created.
ASMCMD> cd DGEXTBK
ASMCMD> mkdir prod
ASMCMD> cd prod
ASMCMD> mkdir datafile
ASMCMD> cd datafile
ASMCMD> pwd
+DGEXTBK/prod/datafile
SQL> create tablespace TBSEXT datafile ‘+DGEXT‘ size 10m;
Tablespace created.
SQL> select name from v$datafile;
NAME
-------------------------------------------------------------
+DGEXT/orcl/datafile/tbsext.256.628847401
cp +DGEXT/orcl/datafile/tbsext.256.628847401 +DGEXTBK/prod/datafile/tbsext
ASMCMD> cp +DGEXT/orcl/datafile/tbsext.256.628847401 +DGEXTBK/prod/datafile/tbsext
source +DGEXT/orcl/datafile/tbsext.256.628847401
target +DGEXTBK/prod/datafile/tbsext
copying file(s)...file, +DGEXTBK/prod/datafile/tbsext, copy committed.
The tbsext is alias name created in the folder +DGEXTBK/prod/datafile.
Refer Note 452158.1 ASMCMD cp command fails with ORA-15046
第二个: ASMCMD md_backup and md_restore
用于备份和恢复asm磁盘组的元数据,这提供了一个能力---重建一个与 已经存在的asm磁盘组有着相同磁盘路径,磁盘名称,故障组,属性,模板和别名目录结构的磁盘组
在oracle10g中,如果磁盘组丢失,那么唯一的可能是使用rman 来restore 都是的file,在这之前,需要手动重建asm磁盘组和相关的目录、模板
在oracle11g中,我们可以对asm磁盘组的元数据做备份。
md_backup命令建立了包括一个或者多个磁盘组元数据的备份文件。
默认情况下,所有的mounted磁盘组都会被包括在该备份文件中,该备份文件放在当前的工作目录下。
如果备份文件的名字不指定,那么asm 会将此文件命名为AMBR_BACKUP_INTERMEDIATE_FILE.
--->如下是备份dgext磁盘组元数据的命令
ASMCMD> md_backup -b dgbk -g dgext
Disk group to be backed up: DGEXT
在restore模式下,oracle读取之前生成的file,来重建磁盘组和元数据。
有不同的restore模式:full,nodg,newdg
full mode restore 磁盘组到它备份的时候
ASMCMD> md_restore -b dgbk -t full -g dgext
Current Diskgroup being restored: DGEXT
ASMCMD-09352: CREATE DISKGROUP failed
ORA-15018: diskgroup cannot be created
ORA-15030: diskgroup name "DGEXT" is in use by another diskgroup (DBD ERROR: OCIStmtExecute) --->可以看到,已经使用的磁盘组不能restore
SQL> drop diskgroup dgext;
Diskgroup dropped.
ASMCMD> md_restore -b dgbk -t full -g dgext
Current Diskgroup being restored: DGEXT
Diskgroup DGEXT created!
System template XTRANSPORT modified!
System template ONLINELOG modified!
System template DATAGUARDCONFIG modified!
System template AUTOBACKUP modified!
System template TEMPFILE modified!
System template ARCHIVELOG modified!
System template ASM_STALE modified!
System template BACKUPSET modified!
System template DUMPSET modified!
System template FLASHBACK modified!
System template PARAMETERFILE modified!
System template CONTROLFILE modified!
System template DATAFILE modified!
System template CHANGETRACKING modified!
SQL> select group_number,name,type from v$asm_diskgroup;
GROUP_NUMBER NAME TYPE
------------ -------------------- ------
1 DGEXT EXTERN
nodg模式 restore 备份文件中的 属性,模板 和别名目录结构 到一个存在的磁盘组中。
ASMCMD> md_restore -b dgbk -t nodg -g dgext
Current Diskgroup being restored: DGEXT
System template XTRANSPORT modified!
System template ONLINELOG modified!
System template DATAGUARDCONFIG modified!
System template AUTOBACKUP modified!
System template TEMPFILE modified!
System template ARCHIVELOG modified!
System template ASM_STALE modified!
System template BACKUPSET modified!
System template DUMPSET modified!
System template FLASHBACK modified!
System template PARAMETERFILE modified!
System template CONTROLFILE modified!
System template DATAFILE modified!
System template CHANGETRACKING modified!
newdg 模式 允许 用户覆盖 磁盘组名字,磁盘,故障组设置,但是会保留属性,模板和 别名目录结构。
ASMCMD> md_restore -b dgbk -t newdg -o ‘DGEXT:DG‘
Current Diskgroup being restored: DGEXT
Current Diskgroup name replace by: DG
Diskgroup DG created!
System template XTRANSPORT modified!
System template ONLINELOG modified!
System template DATAGUARDCONFIG modified!
System template AUTOBACKUP modified!
System template TEMPFILE modified!
System template ARCHIVELOG modified!
System template ASM_STALE modified!
System template BACKUPSET modified!
System template DUMPSET modified!
System template FLASHBACK modified!
System template PARAMETERFILE modified!
System template CONTROLFILE modified!
System template DATAFILE modified!
System template CHANGETRACKING modified!
SQL> select group_number,name,type from v$asm_diskgroup
GROUP_NUMBER NAME TYPE
------------ -------------------- ------
1 DG EXTERN
【翻译自mos文章】 11gR1版本 asmcmd的新命令--cp、md_backup、md_restore