`

Oracle 11g ASM Command Enhancement(原创)

 
阅读更多

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:

  • --statistics: Displays the READS, WRITES, READ_ERRS, WRITE_ERRS, READ_TIME, WRITE_TIME, BYTES_READ, BYTES_WRITTEN, and the PATH columns of the V$ASM_DISK view.
  • -p: Displays the GROUP_NUMBER, DISK_NUMBER, INCARNATION, MOUNT_STATUS, HEADER_STATUS, MODE_STATUS, STATE, and the PATH columns of the V$ASM_DISK view.
  • -t: Displays the CREATE_DATE, MOUNT_DATE, REPAIR_TIMER, and the PATH columns of the V$ASM_DISK view.
  • -g: Selects from GV$ASM_DISK_STAT, or from GV$ASM_DISK if the --discovery flag is also specified. GV$ASM_DISK.INST_ID is included in the output.
  • --discovery: Selects from V$ASM_DISK, or from GV$ASM_DISK if the -g flag is also specified. This option is always enabled if the Oracle ASM instance is version 10.1 or earlier. This flag is disregarded if lsdsk is running in non-connected mode.
  • --suppressheader: Suppresses column headings.
  • -I: Scans disk headers for information rather than extracting the information from an Oracle ASM instance. This option forces non-connected mode.
  • -G: Restricts results to only those disks that belong to the group specified by diskgroup.
  • -M: Displays the disks that are visible to some but not all active instances. These are disks that, if included in a disk group, cause the mount of that disk group to fail on the instances where the disks are not visible.
  • --candidate: Restricts results to only disks having membership status equal to CANDIDATE.
  • --member: Restricts results to only disks having membership status equal to MEMBER.
  • pattern: Returns only information about the specified disks that match the supplied pattern.
  • -d: 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
Marks a range of blocks as unusable on the disk and relocates any data allocated in that range.
Syntax:
remap diskgroup disk block_range
diskgroup: Disk group name in which a disk must have data relocated.
disk: Name of the disk that must have data relocated. The name must match the NAME column in the V$ASM_DISK view.
block_range: Range of physical blocks to relocate in the format start_range_number-end_range_number.
The remap command only relocates blocks. It does not correct or repair blocks that contain corrupted contents. The command uses a physical block size based on the SECTOR_SIZE disk group attribute.
remaps blocks 5000 through 5999 for disk DATA_0001 in disk group DATA.
ASMCMD [+] > remap DATA DATA_0001 5000-5999

remaps blocks 6230 through 6339 for disk FRA_0002 in disk group FRA
ASMCMD [+] > remap FRA FRA_0002 6230-6339
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
       http://docs.oracle.com/cd/E11882_01/server.112/e18951/asm_util004.htm#OSTMG94626

       http://docs.oracle.com/cd/E11882_01/server.112/e18951/asm_util004.htm#OSTMG94559

本文原创,转载请注明出处、作者

如有错误,欢迎指正

邮箱:czmcj@163.com

0
0
分享到:
评论

相关推荐

    OracleLinux6.5下安装Oracle11g_ASM.docx

    Oracle Linux 6.5 下安装 Oracle 11g ASM Oracle Linux 6.5 是一个稳定的操作系统,而 Oracle 11g ASM(Automatic Storage Management)是 Oracle 公司提供的一种高可用性的存储管理解决方案。本文档将指导用户在 ...

    Oracle 11G ASM安装准备

    Oracle 11G Automatic Storage Management (ASM) 是Oracle数据库系统中的一个组件,它提供了一种高效、自动化的磁盘管理方案。在安装Oracle 11G ASM之前,需要确保操作系统环境满足特定的要求,以确保安装过程顺利...

    CentOS7 + ASM + Oracle 11g 单机安装手册

    本文档是一份详尽的指南,旨在指导用户在CentOS 7操作系统上通过自动存储管理(ASM)安装Oracle数据库11g。文档细致地讲解了虚拟机创建、操作系统安装、网络配置、软件包检查、ASM安装、Oracle Grid软件安装和Oracle...

    ORACLE 10G asm

    Oracle 10G ASM,全称为Oracle Automatic Storage Management,是Oracle数据库系统中的一款高级存储管理技术。ASM提供了一种集中式、自动化的磁盘管理和I/O优化方案,它简化了数据库存储的配置和管理,同时提高了...

    oracle 11g asm 在线更换存储

    Oracle 11g ASM(Automatic Storage Management)在线更换存储是一个涉及数据库高可用性和存储优化的重要操作。在Oracle RAC(RAC是Real Application Clusters的缩写,即实时应用集群)环境中,ASM负责管理数据库的数据...

    Oracle 11g rac +ASM安装手册

    Oracle 11g RAC(Real Application Clusters)结合ASM(Automatic Storage Management)是Oracle数据库提供的高可用性和可扩展性解决方案。在Linux环境下安装Oracle 11g RAC + ASM是一个复杂的过程,需要对Oracle的...

    oracle11g+asm+rac安装指南

    Oracle 11g + ASM + RAC 安装指南 本文档提供了 Oracle 11g + ASM + RAC 的安装指南,包括环境说明、网络接口和 IP 分配、主机名修改、SELINUX 配置、防火墙配置、OS 环境检查、网络配置、时间同步协议 NTP 配置等...

    Windows Server 2012 R2 X64环境下搭建Oracle 11G R2 RAC+ASM.doc

    Windows Server 2012 R2 X64环境下搭建Oracle 11G R2 RAC+ASM,文档目录清晰,需要的拿去。

    创建oracle10g asm数据库step by step

    ### 创建Oracle 10g ASM数据库的详细步骤与解析 #### 概述 在Oracle 10g中引入了一项重要的技术——ASM(Automatic Storage Management,自动存储管理),旨在简化数据库管理员(DBA)的磁盘管理和提高数据分布的...

    Oracle 11g R2+RAC+ASM+OracleLinux6.4安装详解

    Oracle 11g R2是Oracle数据库的一个重要版本,它提供了许多高级功能和优化,而RAC(Real Application Clusters)和ASM(Automatic Storage Management)是Oracle数据库的关键组件,用于实现高可用性和自动化的存储...

    华为出的牛逼的文档 Oracle11g R2 RAC安装指导书(SUSE11+ASM)

    华为出的牛逼的文档 Oracle11g R2 RAC安装指导书(SUSE11+ASM)

    Oracle11G ASM HA实施文档

    1.安装过程注意事项 2.ORACLE11G GRID安装 3.ORACLE11G软件安装 4.ORACLE11G升级PATCH 5.ORACLE11G创建数据库 6.如何新建ASM磁盘组 7.配置VCS5.1双机

    oracle11g 百度盘下载

    3. **自动存储管理(Automatic Storage Management, ASM)**:ASM是Oracle 11g中的一个集成存储管理解决方案,简化了数据库存储的管理和配置,支持自动磁盘管理和数据冗余。 4. **数据加密**:Oracle 11g加强了数据...

    oracle10g rac asm for linux

    oracle10g rac asm for linux oracle10g rac asm for linux

    手动创建oracle 10g ASM磁盘组

    ### 手动创建Oracle 10g ASM磁盘组知识点详解 #### 一、环境准备与检查 在创建Oracle 10g ASM磁盘组之前,需要做好充分的准备,包括环境检查、软件安装等。 **1.1 检查磁盘信息** 通过`fdisk -l`命令可以查看...

    oracle11g r2+asm

    Oracle 11g R2 on Linux with ASM (Automatic Storage Management)是高级数据库管理技术的集成,它提供了自动化的磁盘管理和故障恢复功能。在本文中,我们将深入探讨Oracle 11g R2在Linux环境下的安装,特别是涉及到...

    oracleasm RPM包

    在Oracle 10g及后续版本中,ASM成为了数据库管理员的强大工具。 RPM(Red Hat Package Manager)包是一种在Linux操作系统中广泛使用的软件包管理格式,用于安装、升级、查询和卸载软件。"oracleasm RPM包"指的是专...

    Oracle10g RAC ASM 环境日常管理命令

    在Oracle10g RAC(Real Application Clusters)与ASM(Automatic Storage Management)环境中,日常管理操作至关重要,确保了数据库的高效运行与集群的稳定性。本文将深入解析几个关键的管理命令,涵盖网络配置、...

    redhat6.5 oracle ASM驱动

    Oracle ASM(Automatic Storage Management)是Oracle数据库公司提供的一种先进的存储管理解决方案,专为Oracle数据库设计。它整合了文件系统和卷管理器的功能,为数据库提供高效、可靠的存储管理。在Red Hat ...

    oracle 11G rac_asm搭建实测

    ### Oracle 11g RAC_ASM 搭建详解 #### 一、环境配置与准备 在进行Oracle 11g RAC_ASM的实际部署前,首先需要准备好合适的硬件及软件环境。 **1.1 主机配置** - **RAC1.vm 和 Rac2.vm** - 公共IP (Public IP): ...

Global site tag (gtag.js) - Google Analytics