Creating a snapshot mirror of a volume or volume set used by the database

With Database FlashSnap, you can mirror the volumes used by the database to a separate set of disks, and those mirrors can be used to create a snapshot of the database. These snapshot volumes can be split and placed in a separate disk group. This snapshot disk group can be imported on a separate host, which shares the same storage with the primary host. The snapshot volumes can be resynchronized periodically with the primary volumes to get recent changes of the primary database. If the primary containers become corrupted, you can quickly restore them from the snapshot volumes. Snapshot volumes can be used for a variety of purposes, including backup and recovery, and creating a clone database.

You must create snapshot mirrors for all of the volumes used by the database containers before you can create a snapshot of the database.

Before creating a snapshot mirror, make sure the following conditions have been met:

Prerequisites

  • You must be logged in as superuser (root).

  • The disk group must be version 110 or later. For more information on disk group versions, see the vxdg(1M) online manual page.

  • Be sure that a data change object (DCO) and a DCO log volume are associated with the volume for which you are creating the snapshot.

  • Persistent FastResync must be enabled on the existing database volumes and disks must be assigned for the snapshot volumes. FastResync optimizes mirror resynchronization by tracking updates to stored data that have been missed by a mirror. When a snapshot mirror is reattached to its primary volumes, only the updates that were missed need to be re-applied to resynchronize it. FastResync increases the efficiency of the volume snapshot mechanism to better support operations such as backup and decision support. For detailed information about FastResync, see the Veritas Volume Manager Administrator's Guide.

  • Snapshot mirrors and their associated DCO logs should be on different disks than the original mirror plexes, and should be configured correctly for creating snapshots by the system administrator.

  • When creating a snapshot mirror, create the snapshot on a separate controller and separate disks from the primary volume.

  • Snapplan validation (db2ed_vmchecksnap) fails if any volume in the disk group is not used for the database.

Usage notes

  • Create a separate disk group for DB2 database-related files.

  • Do not share volumes between DB2 database files and other software.

  • INSTANCE_HOME cannot be included in the snapshot mirror.

  • Resynchronization speed varies based on the amount of data changed in both the primary and snapshot volumes during the break-off time.

  • Do not share any disks between the original mirror and the snapshot mirror.

  • Snapshot mirrors for datafiles and archive logs should be created so that they do not share any disks with the data of the original volumes. If they are not created in this way, the VxVM disk group cannot be split and, as a result, Database FlashSnap will not work.

Note:

Database FlashSnap commands support third-mirror break-off snapshots only. The snapshot mirror must be in the SNAPDONE state.

To create a snapshot mirror of a volume

  1. Create a volume:

    vxassist -g diskgroup make volume_name size disk_name

    For example:

    # vxassist -g PRODdg make snapvset_1 8g data01
  2. Create a DCO and enable FastResync on the volume:

    vxsnap -g diskgroup prepare volume_name [alloc=storage_attribute]

    For example:

    # vxsnap -g PRODdg prepare snapvset alloc="snap01"
  3. Verify that a DCO and DCO log are attached to the volume:

    vxprint -g diskgroup -F%fastresync volume_name
    vxprint -g diskgroup -F%hasdcolog volume_name

    This command returns on if a DCO and DCO log are attached to the specified volume.

    For example:

    # vxprint -g PRODdg -F%fastresync snapdata
    on
    # vxprint -g PRODdg -F%hasdcolog snapdata
    on
  4. Create a mirror of the volume:

    vxsnap -g diskgroup addmir volume_name [alloc=storage_attribute]

    For example:

    # vxsnap -g PRODdg addmir snapdata alloc="data02"
  5. List the available mirrored data plex for the volume:

    vxprint -g diskgroup -F%name -e"pl_v_name in \"volume_name\""

    For example:

    # vxprint -g PRODdg -F%name -e"pl_v_name in\"snapdata\""
    snapdata-01
    snapdata-02
  6. Set the dbed_flashsnap tag on the break-off data plex for the volume:

    vxedit -g diskgroup set putil2=dbed_flashsnap plex_name

    For example:

    # vxedit -g PRODdg set putil2=dbed_flashsnap snapdata-02
  7. Verify that the dbed_flashsnap tag has been set on the data plex for each volume in the volume set:

    vxprint -g diskgroup -F%name -e"pl_v_name in \"volume_name\" \
    && p2 in \"dbed_flashsnap\""

    For example:

    # vxprint -g PRODdg -F%name -e"pl_v_name in \"snapdata\" \
    && p2 in \"dbed_flashsnap\""
    snapdata-02
  8. Verify the disk group configuration:

    vxprint -g diskgroup

    For example:

    # vxprint -g PRODdg
    
    TY NAME         ASSOC           KSTATE   LENGTH   PLOFFS STATE    TUTIL0 PUTIL0
    dg PRODdg       PRODdg          -        -        -      -        -      -
    
    dm data01       Disk_17         -        33483648 -      -        -      -
    dm data02       Disk_24         -        33483648 -      -        -      -
    
    v  snapdata     fsgen           ENABLED  16777216 -      ACTIVE   -      -
    pl snapdata-01  snapdata        ENABLED  16777216 -      ACTIVE   -      -
    sd data01-01    snapdata-01     ENABLED  16777216 0      -        -      -
    pl snapdata-02  snapdata        ENABLED  16777216 -      SNAPDONE -      -
    sd data02-01    snapdata-02     ENABLED  16777216 0      -        -      -
    dc snapdata_dco snapdata        -        -        -      -        -      -
    v  snapdata_dcl gen             ENABLED  1696     -      ACTIVE   -      -
    pl snapdata_dcl-01 snapdata_dcl ENABLED  1696     -      ACTIVE   -      -
    sd data01-02    snapdata_dcl-01 ENABLED  1696     0      -        -      -
    pl snapdata_dcl-02 snapdata_dcl DISABLED 1696    -       DCOSNP   -      -
    sd data02-02    snapdata_dcl-02 ENABLED  1696     0      -        -      -

