VxVM root磁盘封装和镜像

VxVM 或者任何卷管理器的最佳功能之一就是数据冗余。
根磁盘是最重要的磁盘之一,因为它包含完整的操作系统。
所以镜像根盘是非常重要的。
VxVM 为我们提供了镜像根磁盘的功能。
但为此,我们首先需要通过封装根磁盘来使 VxVM 控制下的根磁盘。
根磁盘封装保留数据。
封装启动盘通常称为rootability,即能够将所有根磁盘FS(如root、swap 等)置于VxVM 控制之下。
让我们看看如何封装和镜像根磁盘。

现在首先记下当前启动操作系统的根磁盘。
在我们的例子中,它是 c1t0d0。

# df -h /
Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c1t0d0s0       15G   5.9G   8.6G    41%    /

现在我们将使用 vxdiskadm 实用程序封装根磁盘。
选择选项 2:“封装一个或者多个磁盘”。

# vxdiskadm
......(other options omitted for brevity)......
 2      Encapsulate one or more disks
Select an operation to perform: 2
Encapsulate one or more disks
Menu: VolumeManager/Disk/Encapsulate
  Use this operation to convert one or more disks to use the Volume Manager.
  This adds the disks to a disk group and replaces existing partitions
  with volumes.  Disk encapsulation requires a reboot for the changes
  to take effect.

现在我们可以有各种磁盘选择示例。
我将使用选项“list”列出 VxVM 控制下的可用磁盘。
列表选项仅显示受 VxVM 控制的磁盘,例如:已封装或者已初始化。
现在我们可以看到我们要封装的磁盘例如:c1t0d0

