The following steps illustrate the use of disk mirroring commands and their effect on selected columns of master..sysdevices. The status number and its hexidecimal equivalent for each entry in sysdevices are in parentheses:
Initialize a new test device using:
disk init name = "test", physname = "/usr/sybase/test.dat", size=5120
This inserts the following values into columns of master..sysdevices:
name phyname mirrorname status test /usr/sybase/test.dat NULL 16386
Status 16386 indicates that the device is a physical device (2, 0x00000002), and any writes are to a UNIX file (16384, 0x00004000). Since the mirrorname column is null, mirroring is not enabled on this device.
Mirror the test device using:
disk mirror name = "test", mirror = "/usr/sybase/test.mir"
This changes the master..sysdevices columns to:
name phyname mirrorname status test /usr/sybase/test.dat /usr/sybase/test.mir 17122
Status 17122 indicates that mirroring is currently enabled (512, 0x00000200) on this device. Reads are mirrored (128, 0x00000080), and writes are mirrored to a UNIX file device (16384, 0x00004000), the device is mirrored (64, 0x00000040), and serial (32, 0x00000020). The device is a physical disk (2, 0x00000002).
Disable the mirror device (the secondary side), but retain that mirror:
disk unmirror name = "test", side = secondary, mode = retain
name phyname mirrorname status test /usr/sybase/test.dat /usr/sybase/test.mir 18658
Status 18658 indicates that the device is mirrored (64, 0x00000040), and the mirror device has been retained (2048, 0x00000800), but mirroring has been disabled (512 bit off), and only the primary device is used (256 bit off). Reads are mirrored (128, 0x00000080), and writes are mirrored to a UNIX file (16384, 0x00004000) and are in serial (32, 0x00000020). The device is a physical disk (2, 0x00000002).
Remirror the test device:
disk remirror name = "test"
This resets the master..sysdevices columns to:
name phyname mirrorname status test /usr/sybase/test.dat /usr/sybase/test.mir 17122
Status 17122 indicates that mirroring is currently enabled (512, 0x00000200) on this device. Reads are mirrored (128, 0x00000080), and writes are mirrored to a UNIX file device (16384, 0x00004000), the device is mirrored (64, 0x00000040), and serial (32, 0x00000020). The device is a physical disk (2, 0x00000002).
Disable the test device (the primary side), but retain that mirror:
disk unmirror name = "test", side = "primary", mode = retain
This changes the master..sysdevices columns to:
name phyname mirrorname status test /usr/sybase/test.dat /usr/sybase/test.mir 16866
Status 16866 indicates that the device is mirrored (64, 0x00000040), but mirroring has been disabled (512 bit off) and that only the secondary device is used (256, 0x00000100). Reads are mirrored (128, 0x00000080), and writes are mirrored to a UNIX file (16384, 0x00004000), and are in serial (32, 0x00000020). The device is a physical disk (2, 0x00000002).
Remirror the test device:
disk remirror name = "test"
This resets the master..sysdevices columns to:
name phyname mirrorname status test /usr/sybase/test.dat /usr/sybase/test.mir 17122
Status 17122 indicates that mirroring is currently enabled (512, 0x00000200) on this device. Reads are mirrored (128, 0x00000080), and writes are mirrored to a UNIX file device (16384, 0x00004000), the device is mirrored (64, 0x00000040), and serial (32, 0x00000020). The device is a physical disk (2, 0x00000002).
Disable the test device (the primary side), and remove that mirror:
disk unmirror name = "test", side = "primary", mode = remove
This changes the master..sysdevices columns to:
name phyname mirrorname status test /usr/sybase/test.dat NULL 16386
Status 16386 indicates that the device is a physical device (2, 0x00000002), and any writes are to a UNIX file (16384, 0x00004000). Since the mirrorname column is null, mirroring is not enabled on this device.
Remove the test device to complete the tutorial:
sp_dropdevice test
This removes all entries for the test device from master..sysdevices.