Oracle 11g ASM Command Enhancement
发布日期:2021-09-16 04:38:22 浏览次数:61 分类:技术文章

本文共 14024 字,大约阅读时间需要 46 分钟。

Changes in the check Command 

The check command lets you verify if the ASM disk group metadata is consistent. If there are any inconsistencies, the command shows you a summary of the errors and records the details in the alert log. In Oracle Database 10g, you could specify the following values with the check command: 
all,disk,disks in failgroup,file. 
In Oracle Database 11g, the check command syntax is much simpler and checks all metadata directories by default. The check command performs the following checks in Oracle Database 11g:

  • The file and disk options will perform the same checks as the all option in the previous release. Checks disk consistency, acting as an equivalent command to the check disk and check disks in failgroup clauses in the Oracle Database 10g release.
  • Cross checks all file extent maps and allocation tables, which is equivalent to what the check file command did in Oracle Database 10g.
  • Checks to ensure that the alias metadata directory and the file directory are correctly linked.
  • Checks that the alias directory tree is correctly linked.
  • Checks to ensure that the ASM metadata directories don’t contain any allocated blocks that are unreachable.

You can specify the repair/norepair clause to tell ASM whether you want it to attempt to repair any errors found during the disk group checks. The default value is repair, meaning ASM will attempt to automatically fix any inconsistencies it finds during its disk group checks.

ALTER DISKGROUP data CHECK; -- Like NOREPAIR 

ALTER DISKGROUP data CHECK NOREPAIR; 
ALTER DISKGROUP data CHECK REPAIR;

The FORCE option 

In Oracle Database 10g, Oracle mounts a disk group even when there are potentially missing or damaged failure groups. That is, a command to mount an incomplete group will succeed as long as there are enough failure groups to mount the disk group. If ASM finds at least one complete set of extents in the disk group, it will mount the disk group. The problem with this approach is that ASM is liable to drop a missing ASM disk, which means you have to add them back after repairing them and perform an expensive rebalancing operation. 
In Oracle Database 11g, ASM won’t mount an incomplete disk group automatically. Rather, you must specify the force option when mounting a disk group, for the operation to succeed. This means that if there are any errors, in say, the asm_diskstring parameter or if there are any connectivity issues, you can correct them before mounting the disk group. By default, the mount diskgroup operation uses a noforce option. Under this option, the database will mount a disk group only if all the disks belonging to that disk group are available. Use the force option when you know beforehand that some of the disks are unavailable. ASM will then mount the disk group, even when some disks are unavailable, as long as it finds enough disks to form a quorum. When you mount a disk group with the force option, if one or more disks aren’t available at mounting time, the disks can be offlined. You must restore those devices before the duration set by the disk_repair_time attribute expires to avoid a costly rebalancing operation to restore redundancy for all files in the disk group. 
In Oracle Database 10g, you’d sometimes run into a problem when dealing with a badly damaged disk or lost disk. Because of the problem with the damaged or lost disk, you may want to drop the entire disk group or rearrange the disks in the disk group in other disk groups. If a disk is missing, you can’t mount the disk group, however. The only alternative you have is to use the dd command to wipe the disk headers off. 
In Oracle Database 11g, it’s much easier to drop disk groups that you can’t mount.You can use the new drop disk group force command to drop disk groups that can’t be mounted by an ASM instance, as shown here: 
SQL> drop diskgroup dgroup1 force including contents; 
Note that you must specify the including contents clause when executing the drop diskgroup command with the force option. The command will fail if the disk group you’re dropping is being used by the ASM instance anywhere in the subsystem. If the disk group is in the same cluster or on the same node and is in use, the command fails. However, if the disk group is on another cluster, the command fails if ASM verifies that the disk group is in use. Once the drop 
diskgroup . . . force command succeeds, it results in the marking of the headers of the disks in the disk group that wasn’t mounted as FORMER. 
Enhancements in ASMCMD 
The ASMCMD utility is a command-line tool that helps you view and manage files and directories within an ASM disk group. You can list the contents of disk groups, perform a search, and create and remove directories with the help of the ASMCMD utility. In Oracle Database 11g, there are new options you can use with the ASMCMD utility to help you perform ASM metadata backup and recovery operations. In Oracle Database 10g, you could use RMAN to restore lost files when an ASM disk group was lost, but this required you to re-create the ASM disk group as well as any user directories or templates. In Oracle Database 11g, the new md_backup and md_restore options let you re-create an ASM disk group with an identical template and alias directory structure. 
The new ASM metadata backup and restore (AMBR) functionality works in the backup and restore modes. In the backup mode, AMBR gathers information about disk groups and failure group configuration, templates, and alias directory structures, and stores this metadata in a text file. In the restore mode, AMBR reconstructs the disk group from the information it saves to the text file. In addition to the md_backup and md_restore options, ASMCMD also has the new cp, lsdsk, and remap commands. 
cp

