February 21, 2010

asmcmd utility in Oracle

Managing ASM through SQL interfaces, in Oracle Database 10g Release 1, posed a challenge for administrators who were not very familiar with SQL and preferred a more conventional command line interface. From Oracle Database 10g Release 2, we have an option to manage the ASM files by using ASMCMD, a powerful and easy to use command line tool.

In Oracle Database 10g Release 1, ASM diskgroups are not visible outside the database for regular file system administration tasks such as copying and creating directories. From Oracle Database 10g Release 2, we can transfer the files from ASM to locations outside of the diskgroups via FTP and through a web browser using HTTP.

list the contents, statistics and attributes of diskgroups, and files on them

backup and restore the metadata of diskgroups

create and remove directories, templates and aliases

managing volumes

make online or offline the disks/failure groups

can rebalance the diskgroups

repair physical blocks

copy the files between the diskgroups and OS

backup and restore of SP file

add/remove/modify/list users from password file

add/remove/modify/list templates

manipulate diskstring

create/modify/remove ASM users, groups

change ASM file permissions, owners and groups

display space utilization

perform searches

ASMCMD has equivalent commands for all the SQL commands that can be performed through SQL*Plus.

ASMCMD is included in the installation of the Oracle Database software (from 10g Release 2), no separate setup is required.

We can’t see the files stored in the ASM instance using standard UNIX commands like ls. We need to use asmcmd. The asmcmd command line interface is very similar to standard UNIX/Linux commands, but it only manages files at the OS level. The asmcmd utility supports all common Linux commands. The idea of this tool is to make administering the ASM files similar to administering standard OS files.

Invoking asmcmd

To start using ASMCMD, you must log in as a user that has SYSASM or SYSDBA privileges through OS authentication. The environmental variables ORACLE_HOME and ORACLE_SID must be set to the ASM instance. Ensure that $ORACLE_HOME/bin is in PATH environment variable. You must have ASM configured on the machine and started, and the ASM diskgroups are mounted.

The default value of the ASM SID for a single instance database is +ASM. In Real Application Clusters (RAC) environments, the default value of the ASM SID on any node is +ASMnode# (+ASM1, +ASM2, ...).

$ export ORACLE_SID=+ASM

To enter in interactive mode, type asmcmd, which brings up the ASM command prompt.

$ asmcmd

ASMCMD>

To run a specific ASMCMD command, non interactively, we can type

$ asmcmd command arguments

We can specify -p option with the asmcmd command to include current directory path in the ASMCMD prompt.

$ asmcmd -p

ASMCMD [+] > cd dgroup1/hrms

ASMCMD [+dgroup1/hrms] >

We can specify -a option to choose the type of connection, either SYSASM or SYSDBA. From 11g, the SYSASM privilege is preferred & default.

$ asmcmd -a sysasm or asmcmd -a sysdba

We can specify -V option when starting asmcmd to displays the asmcmd version number. This is from 11g.

$ asmcmd -V

asmcmd version 11.1.0.6.0

We can specify -v option when starting asmcmd to displays the additional information. This is from 11g.

$ asmcmd -v

ASM Filenames & Directories

Pathnames within ASMCMD, can use either the forward slash (/) as in UNIX or the backward slash (\) as in Windows, they're interchangeable. Also, we can use either the UNIX wildcard "*" to match any string in a pathname, or its SQL equivalent, "%".

Filenames are not case sensitive, but are case retentive, that is, ASMCMD retains the case of the directory that you entered.

The fully qualified filename represents a hierarchy of directories in which the plus sign (+) represent the root directory. We can also create our own directories as subdirectories of the system-generated directories using the ALTER DISKGROUP command or with the ASMCMD mkdir command. Those directories can have subdirectories, and we can navigate the hierarchy of both system-generated directories and user-created directories with the cd command.

When we run an ASMCMD command that accepts a filename or directory name as an argument, we can use the name as either an absolute path or a relative path.

An absolute path refers to the full path of a file or directory. An absolute path begins with a plus sign (+) followed by a diskgroup name, followed by subsequent directories in the directory tree. The absolute path includes directories until the file or directory is reached. A fully qualified filename is an example of an absolute path to a file.

Using an absolute path enables the command to access the file or directory regardless of where the current directory is set. The following rm command uses an absolute path for the filename:

ASMCMD [+] > rm +dgroup1/hrms/datafile/users.280.555341999

A relative path includes only the part of the filename or directory name that is not part of the current directory. That is, the path to the file or directory is relative to the current directory.

ASMCMD [+dgroup1/hrms/DATAFILE] > ls -l undotbs1.267.557429239

Paths to directories can also be relative and we can use the pseudo-directories "." and ".." in place of a directory name. The wildcard characters * and % match zero or more characters anywhere within an absolute or relative path, which saves typing of the full directory or file name. These two wildcard characters behave identically.

Alias

As in UNIX, we can create alias names for files listed in the diskgroup. Aliases are user-friendly filenames that are references or pointers to system-generated filenames. Aliases are similar to symbolic links in UNIX flavors. ASM's auto generated names can be a bit strange, so creating aliases makes working with ASM files with ASMCMD easier. Aliases simplify ASM filename administration. We can create aliases with an ALTER DISKGROUP command or with the mkalias ASMCMD command.

