We have introduced three new functionalities to the ASMCMD utility to improve node recovery after a crash,repair bad blocks on a disk, copy files and simplify the listing of ASM disks in a diskgroup
ASMCMD is also extended to include ASM disk group metadata backup and restore functionality.This provides the ability to create a pre-existing ASM diksgroup with the same disk paths, disk names,failure groups,attributes,templates and alias directory structure
ASMCMD - New commands in 11gR1
1. ASMCMD cp command
The ASMCMD cp option allows you to copy files between ASM disk groups and OS file systems and between two ASM servers.
The following file copy can be performed :
- ASM Diskgroup to OS file system
- OS file system to ASM Diskgroup
- ASM Diskgroup to another diskgroup
(1)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.
(2)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.
(3)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 and actual file is created in the ASMTESTING folder
ASMCMD> ls -ltr
Type Redund Striped Time Sys Name
N tbsext => +DGEXTBK/ASMTESTING/DATAFILE/TESTING.256.628848885
Also Refer Note 452158.1 ASMCMD cp command fails with ORA-15046
2. ASMCMD md_backup and md_restore
ASMCMD is extended to include ASM disk group metadata backup and restore functionality.This provides the ability to recreate a pre-existing ASM disk group with the same disk paths,disk names, failure groups, attributes, templates and alias directory structure
In 10g if an ASM disk group is lost, then it is only possible to restore the lost files using RMAN but you have to manually recreate the ASM disk group and any required user directories/templates.
In 11g we can take backup of ASM diskgroup metadata.The md_backup command creates a backup file containing metadata for one or more disk groups. By default all the mounted disk groups are included in the backup file which is saved in the current working directory. If the name of the backup file is not specified, ASM names the file AMBR_BACKUP_INTERMEDIATE_FILE.
ASMCMD> md_backup -b dgbk -g dgext
Disk group to be backed up: DGEXT
In restore mode, it reads the previously generated file to reconstruct the diskgroup and its metadata. You have the possibility to control the behaviour in restore mode to do a full,nodg or newdg restore.
The full mode restores the diskgroup exactly as it was at the time of backup
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)
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
The 'nodg' mode restore the attributes,templates, and alias directory structure specified in the backup file to an existing disk group.
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!
The 'newdg' mode allows the user to override the disk group name,disk, and failgroup specifications as part of a diskgroup creation,but retains the attribute,template and, alias directory structure from the backup
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
From Oracle
-------------------------------------------------------------------------------------------------------
QQ: 492913789
Email: ahdba@qq.com
Blog: http://www.cndba.cn/dave
DBA1 群:62697716(满); DBA2 群:62697977(满) DBA3 群:62697850(满)
DBA 超级群:63306533(满); DBA4 群: 83829929 DBA5群: 142216823
聊天 群:40132017 聊天2群:69087192
--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请