To create a snapshot mirror of a volume set

  1. Create a volume:

    vxassist -g diskgroup make volume_name size disk_name

    For example:

    # vxassist -g PRODdg make snapvset_1 8g snap01
    # vxassist -g PRODdg make snapvset_2 4g snap01
  2. Create a volume set for use by VxFS:

    vxvset -g diskgroup -t vxfs make vset_name volume_name

    For example:

    # vxvset -g PRODdg -t vxfs make snapvset snapvset_1
  3. Add the volume to the volume set:

    vxvset -g diskgroup addvol vset_name volume_name

    For example:

    # vxvset -g PRODdg addvol snapvset snapvset_2
  4. Create a DCO and enable FastResync on the volume set:

    vxsnap -g diskgroup prepare vset_name [alloc=storage_attribute]

    For example:

    # vxsnap -g PRODdg prepare snapvset alloc="snap01"
  5. Verify that a DCO and DCO log are attached to each volume in the volume set:

    vxprint -g diskgroup -F%fastresync volume_name
    vxprint -g diskgroup -F%hasdcolog volume_name

    This command returns on if a DCO and DCO log are attached to the specified volume.

    For example:

    # vxprint -g PRODdg -F%fastresync snapvset_1
    on
    # vxprint -g PRODdg -F%fastresync snapvset_2
    on
    # vxprint -g PRODdg -F%hasdcolog snapvset_1
    on
    # vxprint -g PRODdg -F%hasdcolog snapvset_2
    on
  6. Create a mirror of the volume set volumes:

    vxsnap -g diskgroup addmir vset_name [alloc=storage_attribute]

    For example:

    # vxsnap -g PRODdg addmir snapvset alloc="snap02"
  7. List the available mirrored data plex for each volume in the volume set:

    vxprint -g diskgroup -F%name -e"pl_v_name in \"volume_name\""

    For example:

    # vxprint -g PRODdg -F%name -e"pl_v_name in\"snapvset_1\""
    snapvset_1-01
    snapvset_1-02
    
    # vxprint -g PRODdg -F%name -e"pl_v_name in\"snapvset_2\""
    snapvset_2-01
    snapvset_2-02
  8. Set the dbed_flashsnap tag on the break-off data plex for each volume in the volume set:

    vxedit -g diskgroup set putil2=dbed_flashsnap plex_name

    For example:

    # vxedit -g PRODdg set putil2=dbed_flashsnap snapvset_1-02
    # vxedit -g PRODdg set putil2=dbed_flashsnap snapvset_2-02
  9. Verify that the dbed_flashsnap tag has been set on the data plex for each volume in the volume set:

    vxprint -g diskgroup -F%name -e"pl_v_name in \"volume_name\" \
    && p2 in \"dbed_flashsnap\""

    For example:

    # vxprint -g PRODdg -F%name -e"pl_v_name in \"snapvset_1\" \
    && p2 in \"dbed_flashsnap\""
    snapvset_1-02
    
    # vxprint -g PRODdg -F%name -e"pl_v_name in \"snapvset_2\" \
    && p2 in \"dbed_flashsnap\""
    snapvset_2-02
  10. Verify the snapshot volume configuration:

    vxprint -g diskgroup

    For example:

    # vxprint -g PRODdg
    TY NAME         ASSOC               KSTATE   LENGTH   PLOFFS STATE    TUTIL0  PUTIL0
    dg PRODdg       PRODdg              -        -        -      -        -       -
    
    dm snap01       Disk_9              -        33483648 -      -        -       -
    dm snap02       Disk_11             -        33483648 -      -        -       -
    
    vt snapvset     -                   ENABLED  -        -      ACTIVE   -       -
    v  snapvset_1   snapvset            ENABLED  16777216 -      ACTIVE   -       -
    pl snapvset_1-01 snapvset_1         ENABLED  16777216 -      ACTIVE   -       -
    sd snap01-01    snapvset_1-01       ENABLED  16777216 0      -        -       -
    pl snapvset_1-02 snapvset_1         ENABLED  16777216 -      SNAPDONE -       -
    sd snap02-01    snapvset_1-02       ENABLED  16777216 0      -        -       -
    dc snapvset_1_dco snapvset_1        -        -        -      -        -       -
    v  snapvset_1_dcl gen               ENABLED  1696     -      ACTIVE   -       -
    pl snapvset_1_dcl-01 snapvset_1_dcl ENABLED  1696     -      ACTIVE   -       -
    sd snap01-03    snapvset_1_dcl-01   ENABLED  1696     0      -        -       -
    pl snapvset_1_dcl-02 snapvset_1_dcl DISABLED 1696     -      DCOSNP   -       -
    sd snap02-02    snapvset_1_dcl-02   ENABLED  1696     0      -        -       -
    v  snapvset_2   snapvset            ENABLED  8388608  -      ACTIVE   -       -
    pl snapvset_2-01 snapvset_2         ENABLED  8388608  -      ACTIVE   -       -
    sd snap01-02    snapvset_2-01       ENABLED  8388608  0      -        -       -
    pl snapvset_2-02 snapvset_2         ENABLED  8388608  -      SNAPDONE -       -
    sd snap02-03    snapvset_2-02       ENABLED  8388608  0      -        -       -
    dc snapvset_2_dco snapvset_2        -        -        -      -        -       -
    v  snapvset_2_dcl gen               ENABLED  1120     -      ACTIVE   -       -
    pl snapvset_2_dcl-01 snapvset_2_dcl ENABLED  1120     -      ACTIVE   -       -
    sd snap01-04    snapvset_2_dcl-01   ENABLED  1120     0      -        -       -
    pl snapvset_2_dcl-02 snapvset_2_dcl DISABLED 1120     -      DCOSNP   -       -
    sd snap02-04    snapvset_2_dcl-02   ENABLED  1120     0      -        -       -