An alias has at a minimum the diskgroup name as part of its complete path. We can create aliases at the diskgroup level or in any system-generated or user-created subdirectory. The following are examples of aliases:

+dgroup1/ctl1.f

+dgroup1/crm/ctl1.f

+dgroup1/mydir/ctl1.f

If you run the ASMCMD ls (list directory) with the -l flag, each alias is listed with the system-generated file to which the alias refers.

ctl1.f => +dgroup2/hrms/CONTROLFILE/Current.256.541956473

We can run the ASMCMD utility in either interactive or non interactive mode.

ASMCMD in Interactive Mode

The interactive mode of the ASMCMD utility provides an environment like shell or SQL*Plus, where we are prompted to enter ASMCMD commands.

To run ASMCMD in interactive mode:

1. Enter the following at the OS command prompt:

$ asmcmd

Oracle displays an ASMCMD command prompt as follows:

ASMCMD>

2. Enter an ASMCMD command and press Enter. The command runs and displays its output, and then ASMCMD prompts for the next command.

In non interactive mode, you run a single ASMCMD command by including the command and command arguments on the command line that invokes ASMCMD. ASMCMD runs the command, generates output, and then exits. The non interactive mode is especially useful for running scripts.

To run ASMCMD in non interactive mode, where command is any valid ASMCMD command and arguments is a list of command flags and arguments, at the command prompt enter the following:

Changes to a specified directory. We can go up or down the hierarchy of the current directory tree by providing a directory argument to the cd command.

cd dir_name

dir_name may be specified as either an absolute path or a relative path, including the . and .. pseudo-directories and wildcards.

ASMCMD [+dgroup2/crm] > cd +dgroup1/hrms

ASMCMD [+dgroup1/hrms] > cd DATAFILE

ASMCMD [+dgroup1/hrms/DATAFILE] > cd ..

ASMCMD [+]> cd +dgroup1/sample/C*

If a wildcard pattern matches only one directory when using wildcard characters with cd, then cd changes the directory to that destination. If the wildcard pattern matches multiple directories, then ASMCMD does not change the directory but instead returns an error.

pwd command

Displays the absolute path of the current directory.

pwd

ASMCMD> pwd

help command

Displays the syntax of a command and description of the command parameters.

help [command] or ? [command]

If you do not specify a value for command, then the help command lists all of the ASMCMD commands and general information about using the ASMCMD utility.

ASMCMD> helpASMCMD> help lsct

ASMCMD> ?ASMCMD> ? mkgrp

du command

Displays the total space used for files in the specified directory and in the entire directory tree under the directory.

du [-H] [dir_name]

The -H flag suppresses column headings from the output.

This command is similar to the du -s command on UNIX flavors. If you do not specify dir_name, then information about the current directory is displayed. dir_name can contain wildcard characters.

ASMCMD [+dgroup1/prod] > du

Used_MB Mirror_used_MB

1251 2507

Used_MB - The total space used in the directory, this value does not include mirroring.

Mirror_used_MB - This value includes mirroring.

For example, if a normal redundancy diskgroup contains 100 MB of data, then assuming that each file in the diskgroup is 2way mirrored, Used_MB is 100 MB and Mirror_used_MB is 200 MB.

ASMCMD> du TEMPFILE

Used_MB Mirror_used_MB

24582 24582

In this case, Used_MB & Mirror_used_MB are the same, because the diskgroups are not mirrored.

ASMCMD [+ASM_DG_DATA/CRM] > du -H DATAFILE/

98203 98203

find command

Displays the absolute paths of all occurrences of the specified name pattern (can have wildcards) in a specified directory and its subdirectories.

This command searches the specified directory and all subdirectories under it in the directory tree for the supplied name_pattern. The value that you use for name_pattern can be a directory name or a filename.

ASMCMD> find +dgroup1 undo*

+dgroup1/crm/DATAFILE/UNDOTBS1.258.555341963

+dgroup1/crm/DATAFILE/UNDOTBS1.272.557429239

ASMCMD> find -t CONTROLFILE +dg_data/hrms *

+dg_data/hrms/CONTROLFILE/Current.260.555342185

+dg_data/hrms/CONTROLFILE/Current.261.555342183

ASMCMD [+] > find --type CONTROLFILE +data/devdb *

+data/devdb/CONTROLFILE/Current.260.691577263

ls command

Lists the contents of an ASM directory, the attributes of the specified file, or the names and attributes of all diskgroups from the V$ASM_DISKGROUP_STAT (default) or V$ASM_DISKGROUP.

If name is a directory name, then ASMCMD lists the contents of the directory and depending on flag settings, ASMCMD also lists information about each directory member. Directories are listed with a trailing forward slash (/) to distinguish them from files.

If name is a filename, then ASMCMD lists the file and depending on the flag settings, ASMCMD also lists information about the file.

Flag

Description

(none)

Displays only filenames and directory names.

-l

Displays extended file information, including striping and redundancy information and whether the file was system-generated (indicated by Y under the SYS column) or user-created (as in the case of an alias, indicated by N under the SYS column). Note that not all possible file attributes or diskgroup attributes are included.

-s

Displays file space information.

-d

If the value for the name argument is a directory, then ASMCMD displays information about that directory, rather than the directory contents. Typically used with another flag, such as the -l flag.