The cp command helps copy one or more files to another destination. For example, you can use this command to copy files between ASM disk groups on a local instance and a remote instance. The destination is of the form target/connect_identifier, where connect_identifier can be a HOSTNAME, HOSTNAME.SID, or HOSTNAME.[PORT.]SID (where PORT is an optional attribute). You can use the cp command to copy an ASM file to the operating system. With the cp command, you can: 

Copy a file locally: 
cp +DATA/ORCL/DATAFILE/TBSFV.256.123456789  +DATA/ORCL/tbsjfv.bak 
Copy an ASM file to the operating system: 
cp +DATA/ORCL/DATAFILE/TBSFV.256.123456789 /home/oracle/tbsjfv.dbf 
Copy an operating system file to an ASM directory: 
cp /home/oracle/tbsjfv.dbf  +data/jfv 
Copy an ASM file from a local ASM instance to a remote ASM instance: 
cp +DATA/orcl/datafile/tbsjfv.256.123456789\sys@mydb . +ASM2 : +D2/jfv/tbsjfv.dbf 
lsdsk

The lsdsk command lists ASM-visible disks. You can restrict the output to only those disks that match a pattern, which can include wildcard characters and slashes. You can run this command in either the connected mode or the non-connected mode. In the connected mode, the command retrieves disk information from the V$ and the GV$ tables. In the non-connected mode, the command scans disk headers to retrieve the disk information. Unless you specify the -i flag, the lsdsk command runs in the connected mode when you are connected to an ASM instance. Here is an example of the lsdsk command. 

ASMCMD> lsdsk 
/dev/raw/raw1 
/dev/raw/raw3 
... 
ASMCMD> lsdsk -d data -k 
Total_MB  Free_MB  OS_MB  Name       Failgroup  Library  Label  UDID  Product  Redund   Path 
    8189     6961   8189  DATA_0000  DATA_0000  System                         UNKNOWN  /dev/sdc1 
    8189     6961   8189  DATA_0001  DATA_0001  System                         UNKNOWN  /dev/sdd1 
    8189     6950   8189  DATA_0002  DATA_0002  System                         UNKNOWN  /dev/sde1 
You can also specify the following flags with the lsdsk command:

  • The -k flag provides a detailed set of information about disks, including their total size and free sizes, failgroups, and their paths.
  • The -s flag shows I/O statistics relating to the disks.
  • The -p flag provides the status of the disks.
  • The -t flag provides repair related information.
  • The -d flag along with another flag such as -t, limits the output to a specific disk group, as shown here:

ASMCMD> lsdsk -t -d dgrp1 

Use the help lsdsk command to get information about all the options of the lsdsk command.

You can also attach the -l flag to any other flag to make ASM retrieve the information directly from the file headers instead of the V$ views. For example: 

ASMCMD> lsdsk -lk

The preceding command gets detailed disk information from the disk headers. If the ASM instance isn’t available for some reason, you can still get the information you need by letting ASM extract the information from the file headers. You can get information for a specific disk group by using the -d flag with any of the other flags, as shown here: 

ASMCMD> lsdsk -t -d dgrp1 
The previous lsdsk command gets detailed information about the disks in disk group dgrp1. 
remap

The remap command lets you remap a range of unreadable bad disk sectors. It can’t, however, remap blocks with incorrect content, whether they are readable or not. Here’s an example showing how to use the remap command: 

 ASMCMD> remap DATA DATA_0001 5000-7500 
md_backup

