Using ZFS Snapshots for Data Replication on Solaris OS Systems

Description


This article describes how to perform data replication using ZFS snapshots on Solaris OS systems. For demonstration purposes, the primary host

system is the source system and the secondary host system is the destination system. The ZFS datapool1 pool name is replicated from the primary

host system to the secondary host system over SSH. The ZFS datapool1 pool must exist and be the same version on both host systems.


A ZFS snapshot is a read-only copy of a file system or volume. ZFS snapshots can be created almost instantly, and initially consume no additional disk

space within the pool. However, as data within the active dataset changes, the snapshot consumes disk space by continuing to reference the old data

and so prevents the space from being freed. Before creating a ZFS snapshot applications or databases must be shut down and ZFS datasets must be idle.


ZFS snapshots are created by using the zfs snapshot command, which takes as its only argument the name of the snapshot to create. The zfs send command

creates a stream representation of a snapshot that is written to standard output. By default, a full stream is generated. The zfs send output can be redirected

to a file or to a different system.The zfs receive command creates a snapshot whose contents are specified in the stream that is provided on standard input.

If a full stream is received, a new file system is created as well.

Step-by-step guide


  1. Create a full recursive ZFS snapshot of the datapool1 pool on the primary host system and the snapshot name is datapool1_full.

           root@primary:/# zfs snapshot -r datapool1@datapool1_full

     

       2. Send the ZFS datapool1_full snapshot from the primary host system to the secondary host system over SSH.

           root@primary:/# zfs send -R datapool1@datapool1_full | ssh secondary zfs receive -Fduv datapool1
           Password:
           receiving full stream of datapool1@datapool1_full into datapool1@datapool1_full
           received 39.6KB stream in 1 seconds (39.6KB/sec)
           receiving full stream of datapool1/u01@datapool1_full into datapool1/u01@datapool1_full
           received 1.47GB stream in 170 seconds (8.83MB/sec)

     

      3. Create an incremental recursive ZFS snapshot of the datapool1 pool on the primary host system and the snapshot name is datapool1_incremental.

           root@primary:/# zfs snapshot -r datapool1@datapool1_incremental


       4. Send the ZFS datapool1_incremental snapshot from the primary host system to the secondary host system over SSH.

           root@primary:/# zfs send -RI datapool1@datapool1_full datapool1@datapool1_incremental | ssh secondary zfs receive -Fduv datapool1

           Password:

           receiving incremental stream of datapool1@datapool1_incremental into datapool1@datapool1_incremental

           received 160B stream in 1 seconds (160B/sec)

           receiving incremental stream of datapool1/u01@datapool1_incremental into datapool1/u01@datapool1_incremental

           received 1001MB stream in 125 seconds (8.01MB/sec)


          5. Verify ZFS datapool1 sizes on both primary and secondary host systems.

             root@primary:/# zpool list datapool1

             NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT

             datapool1 9.88G 2.44G 7.43G 24% 1.00x ONLINE -


             root@secondary:/# zpool list datapool1

             NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT

             datapool1 9.88G 2.44G 7.43G 24% 1.00x ONLINE -

                    

Related articles

The Oracle Solaris ZFS Administration Guide is located on the URL listed below.

https://docs.oracle.com/cd/E19253-01/819-5461/index.html



© Stromasys, 1999-2024  - All the information is provided on the best effort basis, and might be changed anytime without notice. Information provided does not mean Stromasys commitment to any features described.