-r or--reverse

Reverses the sort order of the listing.

-t

Sorts the listing by timestamp.

-L

If the value for the name argument is an alias, then ASMCMD displays information about the file that it references. Typically used with another flag, such as the -l flag.

-a

For each listed file, displays the absolute path of the alias that references it.

-c

Selects from V$ASM_DISKGROUP or GV$ASM_DISKGROUP if the -g flag is also specified.

-g

Selects from GV$ASM_DISKGROUP_STAT or GV$ASM_DISKGROUP if the -c flag is also specified. GV$ASM_DISKGOUP.INST_ID is included in the output.

-H

Suppresses column headings.

--permission

Shows the permissions of a file (V$ASM_FILE.permission, V$ASM_FILE.owner, V$ASM_FILE.usergroup, V$ASM_ALIAS.name).

pattern

Name of a file, directory, or pattern.

If you specify all of the flags, then the command shows a union of their attributes, with duplicates removed. To see the complete set of column values for a file or a diskgroup, query the V$ASM_FILE and V$ASM_DISKGROUP.

The Sys column, immediately to the left of the Name column, shows if the file or directory was created by the ASM system. Because the CONTROLFILE directory is not a real file but an alias, the attributes of the alias, such as size, free space, and redundancy, shown in the first few columns of the output are null.

The following examples illustrate the use of wildcards.

ASMCMD> ls +dgroup1/mydir1/d*

data1.f

dummy.f