As you are aware, an ASM instance doesn’t store data. It merely maintains the storage metadata such as the names of the disk groups, directories, and so on and stores this metadata in the disk headers. This means that if there is a disk crash and you lose the disk headers, you’re in trouble. You can use RMAN to restore a backup for the database itself, but you’ll have to first re-create the ASM disk groups and directories. If you haven’t kept careful records, you’re in trouble again. Even if you have the records, you must still take the time to re-create the necessary ASM metadata. In Oracle Database 11g, the ASMCMD utility is extended to provide ASM metadata backup and restore functionality through the md_backup and md_restore commands. This functionality is known as the ASM metadata backup and restore (AMBR). The goal is to enable you to easily re-create an ASM disk group with an identical template and alias directory structure, using the backup of the ASM metadata. This eliminates the need for manually re-creating the disk groups and the necessary directories or templates following the loss of an ASM disk group. The new md_backup option in Oracle Database 11g lets you perform an ASM metadata backup for a disk group. The command will back up into a backup text file, disk group metadata including fail groups, disks, attributes, aliases, and templates. Here’s the syntax of the md_backup command: 

md_backup [-b <backup_file>] 
          [-g '<diskgroup_name>,<diskgroup_name>,...'] 
The -b option lets you specify the backup file to store the information. By default, the filename is ambr_backup_intermediate_file. 
The -g option lets you specify the disk groups to back up. The command backs up all disk groups by default. 
Here’s an example showing how to use the md_backup command to back up a single disk group named admdsk1. 
ASMCMD> md_backup -b /tmp/asmbkp1 -g admdsk1 
The md_backup command shown here uses the -g option to create a backup of the disk group admdsk1 and saves it in the /tmp/dgbackup07022 file. The -b option specifies that the backup information containing the ASM metadata be recorded in the file named asmblp1 instead of in the default file named ambr_backup_intermediate_file. 
md_restore

The md_restore command is the counterpart of the md_backup command and helps you restore the ASM metadata for a disk group. Before you can restore data files in a disk group, you must first restore the disk group using this command. The md_restore command has the following syntax: 

md_restore -b <backup_file> [-li] 
           [-t (full)|nodg|newdg] [-f <sql_script_file>] 
           [-g '<diskgroup_name>,<diskgroup_name>,...'] 
           [-o '<old_diskgroup_name>:<new_diskgroup_name>,...'] 
The following lists the various flags and their meanings: 
 -b  Read metadata information from <backup_file>. 
 -l  Print messages to a file (Not implemented). 
 -i  Ignore errors. Normally, if md_restore encounters an error, it will stop. 
When you specify the -i flag, errors are ignored. 
 -t  Specify diskgroup creation.

  •  full  Create disk group and restore metadata.
  •  nodg  Restore metadata only.
  •  newdg  Create disk group with a different name and restore metadata.

 -f  Write SQL commands to <sql_script_file> instead of executing them. 

 -g  Select the disk groups to be restored. If no disk groups are defined, all of them will be restored. 
 -o  Rename disk group <old_diskgroup_name> to <new_diskgroup_name>. 
You can initiate the creation of a disk group as well as restore its metadata by executing the md_restore command. The following examples show how to use this command in various scenarios: 
Restoring a disk group from the backup script and creating a copy: 
ASMCMD> md_restore -t full -g asmdsk1 -i backup_file 
Restoring an existing disk group’s metadata: 
ASMCMD> md_restore -t nodg - asmdsk1 -i backup_file 
Restoring a disk group and creating a new disk group: 
ASMCMD> md_restore -t newdg -o 'DGNAME=asmdsk1:asmdsk2'  -i backup_file 
The md_restore command restores the disk groups, creates the attributes such as disk_repair_time, modifies the templates, and creates the directories. It’s important to understand that any data in the disk groups will be lost, however. The md_restore command creates a disk group and the directories without any data. The md_restore uses the backup file created by the md_backup command, which backs up just the ASM metadata. You must use your RMAN database backups to restore the information on the re-created disk groups. The following md_restore command example specifies the -f flag to create a text file with the commands to create the disk groups, directories, and so on . 
ASMCMD> md_restore -b dgroup1.backup -t full -f create_dgroup1.sql 
You can execute the md_restore command with the -f option on a regular basis to maintain a record of the ASM metadata.

参考至:《McGraw.Hill.OCP.Oracle.Database.11g.New.Features.for.Administrators.Exam.Guide.Apr.2008》 

       http://www.oracle-base.com/articles/11g/asm-enhancements-11gr1.php#fast_rebalance

 

转载地址:https://blog.csdn.net/wll_1017/article/details/45336541 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:asm 实例的管理
下一篇:Which two are the uses of the ASM metadata backup and restore (AMBR) feature? (Choose two.)

发表评论

最新留言

很好
[***.229.124.182]2024年04月17日 23时45分26秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章