This example shows the steps involved in creating a snapshot mirror for the volume data_vol belonging to the disk group PRODdg.

Prepare the volume data_vol for mirroring:

# vxsnap -g PRODdg prepare data_vol alloc=PRODdg01

Verify that FastResync is enabled:

# vxprint -g PRODdg -F%fastresync data_vol
on

Verify that a DCO and a DCO log are attached to the volume:

# vxprint -g PRODdg -F%hasdcolog data_vol
on

Create a snapshot mirror of data_vol:

# vxsnap -g PRODdg addmir data_vol alloc=PRODdg02

List the data plexes:

# vxprint -g PRODdg -F%name -e"pl_v_name in \"data_vol\""
data_vol-01
data_vol-02

Choose the plex that is in the SNAPDONE state. Use the vxprint -g diskgroup command to identify the plex that is in the SNAPDONE state.

Decide which data plex you want to use and set the tag name tag for it:

# vxedit -g PRODdg set putil2=PRODtag data_vol-02

Verify that the PRODtag tag has been set to the desired data plex, data_vol-02:

# vxprint -g PRODdg -F%name -e"pl_v_name in \"data_vol\" \
&& p2 in \"PRODtag\""
data_vol-02

To verify that the snapshot volume was created successfully, use the vxprint -g disk_group command as follows:

# vxprint -g PRODdg
v  data_vol      fsgen                              ENABLED     4194304     -        ACTIVE   -       -
pl data_vol-01   data_vol                   ENABLED     4194304     -        ACTIVE   -       -
sd PRODdg03-01   data_vol-01        ENABLED     4194304     0        -        -       -
pl data_vol-02   data_vol                   ENABLED     4194304     -        SNAPDONE -       -
sd PRODdg02-01   data_vol-02        ENABLED     4194304     0        -        -       -
dc data_vol_dco  data_vol                   -        -        -        -        -       -
v  data_vol_dcl  gen                                        ENABLED     560         -        ACTIVE   -       -
pl data_vol_dcl-01 data_vol_dcl  ENABLED        560      -        ACTIVE   -       -
sd PRODdg01-01   data_vol_dcl-01 ENABLED        5600     -        -        -       -
pl data_vol_dcl-02 data_vol_dcl  DISABLED   560      -        DCOSNP   -       -
sd PRODdg02-02   data_vol_dcl-02 ENABLED        5600     -        -        -       -

Identify that the specified plex is in the SNAPDONE state. In this example, it is data_vol-02.

The snapshot mirror is now ready to be used.