ASMCMD> ls +group1/sample/*

+dgroup1/sample/CONTROLFILE/:

Current.260.555342185

Current.261.555342183

+dgroup1/sample/DATAFILE/:

EXAMPLE.269.555342243

SYSAUX.257.555341961

SYSTEM.256.555341961

UNDOTBS1.272.557429239

USERS.259.555341963

+dgroup1/sample/ONLINELOG/:

group_1.262.555342191

group_1.263.555342195

group_2.264.555342197

group_2.265.555342201

+dgroup1/sample/PARAMETERFILE/:

spfile.270.555342443

+dgroup1/sample/TEMPFILE/:

TEMP.268.555342229

lsct command

Lists information about current ASM clients (from V$ASM_CLIENT). A client, is a database or Oracle ASM Dynamic Volume Manager (Oracle ADVM), uses diskgroups that are managed by the ASM instance to which ASMCMD is currently connected.

lsct [-gH] [disk_group]

Flag

Description

(none)

Displays information about current ASM clients from V$ASM_CLIENT.

-g

Selects from GV$ASM_CLIENT. GV$ASM_CLIENT.INST_ID is included in the output.

-H

Suppresses column headings.

An ASM instance serves as a storage container; it's not a database by itself. Other databases use the space in the ASM instance for datafiles, control files, and so on.

Lists all diskgroups and their attributes from V$ASM_DISKGROUP_STAT (default) or V$ASM_DISKGROUP. The output also includes notification of any current rebalance operation for a diskgroup. If a diskgroup is specified, then lsdg returns only information about that diskgroup.

If group is specified, then information about only that diskgroup is listed.

Flag

Description

(none)

Displays all the diskgroup attributes.

-c or --discovery

Selects from V$ASM_DISKGROUP or GV$ASM_DISKGROUP if the -g flag is also specified. This option is ignored if the ASM instance is version 10.1 or earlier.

-g

Selects from GV$ASM_DISKGROUP_STAT or GV$ASM_DISKGROUP if the -c or --discovery flag is also specified. GV$ASM_DISKGOUP.INST_ID is included in the output. The REBAL column of the GV$ASM_OPERATION is also included in the output.

-H

Suppresses column headings.

pattern

Returns only information about the specified diskgroup or diskgroups that match the supplied pattern.

To see the complete set of attributes for a diskgroup, use the V$ASM_DISKGROUP_STAT or V$ASM_DISKGROUP.

Attribute Name

Description

State

State of the diskgroup (BROKEN, CONNECTED, DISMOUNTED, MOUNTED, QUIESCING, and UNKNOWN).

Type

Diskgroup redundancy (NORMAL, HIGH, EXTERN).

Rebal

Y if a rebalance operation is in progress.

Sector

Sector size in bytes.

Block

Block size in bytes.

AU

Allocation unit size in bytes.

Total_MB

Size of the diskgroup in MB.

Free_MB

Free space in the diskgroup in MB, without redundancy, from V$ASM_DISKGROUP.

Req_mir_free_MB

Amount of space that must be available in the diskgroup to restore full redundancy after the most severe failure that can be tolerated by the diskgroup. This is the REQUIRED_MIRROR_FREE_MB column from V$ASM_DISKGROUP.

Usable_file_MB

Amount of free space, adjusted for mirroring, that is available for new files, from V$ASM_DISKGROUP.

Offline_disks

Number of offline disks in the diskgroup. Offline disks are eventually dropped.

If name is a file or alias (can contain wildcard characters), then the rm command can delete the file or alias, only if it is not currently in use by a client database.

If name is a directory, then the rm command can delete it only if it is empty (unless the -r flag is used) and it is not a system-generated directory.

If name is an alias, then the rm command deletes both the alias and the file to which the alias refers.

For example, if we have an alias,

+dg1/dir1/file.alias => +dg/orcl/DATAFILE/System.256.146589651

then running the

rm -r +dg1/dir1

command removes the +dg1/dir1/file.alias as well as +dg/orcl/DATAFILE/System.256.146589651.

To delete only an alias and retain the file that the alias references, use the rmalias command.

If you use a wildcard, the rm command deletes all of the matches except nonempty directories, unless you use the -r flag. To recursively delete, use the -r flag. This enables you to delete a nonempty directory, including all files and directories in it and in the entire directory tree underneath it. If you use the -r flag or a wildcard character, then the rm command prompts you to confirm the deletion before proceeding, unless you specify the -f flag. When using the -r flag, either the system-generated file or the alias must be present in the directory in which you run the rm command.

Deletes the specified aliases, retaining the files that the aliases reference.

rmalias [-r] alias [alias]...

To recursively delete, use the -r flag. This enables you to delete all of the aliases in the current directory and in the entire directory tree beneath the current directory. If any user-created directories become empty as a result of deleting aliases, they are also deleted. Files and directories created by the system are not deleted.

Used to copy files between ASM diskgroups on local instances to and from remote instances. The local ASM instance must be either the source or the target.The file copy cannot be between remote instances. We can also use this command to copy files from ASM diskgroups to the OS.

Force, if an existing destination file, remove it and try again without user interaction.

-r

Recursive, copy forwarding sub-directories recursively.

The connect_identifier parameter is not required for a local instance copy, which is default. In case of a remote instance copy, we need to specify the connect_identifier and ASM prompts for a password in a non-echoing prompt. The connect_identifier is in the form of:

user_name@host_name[.port_number].SID

The user_name, host_name, and SID are required. The default port number is 1521.

src_fname(s) - Source file name to copy from. Enter either the fully qualified file name, or the ASM alias.

tgt_fname - A user alias for the created target file name or alias directory name.

tgt_directory - A target alias directory within an ASM diskgroup. The target directory must exist, otherwise the file copy returns an error.

The format of copied files is portable between Little-Endian and Big-Endian systems, if the files exist in an ASM diskgroup. ASM automatically converts the format when it writes the files. For copying non-ASM files from or to an ASM diskgroup, you can copy the files to a different endian platform and then use one of the commonly used utilities to convert the file.

Creates a backup file containing metadata for one or more diskgroups. By default, all the mounted diskgroups 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. Here AMBR stands for ASM Managed Backup Recovery.

md_backup [-b location_of_backup] [-g dgname [-g dgname...]]

md_backup [-b location_of_backup] [-g dgname[, dgname...]]

Flag

Description

-b

Specifies the location in which you want to store the intermediate backup file.

-g

Specifies the diskgroup name that needs to be backed up.

This example backs up all of the mounted diskgroups and creates the backup in the current working directory.

ASMCMD > md_backup

The following example creates a backup of diskgroup asmdsk1 and asmdsk2. The backup will be saved in the /tmp/dgbackup100221 file.

Selects from GV$ASM_DISK_STAT or GV$ASM_DISK if the -c flag is also specified. GV$ASM_DISK.INST_ID is included in the output.

-c

Selects from V$ASM_DISK or GV$ASM_DISK, if the -g flag is also specified. This option is ignored if the ASM instance is version 10.1 or earlier.

-H

Suppresses column headings.

-I

Scans disk headers for information rather than extracting the information from an ASM instance. This option forces the non-connected mode.

-d or -G

Restricts results to only those disks that belong to the group specified by diskgroup_name.

--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.

-M

Displays the disks that are visible to some but not all active instances. These are disks that, if included in a diskgroup, cause the mount of that diskgroup 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.

The k, s, p, and t flags modify how much information is displayed for each disk. If any combinations of the flags are specified, then the output shows the union of the attributes associated with each flag.

pattern restricts the output to only disks that matches the pattern specified.

ASMCMD> lsdsk -d DG_DATA -k

ASMCMD> lsdsk -g -t -d DATA1 *_001

This command can run in connected or non-connected mode. The connected mode is always attempted first. The -I option forces the non-connected mode.

Repairs range of physical blocks on a disk. The remap command only repairs blocks that have read disk I/O errors. It does not repair blocks that contain corrupted contents, whether those blocks can be read or not. The command assumes a physical block size of 512 bytes and supports all allocation unit sizes (1MB to 64MB).It reads the blocks from a good copy of an ASM mirror and rewrites them to an alternate location on disk if the blocks on the original location cannot be read properly.

remap diskgroup_name disk_name block_range

Flag

Description

diskgroup_name

Name of the diskgroup in which a disk must be repaired.

disk_name

Name of the disk that must be repaired.

block_range

Range of physical blocks to repair, in the format: starting_number-ending_number

The following example repairs blocks 4500 through 5599 for disk DATA_001 in diskgroup DISK_GRP_DATA.

ASMCMD> remap DISK_GRP_DATA DATA_001 4500-5599

The following example repairs blocks 7200 through 8899 for disk largedisk_2 in diskgroup DISK_GRP_GRA.

Oracle strongly recommends that you shut down all database instances that use the Oracle ASM instance and dismount all file systems mounted on Oracle ASM Dynamic Volume Manager (Oracle ADVM) volumes before attempting to shut down the Oracle ASM instance with the abort (--abort) option.

The first example performs a shutdown of the Oracle ASM instance with normal action.

ASMCMD [+] > shutdown

The second example performs a shut down with immediate action

ASMCMD [+] > shutdown –-immediate

The third example performs a shut down that aborts all existing operations.

Sets the discovery diskstring value that is used by the Oracle ASM instance and its clients. The specified diskstring must be valid for existing mounted diskgroups. The updated value takes effect immediately.

dsset [--normal] [--parameter] [--profile [--force]] diskstring

Flag

Description

--normal

Sets the discovery string in the Grid Plug and Play (GPnP) profile and in the Oracle ASM instance. The update occurs after the Oracle ASM instance has successfully validated that the specified discovery string has discovered all the necessary diskgroups and voting files. This command fails if the instance is not using a server parameter file (SPFILE).

This is the default setting.

--profile [--force]

Specifies the discovery diskstring that is pushed to the GPnP profile without any validation by the Oracle ASM instance, ensuring that the instance can discover all the required diskgroups. The update is guaranteed to be propagated to all the nodes that are part of the cluster.

If --force is specified, the specified diskstring is pushed to the local GPnP profile without any synchronization with other nodes in the cluster. This command option updates only the local profile file. This option should only be used for recovery. The command fails if the Oracle Clusterware stack is running.

--parameter

Specifies that the diskstring is updated in memory after validating that the discovery diskstring discovers all the current mounted diskgroups and voting files. The diskstring is not persistently recorded in either the SPFILE or the GPnP profile.

diskstring

Specifies the value for the discovery diskstring.

The following example uses dsset to set the current value of the discovery diskstring in the GPnP profile.

ASMCMD [+] > dsset /devices/disk*

dsget command

Retrieves the discovery diskstring value that is used by the Oracle ASM instance and its clients.

dsget [[--normal] [--profile [--force]] [--parameter]]

Flag

Description

--normal

Retrieves the discovery string from the Grid Plug and Play (GPnP) profile and the one that is set in the Oracle ASM instance. It returns one row each for the profile and parameter setting. This is the default setting.

--profile [--force]

Retrieves the discovery string from the GPnP profile. If --force is specified, retrieves the discovery string from the local GPnP profile.

--parameter

Retrieves the ASM_DISKSTRING parameter setting of the Oracle ASM instance.

The following example uses dsget to retrieve the current discovery diskstring value from the GPnP profile and the ASM_DISKSTRING parameter.

ASMCMD [+] > dsget

profile: /devices/disk*

parameter: /devices/disk*

lspwusr command

List the current users from the local Oracle ASM password file.

lspwusr [-H]

-HSuppresses column headers from the output.

ASMCMD [+] > lspwusr

Username sysdba sysoper sysasm

SYS TRUE TRUE TRUE

ASMSNMP TRUE FALSE FALSE

ASMCMD [+] > lspwusr -H

SYS TRUE TRUE TRUE

Satya TRUE TRUE FALSE

orapwusr command

Add, drop, or modify an Oracle ASM password file user. The command requires the SYSASM privilege to run. A user logged in as SYSDBA cannot change its password using this command.

orapwusr {{ {--add | --modify [--password]}

[--privilege {sysasm|sysdba|sysoper}] } | --delete} user

Flag

Description

--add

Adds a user to the password file. Also prompts for a password.

--delete

Drops a user from the password file.

--modify

Changes a user in the password file.

--privilege

Sets the role for the user. The options are sysasm, sysdba, and sysoper.

--password

Prompts for and then changes the password of a user.

user

Name of the user to add, drop, or modify.

orapwusr attempts to update passwords on all nodes in a cluster.

This example adds the Satya to the Oracle ASM password file with the role of the user set to SYSASM.

ASMCMD [+] > orapwusr --add --privilege sysasm Satya

ASMCMD [+] > lspwusr

Username sysdba sysoper sysasm

SYS TRUE TRUE TRUE

Satya TRUE TRUE TRUE

spset command

Sets the location of the Oracle ASM SPFILE in the Grid Plug and Play (GPnP) profile.

spset location

The following is an example of the spset command that sets the location of the Oracle ASM SPFILE command in the dg_data diskgroup.

ASMCMD> spset +DG_DATA/asm/asmparameterfile/asmspfile.ora

spget command

Retrieves the location of the Oracle ASM SPFILE from the Grid Plug and Play (GPnP) profile.

spget

The location retrieved by spget is the location in the GPnP profile, but not always the location of the SPFILE currently used. For example, the location could have been recently updated by spset or spcopy with the -u option on an Oracle ASM instance that has not been restarted. After the next restart of the Oracle ASM, this location point to the ASM SPFILE currently is being used.

The following is an example of the spget command that retrieves and displays the location of the SPFILE from the GPnP profile.

ASMCMD [+] > spget

+DATA/asm/asmparameterfile/registry.253.691575633

spbackup command

Backs up an Oracle ASM SPFILE. spbackup does not affect the GPnP profile.

spbackup source destination

The backup file that is created is not a special file type and is not identified as a SPFILE. This file cannot be copied with spcopy. To copy this backup file, use the ASMCMD cp command.

The first example backs up the Oracle ASM SPFILE from one operating system location to another.

Copies an Oracle ASM SPFILE from source to destination. To use spcopy to copy an Oracle ASM SPFILE into a diskgroup, the diskgroup attribute COMPATIBLE.ASM must be set to 11.2 or greater.

spcopy [-u] source destination

-uupdates the Grid Plug and Play (GPnP) profile.We can also use spset to update the GPnP profile.

Note the following about the use of spcopy:

spcopy can copy an Oracle ASM SPFILE from a diskgroup to a different diskgroup or to an operating system file.

spcopy can copy an Oracle ASM SPFILE from an operating system file to a diskgroup or to an operating system file.

spcopy can copy an Oracle ASM SPFILE when the SPFILE is being used by an open Oracle ASM instance.

After copying the SPFILE, you must restart the instance with the SPFILE in the new location to use that SPFILE. When the Oracle ASM instance is running with the SPFILE in the new location, you can remove the source SPFILE.

The first example copies the Oracle ASM SPFILE from one operating system location to another.

Moves an Oracle ASM SPFILE from source to destination and automatically updates the GPnP profile. To use spmove to move an Oracle ASM SPFILE into a diskgroup, the diskgroup attribute COMPATIBLE.ASM must be set to 11.2 or greater.

spmove source destination

Note the following about the use of spmove:

spmove can move an Oracle ASM SPFILE when the open instance is using a PFILE or a different SPFILE. After moving the SPFILE, you must restart the instance with the SPFILE in the new location to use that SPFILE.

spmove cannot move an Oracle ASM SPFILE when the SPFILE is being used by an open Oracle ASM instance.

The first example moves the Oracle ASM SPFILE from one operating system location to another.

Adds or removes OS users to and from an existing Oracle ASM user group. Only the owner of the user group can use this command. The command requires the SYSASM privilege to run. This command accepts an OS user name or multiple user names separated by spaces. The OS users are typically owners of a database instance home.

grpmod {--add | --delete} diskgroup usergroup user [user...]

Flag

Description

--add

Specifies to add users to the user group.

--delete

Specifies to delete users from the user group.

usergroup

Name of the user group.

user

Name of the user to add or remove from the user group.

The following example adds the asmdba1 and asmdba2 users to the asm_fra user group of the dg_fra diskgroup.

ASMCMD [+] > grpmod –-add dg_fra asm_fra asmdba1 asmdba2

The second example removes the asmdba2 user from the asm_data user group of the dg_data diskgroup.

Changes permissions of a file or list of files. This command accepts a file name or multiple file names separated by spaces. The specified files must be closed.

chmod mode file [file ...]

mode can be one of the following forms:

{ugo|ug|uo|go|u|g|o|a} {+|-} {r|w|rw}
a specifies permissions for all users, u specifies permissions for the owner/user of the file, g specifies the group permissions, and o specifies permissions for other users.

{0|4|6} {0|4|6} {0|4|6}
The first digit specifies owner permissions, the second digit specifies group permissions, and the third digit specifies other permissions.

Flag

Description

6

Read write permissions

4

Read only permissions

0

No permissions

u

Owner permissions, used with r or w

g

Group permissions, used with r or w

o

Other user permissions, used with r or w

a

All user permissions, used with r or w

+

Add a permission, used with r or w

-

Removes a permission, used with r or w

r

Read permission

w

Write permission

file

Name of a file

We can only set file permissions to read-write, read-only, and no permissions. We cannot set file permissions to write-only.

Changes the owner of a file or list of files. This command accepts a file name or multiple file names separated by spaces. The specified files must be closed. Only the Oracle ASM administrator can use this command.

chown user[:usergroup ] file [file ...]

user typically refers to the user that owns the database instance home. Oracle ASM File Access Control uses the OS name to identify a database.

Changes the Oracle ASM user group of a file or list of files. This command accepts a file name or multiple file names separated by spaces. Only the file owner or the Oracle ASM administrator can use this command. If the user is the file owner, then he must also be either the owner or a member of the group for this command to succeed.

mkdg commandCreates a diskgroup based on an XML configuration file which specifies the name of the diskgroup, redundancy, attributes, and paths of the disks that form the diskgroup.mkdg {config_file.xml | 'contents_of_xml_file'}

Flag

Description

config_file

Name of the XML file that contains the configuration for the new diskgroup. mkdg searches for the XML file in the directory where ASMCMD was started unless a path is specified.

contents_of_xml_file

The XML script enclosed in single quotations.

Redundancy is an optional parameter; the default is normal redundancy. For some types of redundancy, disks are required to be gathered into failure groups. In the case that failure groups are not specified for a diskgroup, each disk in the diskgroup belongs to its own failure group.It is possible to set some diskgroup attribute values during diskgroup creation. Some attributes, such as AU_SIZE and SECTOR_SIZE, can be set only during diskgroup creation.The default diskgroup compatibility settings are 10.1 for Oracle ASM compatibility, 10.1 for database compatibility, and no value for Oracle ADVM compatibility.Tags for mkdg XML Configuration File<dg> diskgroup name diskgroup name redundancy normal, external, high<fg> failure group name failure group name</fg><dsk> disk name disk name path disk path size size of the disk to add</dsk><a> attribute name attribute name value attribute value</a></dg>The following is an example of an XML configuration file for mkdg. The configuration file creates a diskgroup named dg_data with normal redundancy. Two failure groups, fg1 and fg2, are created, each with two disks identified by associated disk strings. The diskgroup compatibility attributes are all set to 11.2.<dg name="dg_data" redundancy="normal"><fg name="fg1"><dsk string="/dev/disk1"/><dsk string="/dev/disk2"/></fg><fg name="fg2"><dsk string="/dev/disk3"/><dsk string="/dev/disk4"/></fg><a name="compatible.asm" value="11.2"/><a name="compatible.rdbms" value="11.2"/><a name="compatible.advm" value="11.2"/></dg>The first example executes mkdg with an XML configuration file in the directory where ASMCMD was started.ASMCMD [+] > mkdg data_config.xmlThe second example executes mkdg using information on the command line.ASMCMD [+] > mkdg '<dg name="data"><dsk path="/dev/disk*"/></dg>'

Name of the XML file that contains the changes for the diskgroup. chdg searches for the XML file in the directory where ASMCMD was started unless a path is specified.

contents_of_xml_file

The XML script enclosed in single quotations.

The modification includes adding or deleting disks from an existing diskgroup, and the setting rebalance power level. The power level can set from 0 to the maximum of 11, the same values as the ASM_POWER_LIMIT initialization parameter.When adding disks to a diskgroup, the diskstring must be specified in a format similar to the ASM_DISKSTRING initialization parameter.The failure groups are optional parameters. The default causes every disk to belong to a its own failure group.Dropping disks from a diskgroup can be performed through this operation. An individual disk can be referenced by its Oracle ASM disk name. A set of disks that belong to a failure group can be specified by the failure group name.We can resize a disk inside a diskgroup with chdg. The resize operation fails if there is not enough space for storing data after the resize.Tags for the chdg XML Configuration Template<chdg> update disk clause (add/delete disks/failure groups)name diskgroup to changepower power to perform rebalance<add> items to add are placed here</add><drop> items to drop are placed here</drop><fg> failure groupname failure group name</fg><dsk> diskname disk namepath disk pathsize size of the disk to add</dsk></chdg>The following is an example of an XML configuration file for chdg. This XML file alters the diskgroup named data. The failure group fg1 is dropped and the disk data_0001 is also dropped. The /dev/disk8 disk is added to failure group fg2. The rebalance power level is set to 4.<chdg name="data" power="4"><drop><fg name="fg1"></fg><dsk name="data_0001"/></drop><add><fg name="fg2"><dsk string="/dev/disk8"/></fg></add></chdg>The following are examples of the chdg command with the configuration file or configuration information on the command line.ASMCMD [+] > chdg data_config.xmlASMCMD [+] > chdg '<chdg name="data" power="3"><drop><fg name="fg1"></fg><dsk name="data_0001"/></drop><add><fg name="fg2"><dsk string="/dev/disk5"/></fg></add></chdg>'

rebal command
Rebalances a diskgroup. The power level can be set from 0 to 11. A value of 0 disables rebalancing. If the rebalance power is not specified, the value defaults to the setting of the ASM_POWER_LIMIT initialization parameter.rebal [--power power_value] [-w] diskgroup

Flag

Description

--power

Power setting (0 to 11).

-w

Wait option. Causes ASMCMD to wait for the diskgroup to be rebalanced before returning control to the user. The default is not waiting.

diskgroup

Diskgroup name.

The following example rebalances the dg_fra diskgroup with a power level set to 6.
ASMCMD [+] > rebal --power 6 dg_fra

We can determine if a rebalance operation is occurring with the ASMCMD lsop command.
ASMCMD [+] > lsop
Group_Name Dsk_Num State Power
FRA REBAL RUN 6SQL equivalentrebal command is:SQL> ALTER DISKGROUP diskgroup_name REBALANCE POWER n;

iostat command

Will display I/O statistics of disks in mounted ASM diskgroups, by using V$ASM_DISK_IOSTAT.

Refreshes the statistics display based on the interval value (seconds). Use Ctrl-C to stop the interval display.

To see the complete set of statistics for a diskgroup, use the V$ASM_DISK_IOSTAT view.

Attribute Name

Description

Group_Name

Name of the diskgroup.

Dsk_Name

Name of the disk.

Reads

Number of bytes read from the disk. If the --io option is entered, then the value is displayed as number of I/Os.

Writes

Number of bytes written from the disk. If the --io option is entered, then the value is displayed as number of I/Os.

Cold_Reads

Number of bytes read from the cold disk region. If the --io option is entered, then the value is displayed as number of I/Os.

Cold_Writes

Number of bytes written from the cold disk region. If the --io option is entered, then the value is displayed as number of I/Os.

Hot_Reads

Number of bytes read from the hot disk region. If the --io option is entered, then the value is displayed as number of I/Os.

Hot_Writes

Number of bytes written from the hot disk region. If the --io option is entered, then the value is displayed as number of I/Os.

Read_Err

Number of failed I/O read requests for the disk.

Write_Err

Number of failed I/O write requests for the disk.

Read_Time

I/O time (in hundredths of a second) for read requests for the disk if the TIMED_STATISTICSinitialization parameter is set to TRUE (0 if set to FALSE).

Write_Time

I/O time (in hundredths of a second) for write requests for the disk if the TIMED_STATISTICSinitialization parameter is set to TRUE (0 if set to FALSE).

If a refresh interval is not specified, the number displayed represents the total number of bytes or I/Os. If a refresh interval is specified, then the value displayed (bytes or I/Os) is the difference between the previous and current values, not the total value.The first example displays disk I/O statistics for the data diskgroup in total number of bytes.

The following example adds temp_mc template to the dg_data diskgroup. The new template has the redundancy set to mirror and the striping set to coarse.ASMCMD [+] > mktmpl -G dg_data --redundancy mirror --striping coarse temp_mc

At least one of these options is required: --striping, --redundancy, --primary, or --secondary.The following example updates temp_hf template of the dg_fra diskgroup. The redundancy attribute is set to high and the striping attribute is set to fine.ASMCMD [+] > chtmpl -G dg_fra --redundancy high --striping fine temp_hf

Size of the volume to be created in units of K, M, G, T, P, or E. The unit designation must be appended to the number specified. No space is allowed. For example: 20G

--column

Number of columns in a stripe set. Values range from 1 to 8. The default value is 4.

--width

Stripe width of a volume. The value can range from 4 KB to 1 MB, at power-of-two intervals, with a default of 128 KB.

--redundancy

Redundancy of the Oracle ADVM volume which can be specified for normal redundancy diskgroups. The range of values are as follows: unprotected for non-mirrored redundancy, mirror for double-mirrored redundancy, or high for triple-mirrored redundancy. If redundancy is not specified, the setting defaults to the redundancy level of the diskgroup.

Name of the volume to be created. Can be a maximum of 11 alphanumeric characters; dashes are not allowed. The first character must be alphabetic.

When creating an Oracle ADVM volume, a volume device name is created with a unique Oracle ADVM persistent diskgroup number that is concatenated to the end of the volume name. The unique number can be one to three digits.On Linux, the volume device name is in the format volume_name-nnn, such as volume1-123. On Windows the volume device name is in the format asm-volume_name-nnn, such as asm-volume1-123.A successful volume creation automatically enables the volume device.The volume device file functions as any other disk or logical volume to mount file systems or for applications to use directly.The following example creates volume1 in the dg_data diskgroup with the size set to 10 gigabytes.ASMCMD [+] > volcreate -G dg_data -s 10G --width 64K --column 8 volume1You can determine the volume device name with the volinfo command.ASMCMD [+] > volinfo -G dg_data volume1Diskgroup Name: DATAVolume Name: VOLUME1Volume Device: /dev/asm/volume1-123State: ENABLEDSize (MB): 10240Resize Unit (MB): 512Redundancy: MIRRORStripe Columns: 8Stripe Width (K): 64Usage:Mountpath:ASMCMD [+] > volcreate -G dg_fra -s 100M vol2

voldelete commandDeletes an Oracle ADVM volume.voldelete -G diskgroup volumeTo successfully execute this command, the local Oracle ASM instance must be running and the diskgroup required by this command must be mounted in the Oracle ASM instance. Before deleting a volume, you must ensure that there are no active file systems associated with the volume.The following example deletes volume1 from the dg_data diskgroup.ASMCMD [+] > voldelete -G dg_data volume1

When used without a diskgroup name, specifies all volumes within all diskgroups.When used with a diskgroup name (-G diskgroup -a), specifies all volumes within that diskgroup.

-G

Name of the diskgroup containing the volume.

volume

Name of the volume to be operated on. Can be maximum of 30 alphanumeric characters. The first character must be alphabetic.

You can disable volumes before shutting down an Oracle ASM instance or dismounting a diskgroup to verify that the operations can be accomplished normally without including a force option due to open volume files. Disabling a volume also prevents any subsequent opens on the volume or device file because it no longer exists.Before disabling a volume, you must ensure that there are no active file systems associated with the volume. You must first dismount the Oracle ACFS file system before disabling the volume. You can delete a volume without first disabling the volume.The following example disables volume1 in the dg_data diskgroup.ASMCMD [+] > voldisable -G dg_data volume1

Force the shrinking of a volume that is not an Oracle ACFS volume to suppress the warning message.

volume

Name of the volume to be operated on.

-s

New size of the volume in units of K, M, G, or T.

If the volume is mounted on a non-Oracle ACFS file system, then dismount the file system first before resizing. If the new size is smaller than current, you are warned of possible data corruption. Unless the -f (force) option is specified, you are prompted whether to continue with the operation.If there is an Oracle ACFS file system on the volume, then you cannot resize the volume with the volresize command. You must use the acfsutil size command, which also resizes the volume and file system.The following is an example of the volresize command that resizes volume1 in the dg_data diskgroup to 20 gigabytes.ASMCMD [+] > volresize -G dg_data -s 20G volume1

When running the mkfs command to create a file system, the usage field is set to ACFS and mountpath field is reset to an empty string if it has been set. The usage field should remain at ACFS.When running the mount command to mount a file system, the mountpath field is set to the mount path value to identify the mount point for the file system. After the value is set by the mount command, the mountpath field should not be updated.The following is an example of a volset command that sets the usage string for a volume that is not associated with a file system.ASMCMD [+] > volset -G dg_arch --usagestring 'no file system created' volume1ASMCMD [+] > volset -G dg_data --usagestring 'acfs' volume1