Oracle® Database Storage Administrator's Guide 11g Release 2 (11.2) Part Number E10500-01 |
|
|
View PDF |
This section describes the ASMCMD file management commands.
Table 12-15 provides a summary of the file management commands.
Table 12-15 Summary of ASMCMD File Management Commands
Command | Description |
---|---|
Changes the current directory to the specified directory. |
|
Enables you to copy files between disk groups on a local instance and remote instances. |
|
Displays the total disk space occupied by files in the specified Oracle ASM directory and all of its subdirectories, recursively. |
|
Lists the paths of all occurrences of the specified name (with wildcards) under the specified directory. |
|
Lists the contents of an Oracle ASM directory, the attributes of the specified file, or the names and attributes of all disk groups. |
|
Lists the open files. |
|
Creates an alias for system-generated filenames. |
|
Creates Oracle ASM directories. |
|
Displays the path of the current Oracle ASM directory. |
|
Deletes the specified Oracle ASM files or directories. |
|
Deletes the specified alias, retaining the file that the alias points to. |
Purpose
Changes the current directory to the specified directory.
Syntax and Description
cd
[dir
]
dir
can be specified as either an absolute path or a relative path, including the .
and ..
pseudo-directories. dir
can contain wildcard characters. See "Wildcard Characters".
Examples
The following are examples of the cd
command changing into various directories.
Purpose
Enables you to copy files between Oracle ASM disk groups on local instances to and from remote instances.
Syntax and Description
cp
[-i][-f]
[
connect_str
:]
src_file
[
connect_str
:]
tgt_file
The syntax options for the cp
command are described in Table 12-17.
Table 12-17 Options for the cp Command
Option | Description |
---|---|
|
Interactive, prompt before copy file or overwrite |
|
Force, if an existing destination file, remove it and try again without user interaction |
|
The connection string for use with a remote instance copy. |
|
Name of the source file to copy. |
|
A user alias for the created target file name or alias directory name. |
cp
cannot copy files between two remote instances. The local Oracle ASM instance must be either the source or the target of the operation.
You can use the cp
command to:
Copy files from a disk group to the operating system
Copy files from a disk group to a disk group
Copy files from the operating system to a disk group
Some file types cannot be the source or destination of the cp
command. These file types include OCR and OCR backup file types. To back up, copy, or move an ASM SPFILE, use the spbackup
, spcopy
, or spmove
commands.
connect_str
is not required for a local instance copy, which is the default case. In the case of a remote instance copy, you must specify the connect string and Oracle ASM prompts for a password in a non-echoing prompt. The connect_str
is in the form of:
user
@
host
[.
port_number
].
SID
user
, host
, and SID
are required in the connect_str
parameter. The default port number is 1521
.
See Also:
Oracle Database Net Services Administrator's Guide for more information about connect stringssrc_file
must be either the fully qualified file name, the system-generated name, or the Oracle ASM alias.
The cp
command performs a bit-wise copy. There is no data transformation.
Examples
The following are examples of the cp
command. The first example shows a copy of a file in the data
disk group to a file on the operating system. The second example shows a copy of a file on the operating system to the data
disk group.
Example 12-18 Using cp
ASMCMD [+] > cp +data/orcl/datafile/EXAMPLE.265.691577295 /mybackups/example.bak copying +data/orcl/datafile/EXAMPLE.265.691577295 -> /mybackups/example.bak ASMCMD [+] > cp /mybackups/examples.bak +data/orcl/datafile/myexamples.bak copying /mybackups/examples.bak -> +data/orcl/datafile/myexamples.bak
Purpose
Displays the total space used for files in the specified directory and in the entire directory tree under the directory.
Syntax and Description
du
[-H]
[
dir
]
Table 12-18 Options for the du command
Option | Description |
---|---|
|
Name of the directory. |
|
Suppresses column headings from the output. |
If you do not specify dir
, then information about the current directory is displayed. dir
can contain wildcard characters. See "Wildcard Characters".
The following two values are displayed, both in units of megabytes.
Used_MB
- This value does not include mirroring.
Mirror_used_MB
- This value includes mirroring.
For example, if a normal redundancy disk group contains 100 MB of data, then assuming that each file in the disk group is 2-way mirrored, Used_MB
is 100 MB and Mirror_used_MB
is roughly 200 MB.
Example
The following is an example of the du
command. The example shows disk space used in the orcl
directory in data
, including all of the directories under the orcl
directory.
Purpose
Displays the absolute paths of all occurrences of the specified name pattern (with wildcards) in a specified directory and its subdirectories.
Syntax and Description
find
[--type
type
]
dir
pattern
Table 12-19 Options for the find Command
Option | Description |
---|---|
|
Type of target that you want to find. |
|
Directory name where you want to start searching. |
|
Name of a target or a wildcard pattern. |
This command searches the specified directory and all subdirectories under it in the directory tree for the supplied pattern
. The value that you use for pattern
can be a directory name or a filename, and can include wildcard characters. See "Wildcard Characters".
The ASMCMD find
command is case insensitive.
In the output of the command, directory names are suffixed with the slash character (/) to distinguish them from filenames.
You use the --type
flag to find all the files of a particular type (specified as type
). For example, you can search for control files by specifying type
as CONTROLFILE
. Valid values for type
are listed in Table 7-1, "File Types Supported by Automatic Storage Management". These are type values from the type
column of the V$ASM_FILE
view.
Examples
The following are examples of the find
command. The first example searches the data
disk group for files that begin with UNDO
. The second example returns the absolute path of all the control files (--type
CONTROLFILE
) in the +data/orcl
directory.
Purpose
Lists the contents of an Oracle ASM directory, the attributes of the specified file, or the names and attributes of all disk groups.
Syntax and Description
ls [-lsdtLagH] [--reverse][--permission][
pattern
]
Table 12-20 Options for the ls command
Option | Description |
---|---|
(none) |
Displays only filenames and directory names. |
|
Displays extended file information, including striping and redundancy information and whether the file was system-generated (indicated by Not all possible file attributes or disk group attributes are included. To view the complete set of column values for a file or a disk group, query the |
|
Displays file space information. |
|
If the value for the |
|
Reverses the sort order of the listing. |
|
Sorts the listing by timestamp (latest first) instead of by name. |
|
If the value for the |
|
For each listed file, displays the absolute path of the alias that references it, if any. |
|
|
|
Suppresses column headings. |
|
Shows the permissions of a file ( |
|
Name of a file, directory, or pattern. |
Command options enable you to modify and customize the output of the command. Table 12-20 lists the options and their descriptions. For disk group information, this command queries the V$ASM_DISKGROUP_STAT
view by default. If you specify all of the options, then the command shows a union of their attributes, with duplicates removed. If you enter ls
+
, the top level directory structure is displayed.
name
can be a filename or directory name, including wildcard characters. See "Wildcard Characters".
If name
is a directory name, then ls
lists the contents of the directory and depending on flag settings, ls
also lists information about each directory member. Directories are listed with a trailing slash (/) to distinguish them from files.
If the value that you enter for name
is a filename, then ls
lists the file and depending on the flag settings, ls
also lists information about the file. The file must be located in the current directory if the filename is specified with a relative path.
Examples
The following are examples of the ls
command that display various information about directories and the contents of the directories.
Example 12-21 Using ls
ASMCMD [+] > ls +data/orcl/datafile EXAMPLE.265.691577295 SYSAUX.257.691577149 SYSTEM.256.691577149 UNDOTBS1.258.691577151 USERS.259.691577151 ASMCMD [+] > ls -lt +data/orcl/datafile Type Redund Striped Time Sys Name DATAFILE MIRROR COARSE JUL 13 08:00:00 Y EXAMPLE.265.691577295 DATAFILE MIRROR COARSE JUL 13 05:00:00 Y SYSAUX.257.691577149 DATAFILE MIRROR COARSE JUL 13 02:00:00 Y USERS.259.691577151 DATAFILE MIRROR COARSE JUL 13 02:00:00 Y UNDOTBS1.258.691577151 DATAFILE MIRROR COARSE JUL 13 02:00:00 Y SYSTEM.256.691577149 ASMCMD [+] > ls -l +data/orcl/datafile/sy* Type Redund Striped Time Sys Name DATAFILE MIRROR COARSE JUL 13 05:00:00 Y SYSAUX.257.691577149 DATAFILE MIRROR COARSE JUL 13 02:00:00 Y SYSTEM.256.691577149 ASMCMD [+] > ls -s +data/orcl/datafile Block_Size Blocks Bytes Space Name 8192 12801 104865792 214958080 EXAMPLE.265.691577295 8192 88321 723525632 1452277760 SYSAUX.257.691577149 8192 88321 723525632 1452277760 SYSTEM.256.691577149 8192 7681 62922752 131072000 UNDOTBS1.258.691577151 8192 641 5251072 12582912 USERS.259.691577151 ASMCMD [+] > ls --permission +data/orcl/datafile User Group Permission Name rw-rw-rw- EXAMPLE.265.691577295 rw-rw-rw- SYSAUX.257.691577149 rw-rw-rw- SYSTEM.256.691577149 rw-rw-rw- UNDOTBS1.258.691577151 rw-rw-rw- USERS.259.691577151
Purpose
Lists the open files of the local clients.
Syntax and Description
lsof
[-H
] {-G
diskgroup
|--dbname
db
| -C
instance
}Table 12-21 Options for the lsof command
Option | Description |
---|---|
|
Suppresses column headings. |
|
List files only from this specified disk group. |
|
List files only from this specified database. |
|
List files only from this specified instance. |
Example
The following are examples of the lsof
command. The first example lists the open files for the data
disk group. The second example lists the open files for the Oracle ASM instance.
Example 12-22 Using lsof
ASMCMD [+] > lsof -G data DB_Name Instance_Name Path orcl orcl +data/orcl/controlfile/current.260.691577263 orcl orcl +data/orcl/datafile/example.265.691577295 orcl orcl +data/orcl/datafile/sysaux.257.691577149 orcl orcl +data/orcl/datafile/system.256.691577149 orcl orcl +data/orcl/datafile/undotbs1.258.691577151 orcl orcl +data/orcl/datafile/users.259.691577151 orcl orcl +data/orcl/onlinelog/group_1.261.691577267 orcl orcl +data/orcl/onlinelog/group_2.262.691577271 orcl orcl +data/orcl/onlinelog/group_3.263.691577275 orcl orcl +data/orcl/tempfile/temp.264.691577287 ASMCMD [+] > lsof -C +ASM DB_Name Instance_Name Path asmvol +ASM +data/VOLUME1.271.679226013 asmvol +ASM +data/VOLUME2.272.679227351
Purpose
Creates an alias for the specified system-generated filename.
Syntax and Description
mkalias
file
alias
Table 12-22 Options for the mkalias command
Option | Description |
---|---|
|
System-generated file name. |
|
Alias for the file name. |
alias
must be in the same disk group as the system-generated file. Only one alias is permitted for each Oracle ASM file.
Example
The following example creates the sysaux.f
alias for the fully qualified filename +data/orcl/DATAFILE/SYSAUX.257.691577149
. Following the mkalias
command, ls
-a
is run to check the results.
Example 12-23 Using mkalias
ASMCMD [+data/orcl/datafile] > mkalias SYSAUX.257.691577149 sysaux.f ASMCMD [+data/orcl/datafile] > ls -a none => EXAMPLE.265.691577295 none => SYSTEM.256.691577149 none => UNDOTBS1.258.691577151 none => USERS.259.691577151 +DATA/ORCL/DATAFILE/sysaux.f => SYSAUX.257.691577149 sysaux.f
Purpose
Creates Oracle ASM directories under the current directory.
Syntax and Description
mkdir
dir
[dir
. . .]
Table 12-23 Options for the mkdir command
Option | Description |
---|---|
|
Directory name that you want to create. |
The current directory can be created by the system or by the user. You cannot create a directory at the root (+) level.
Example
The following is an example of the mkdir
command. The example creates the directories subdir1
and subdir2
at the disk group level in the disk group data
.
Purpose
Displays the absolute path of the current directory.
Syntax and Description
pwd
Example
The following is an example of the pwd
command. The example displays the current directory.
Purpose
Deletes the specified Oracle ASM files and directories.
Syntax and Description
rm [-f|-r]
name
[name
...]
Table 12-24 Options for the rm command
Option | Description |
---|---|
|
Recursively deletes files and subdirectories. |
|
Forces the deletion of files and subdirectories. |
|
Name of the file, pattern, or directory you want to remove. |
If name
is a file or alias, then the rm
command can delete the file or alias only if it is not currently in use. 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. To delete only an alias and retain the file that the alias references, use the rmalias
command.
Note:
When you delete all of the files in a system-created directory, the directory is removed. If the parent directories are empty, all of the parent directories are also removed.name
can contain wildcard characters. See "Wildcard Characters".
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. With -r
option you can 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.If a wildcard character matches an alias or a system-generated file that has an alias, then both the alias and the system-generated file that it references are deleted. 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.
For example, if you have a user alias, +data/dir1/file.alias
that points to +data/orcl/DATAFILE/System.256.146589651
, then running the rm -r +data/dir1
command removes the +data/dir1/file.alias
and +data/orcl/DATAFILE/System.256.146589651
.
Example
The following are examples of the rm
command. The first example deletes the myexamples.bak
file. The second example removes the subdir2
directory and its contents.
Purpose
Removes the specified aliases, retaining the files that the aliases reference.
Syntax and Description
rmalias [-r]
alias
[alias
...]
Table 12-25 Options for the rmalias command
Option | Description |
---|---|
|
Recursively removes aliases. |
|
Alias for the file name or directory. |
The -r
flag enables you to remove 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.
Example
The following is an example of the rmalias
command. The example deletes the alias sysaux.f
, retaining the data file that it references.