9.7.10 Doing a Sparse Copy
The ASM cp
command copies a sparse file to a new destination. However, this operation copies the sparse file with all the blocks instantiated from the parent. The “sparse copy” feature enables you to do a sparse copy of a file.
You can have multiple ASM instances running at the same time. If an operation involves a source or a destination on a different ASM instance other than the one it is executing on, it is treated as a remote ASM instance. You can do a sparse copy on a local ASM instance, or between a local and a remote ASM instance. However, sparse copy does not work between two remote ASM instances.
To do a sparse copy, you use the new --sparse
option in the existing ASM cp
command. The syntax looks like the following:
ASMCMD> cp --sparse <src_sparse_file> <tgt_file>
A new ASM command called setsparseparent
enables you to set the parent of a sparse file. If you do a sparse copy of a file to a sparse destination on a local ASM instance, its parent is set as part of the sparse copy operation. However, if the destination is on a remote ASM instance, you have to set its parent explicitly using the setsparseparent
command.
The setsparseparent
command requires sparse child file and parent file as parameters. It sets the parent of the sparse child file to the new parent file. The syntax looks like the following:
ASMCMD> setsparseparent <sparse_file> <parent_file>
The cp
ASM command performs the following validations before doing a sparse copy operation. The operation is allowed only if it satisfies the following criteria:
-
The source file must exist and must be a sparse file.
-
If you specify multiple source sparse files, all of them must be on the same ASM instance.
-
Copying multiple sparse files on a remote ASM instance to a destination on a local ASM instance and vice versa is allowed provided all source files are on the same ASM instance.
-
Destination file should be backed by a sparse disk group. However, it can be a non-sparse file if event “KFTST_KFPKG_CP_SPARSE” is set. This event is required to validate sparse copy operation by merging and copying the files to a non-sparse destination.
-
Both source and destination cannot be on a remote ASM instance. However, either source or destination can be on a remote ASM instance.
-
If the destination is on a remote ASM instance, its file type cannot be validated and you have to ensure that it is backed by a sparse disk group. You also have to set the parent explicitly using the ASM
setsparseparent
command. -
If the destination is a non-sparse file and you run the
setsparseparent
command, the command will fail because the child file should be sparse. This is a second-level validation if the destination is a non-sparse file.
The setsparseparent
ASM command performs the following validations before it sets the parent. The operation is allowed only if it satisfies the following criteria:
-
The child file must exist and must be a sparse file.
-
The parent file must exist. It can be a sparse or a non-sparse file.
-
Parent and child files must be present on same ASM instance.
Note:
You have to ensure that the files you specify in the setsparseparent
ASM command have a valid parent-child relationship. The command cannot perform this check for files on remote ASM instances. If the files do not have a valid parent-child relationship, then data integrity and corruption issues are likely to occur.
Example 1: The following ASM command copies sparse file “TBS_1.264.908376549” to the destination “+SPARSEDG/child_1”.
ASMCMD> cp –-sparse +SPARSEDG/MERGE/DATAFILE/TBS_1.264.908376549 +SPARSEDG/child_1
Example 2: The following ASM command sets parent “tbs_1.269.908374993” for the sparse file “remote_child_10”.
ASMCMD> setsparseparent +SPARSEDG/remote_child_10 +DATAFILE/DATAFILE/tbs_1.269.908374993
Example 3: The following command copies sparse child files child_1, child_2 and child_3 to the destination directory +SPARSEDG.
ASMCMD> cp –-sparse +SPARSEDG/DATAFILE/child_1 +SPARSEDG/DATAFILE/child_2 +SPARSEDG/DATAFILE/child_3 +SPARSEDG/
Parent topic: Managing Exadata Snapshots