More than one disk or pattern may be entered at the prompt.  Here are
  some disk selection examples:
  all:          all disks
  c3 c4t2:      all disks on both controller 3 and controller 4, target 2
  c3t4d2:       a single disk (in the c#t#d# naming scheme)
  xyz_0 :       a single disk (in the enclosure based naming scheme)
  xyz_ :        all disks on the enclosure whose name is xyz
Select disk devices to encapsulate:
[[pattern-list],all,list,q,?] list
DEVICE       DISK         GROUP        STATUS
c1t0d0       -            -            online invalid
c1t1d0       -            -            online invalid
Select disk devices to encapsulate:
[[pattern-list],all,list,q,?] c1t0d0
  Here is the disk selected.  Output format: [Device_Name]
  c1t0d0
Continue operation? [y,n,q,?]  (default: y) y

现在为我们的 rootdisk 选择磁盘组名称,例如:rootdg。
还将磁盘的名称指定为 rootdisk。
我们将使用另一个磁盘作为镜像并将其命名为 rootmirror。

You can choose to add this disk to an existing disk group or to
  a new disk group.  To create a new disk group, select a disk group
  name that does not yet exist.
Which disk group [[group],list,q,?] rootdg
Create a new group named rootdg? [y,n,q,?]  (default: y) y
Use a default disk name for the disk? [y,n,q,?]  (default: y) n
  A new disk group will be created named rootdg and the selected
  disks will be encapsulated and added to this disk group with
  disk names that will be specified interactively.
  c1t0d0
Continue with operation? [y,n,q,?]  (default: y) y
  The following disk has been selected for encapsulation.
  Output format: [Device_Name]
  c1t0d0
Continue with encapsulation? [y,n,q,?]  (default: y) y
Enter disk name for c1t0d0 [[name],q,?]  (default: rootdg01) rootdisk
  A new disk group rootdg will be created and the disk device c1t0d0 will
  be encapsulated and added to the disk group with the disk name rootdisk.
  The c1t0d0 disk has been configured for encapsulation.
  The first stage of encapsulation has completed successfully.  You
  should now reboot your system at the earliest possible opportunity.
  The encapsulation will require two or three reboots which will happen
  automatically after the next reboot.  To reboot execute the command:
shutdown -g0 -y -i6
  This will update the /etc/vfstab file so that volume devices are
  used to mount the file systems on this disk device.  You will need
  to update any other references such as backup scripts, databases,
  or bananaally created swap devices.
Encapsulate other disks? [y,n,q,?]  (default: n) n

现在通过键入“q”退出 vxdiskadm 实用程序。
我们必须重新启动系统才能完成根封装过程。

# shutdown -i6 -g0 -y

重新启动后,我们应该会注意到“df -h”命令输出的变化:

# df -h /
Filesystem                    size   used  avail capacity  Mounted on
/dev/vx/dsk/bootdg/rootvol     15G   6.0G   8.6G    41%    /

还要注意 /etc/vfstab 文件条目中的更改。
现在文件系统和原始设备已更改。

# cat /etc/vfstab |grep vx
/dev/vx/dsk/bootdg/swapvol      -       -       swap    -       no      
/dev/vx/dsk/bootdg/rootvol      /dev/vx/rdsk/bootdg/rootvol     /       ufs    no

检查磁盘组状态并检查 vxprint 命令输出中的 rootvol 和 swapvol。

# vxdg list
NAME         STATE           ID
rootdg       enabled         1382248262.12.onitroad
# vxprint -htg rootdg
..............
dg rootdg       default      default  27000    1382248262.12.onitroad
dm rootdisk     c1t0d0s2     auto     80321    33399135 
v  rootvol      -            ENABLED  ACTIVE   31374945 ROUND     -        root
pl rootvol-01   rootvol      ENABLED  ACTIVE   31374945 CONCAT    -        RW
sd rootdisk-02  rootvol-01   rootdisk 2024190  31374945 0         c1t0d0   ENA
v  swapvol      -            ENABLED  ACTIVE   2024190  ROUND     -        swap
pl swapvol-01   swapvol      ENABLED  ACTIVE   2024190  CONCAT    -        RW
sd rootdisk-01  swapvol-01   rootdisk 0        2024190  0         c1t0d0   ENA

现在向rootdg 添加一个镜像磁盘并将其命名为rootmirror。
我们将使用这个 diks 来镜像 rootvol 和 swapvol。
记住设置格式和 noreserve 选项。

# vxdisksetup -i c1t1d0 format=sliced noreserve
# vxdg -g rootdg adddisk rootmirror=c1t1d0
# vxdiskadm
...... output omitted for brevity ....
 6      Mirror volumes on a disk
Select an operation to perform: 6
Mirror volumes on a disk
Menu: VolumeManager/Disk/Mirror
  This operation can be used to mirror volumes on a disk.  These
  volumes can be be mirrored onto another disk or onto any
  available disk space.  Volumes will not be mirrored if they are
  already mirrored.  Also, volumes that are comprised of more than
  one subdisk will not be mirrored.
  Mirroring volumes from the boot disk will produce a disk that
  can be used as an alternate boot disk.
  At the prompt below, supply the name of the disk containing the
  volumes to be mirrored.
Enter disk name [[disk],list,q,?] list
Disk group: rootdg
DM NAME         DEVICE       TYPE     PRIVLEN  PUBLEN   STATE
dm rootdisk     c1t0d0s2     auto     80321    33399135 
dm rootmirror   c1t1d0s2     auto     80321    33415200 

Enter disk name [[disk],list,q,?] rootdisk
  You can choose to mirror volumes from disk rootdisk onto any
  available disk space, or you can choose to mirror onto a specific
  disk.  To mirror to a specific disk, select the name of that disk.
  To mirror to any available disk space, select "any".
Enter destination disk [[disk],list,q,?]  (default: any) rootmirror
  The requested operation is to mirror all volumes on disk rootdisk
  in disk group rootdg onto available disk space on disk rootmirror.
  VxVM  NOTICE V-5-2-3650 This operation can take a long time to complete.
Continue with operation? [y,n,q,?]  (default: y) y
VxVM vxmirror INFO V-5-2-22   Mirror volume swapvol ...
VxVM vxmirror INFO V-5-2-22   Mirror volume rootvol ...
  VxVM  INFO V-5-2-674 Mirroring of disk rootdisk is complete.
Mirror volumes on another disk? [y,n,q,?]  (default: n)n

现在退出 vxdiskadm 实用程序。
如果我们想检查镜像的状态,我们可以打开一个新终端并执行以下命令。

# vxtask list
TASKID  PTID TYPE/STATE    PCT   PROGRESS
   160           ATCOPY/R 25.19% 0/2024190/509952 PLXATT swapvol swapvol-02 rootdg
# vxtask monitor
..........
   164           ATCOPY/R 03.52% 0/31374945/1105920 PLXATT rootvol rootvol-02 rootdg
   164           ATCOPY/R 03.54% 0/31374945/1110016 PLXATT rootvol rootvol-02 rootdg
   164           ATCOPY/R 03.55% 0/31374945/1114112 PLXATT rootvol rootvol-02 rootdg
   164           ATCOPY/R 03.56% 0/31374945/1118208 PLXATT rootvol rootvol-02 rootdg
   164           ATCOPY/R 03.58% 0/31374945/1122304 PLXATT rootvol rootvol-02 rootdg
   164           ATCOPY/R 03.59% 0/31374945/1126400 PLXATT rootvol rootvol-02 rootdg
   164           ATCOPY/R 03.60% 0/31374945/1130496 PLXATT rootvol rootvol-02 rootdg
   164           ATCOPY/R 03.62% 0/31374945/1134592 PLXATT rootvol rootvol-02 rootdg
   164           ATCOPY/R 03.63% 0/31374945/1138688 PLXATT rootvol rootvol-02 rootdg
.............

现在我们可以检查 vxprint 输出中的镜像 rootvol 和 swapvol。
检查卷的两个副本是否都处于启用和活动状态。

# vxprint -htg rootdg
.............
dg rootdg       default      default  27000    1382248262.12.onitroad
dm rootdisk     c1t0d0s2     auto     80321    33399135 
dm rootmirror   c1t1d0s2     auto     80321    33415200 
v  rootvol      -            ENABLED  ACTIVE   31374945 ROUND     -        root
pl rootvol-01   rootvol      ENABLED  ACTIVE   31374945 CONCAT    -        RW
sd rootdisk-02  rootvol-01   rootdisk 2024190  31374945 0         c1t0d0   ENA
pl rootvol-02   rootvol      ENABLED  ACTIVE   31374945 CONCAT    -        RW
sd rootmirror-02 rootvol-02  rootmirror 2024190 31374945 0        c1t1d0   ENA
v  swapvol      -            ENABLED  ACTIVE   2024190  ROUND     -        swap
pl swapvol-01   swapvol      ENABLED  ACTIVE   2024190  CONCAT    -        RW
sd rootdisk-01  swapvol-01   rootdisk 0        2024190  0         c1t0d0   ENA
pl swapvol-02   swapvol      ENABLED  ACTIVE   2024190  CONCAT    -        RW
sd rootmirror-01 swapvol-02  rootmirror 0      2024190  0         c1t1d0   ENA

对于 x86 机器

x86 机器使用 BIOS 而不是 OBP,因此为了在 SPARC 机器中复制 eeprom 的功能,x86 系统在启动时使用文件 /boot/solaris/bootenv.rc。
VxVM 使用此文件来定位引导设备。
当我们镜像根磁盘时,我们应该能够在 eeprom 中看到 2 个变量

# eeprom |grep boot
bootpath=/pci@0,0/pci15ad,1976@10/sd@0,0:a
altbootpath=/pci@0,0/pci15ad,1976@10/sd@1,0:a

当我们启动操作系统时,我们应该会在 BIOS 菜单上看到这两个选项。
我们可以使用向上/向下箭头选择要启动的启动磁盘。

如果我们对 bootenv.rc 文件进行了任何更改,则必须更新存档:

# bootadm update-archive

对于 SPARC 机器

如果是 SPARC 机器,我们必须设置 use-nvramrc?
参数为 true 以启用根磁盘和根镜像的 VxVM 别名。
我们可以使用操作系统命令 eeprom 或者从 ok 提示符设置它。

# eeprom use-nvramrc?=true
ok> setenv use-nvramrc? true

现在从 OS 或者从 ok 提示符设置引导设备顺序。

# eeprom boot-device=rootdisk rootmirror
ok> setenv boot-device rootdisk rootmirror

我们现在可以通过提供以下命令在 ok 提示符下引导系统:

ok> boot rootdisk

从镜像磁盘启动

ok> boot rootmirror
or
# eeprom nvramrc=devalias rootmirror
查看更多教程 https://on  itroad.com

解封root磁盘

解封启动盘是一项非常简单的任务。
我们只需要运行一个命令并重新启动系统。
但在解封根盘之前,请确保我们已将镜像盘与根盘分离。

# vxassist -g rootdg remove mirror volume rootvol swapvol
# vxunroot
# shutdown -i6 -g0 -y

vxunroot 命令从 /etc/vfstab 文件中删除 VxVM 条目,以便系统可以从物理分区引导。

测试启动盘故障

我们可以通过使操作系统当前从中启动的启动磁盘失败来检查镜像磁盘。
为此,请使用 vxment 禁用 plex rootvol-01.

# vxmend -g rootdg off rootvol-01

检查 vxprint 输出以查看失败的卷。
系统仍应从根镜像磁盘中的其他丛启动并运行。

# vxprint -htg rootdg
.....................
dg rootdg       default      default  27000    1382248262.12.onitroad
dm rootdisk     c1t0d0s2     auto     80321    33399135 
dm rootmirror   c1t1d0s2     auto     80321    33415200 
v  rootvol      -            ENABLED  ACTIVE   31374945 ROUND     -        root
pl rootvol-01   rootvol      DISABLED OFFLINE  31374945 CONCAT    -        RW
sd rootdisk-02  rootvol-01   rootdisk 2024190  31374945 0         c1t0d0   ENA
pl rootvol-02   rootvol      ENABLED  ACTIVE   31374945 CONCAT    -        RW
sd rootmirror-02 rootvol-02  rootmirror 2024190 31374945 0        c1t1d0   ENA
v  swapvol      -            ENABLED  ACTIVE   2024190  ROUND     -        swap
pl swapvol-01   swapvol      ENABLED  ACTIVE   2024190  CONCAT    -        RW
sd rootdisk-01  swapvol-01   rootdisk 0        2024190  0         c1t0d0   ENA
pl swapvol-02   swapvol      ENABLED  ACTIVE   2024190  CONCAT    -        RW
sd rootmirror-01 swapvol-02  rootmirror 0      2024190  0         c1t1d0   ENA

要将 plex 状态恢复为原始状态:

vxmend -g rootdg on rootvol-01

我们可以使用上述方法来模拟根磁盘故障。
在禁用 rootvol-01 plex 之前,确保两个 plex 同步。

日期:2020-09-17 00:15:30 来源:oir作者:oir