Sun Cluster 系统管理指南(适用于 Solaris OS)

备份群集

表 12–1 任务表:备份群集文件

任务 

指导 

查找要备份的文件系统的名称 

如何查找要备份的文件系统名称

计算存放一份完整备份需要多少磁带 

如何确定进行完整备份所需的磁带数目

备份根文件系统 

如何备份根 (/) 文件系统

为镜像的文件系统或网状文件系统执行联机备份 

如何为镜像执行联机备份 (Solaris Volume Manager)

 

如何为卷执行联机备份 (Veritas Volume Manager(Veritas 卷管理器))

备份群集配置 

如何备份群集配置

备份存储磁盘的磁盘分区配置 

参见存储磁盘的相关文档 

Procedure如何查找要备份的文件系统名称

使用此过程可确定您想要备份的文件系统的名称。

  1. 显示 /etc/vfstab 文件的内容。

    运行此命令不需要成为超级用户或等效角色。


    # more /etc/vfstab
    
  2. 在挂载点列中查找要备份的文件系统的名称。

    备份文件系统时,使用此名称。


    # more /etc/vfstab 
    

示例 12–1 查找要备份的文件系统的名称

以下示例显示了列在 /etc/vfstab 文件中的可用文件系统的名称。


# more /etc/vfstab
#device             device             mount  FS fsck  mount  mount
#to mount           to fsck            point  type     pass   at boot  options
#
#/dev/dsk/c1d0s2    /dev/rdsk/c1d0s2   /usr     ufs     1      yes      -
 f                  -                  /dev/fd  fd      -      no       -
 /proc              -                  /proc    proc    -      no       -
 /dev/dsk/c1t6d0s1  -                  -        swap    -      no       -
 /dev/dsk/c1t6d0s0  /dev/rdsk/c1t6d0s0 /        ufs     1      no       -
 /dev/dsk/c1t6d0s3  /dev/rdsk/c1t6d0s3 /cache   ufs     2      yes      -
 swap               -                  /tmp     tmpfs   -      yes      -

Procedure如何确定进行完整备份所需的磁带数目

使用此过程可计算备份文件系统所需的磁带数量。

  1. 在要备份的群集节点上,成为超级用户或使用等效角色。

  2. 按字节估算备份的大小。


    # ufsdump S filesystem 
    
    S

    显示执行该备份估计需要的字节数。

    filesystem

    指定您要备份的文件系统的名称。

  3. 用磁带容量去除估算大小,看需要多少磁带。


示例 12–2 确定所需要的磁带数

在以下示例中,大小为 905,881,620 字节的文件系统用一盒 4 GB 的磁带 (905,881,620 ÷ 4,000,000,000) 就足够了。


# ufsdump S /global/phys-schost-1
905881620

Procedure如何备份根 (/) 文件系统

使用此过程可以备份群集节点的根 (/) 文件系统。执行此备份过程之前,请确保群集正在无故障运行。

phys-schost# 提示符表示全局群集提示符。此操作过程适用于全局群集。

此过程提供了 Sun Cluster 命令的长格式。此外,大多数命令还有简短格式。这些命令除了名称长短的不同以外,其功能都是相同的。有关命令及其简短格式的列表,请参见附录 B

  1. 在要备份的群集节点上,成为超级用户或使用一个可提供 solaris.cluster.modify RBAC 授权的角色。

  2. 将每一个正在运行的数据服务从将要备份的节点切换到群集的另一个节点。


    # clnode evacuate node
    
    node

    指定从中切换资源组和设备组的节点。

  3. 关闭该节点。


    # shutdown -g0 -y -i0
    
  4. 将节点重新引导到非群集模式。

    • 在基于 SPARC 的系统上,运行以下命令。


      ok boot -xs
      
    • 在基于 x86 的系统上,运行以下命令。


      phys-schost# shutdown -g -y -i0
      
      Press any key to continue
    1. 在 GRUB 菜单中,使用方向键选择适当的 Solaris 条目,然后键入 e 编辑其命令。

      GRUB 菜单显示如下内容:


      GNU GRUB version 0.95 (631K lower / 2095488K upper memory)
      +-------------------------------------------------------------------------+
      | Solaris 10 /sol_10_x86                                                  |
      | Solaris failsafe                                                        |
      |                                                                         |
      +-------------------------------------------------------------------------+
      Use the ^ and v keys to select which entry is highlighted.
      Press enter to boot the selected OS, 'e' to edit the
      commands before booting, or 'c' for a command-line.

      有关基于 GRUB 的引导的更多信息,请参见《系统管理指南:基本管理》中的“使用 GRUB 引导基于 x86 的系统(任务图)”

    2. 在引导参数屏幕中,使用方向键选择内核条目,然后键入 e 编辑该条目。

      GRUB 引导参数屏幕的显示与以下内容类似:


      GNU GRUB version 0.95 (615K lower / 2095552K upper memory)
      +----------------------------------------------------------------------+
      | root (hd0,0,a)                                                       |
      | kernel /platform/i86pc/multiboot                                     |
      | module /platform/i86pc/boot_archive                                  |
      +----------------------------------------------------------------------+
      Use the ^ and v keys to select which entry is highlighted.
      Press 'b' to boot, 'e' to edit the selected command in the
      boot sequence, 'c' for a command-line, 'o' to open a new line
      after ('O' for before) the selected line, 'd' to remove the
      selected line, or escape to go back to the main menu.
    3. 在命令中添加 -x 以指定将系统引导至非群集模式。


      [ Minimal BASH-like line editing is supported. For the first word, TAB
      lists possible command completions. Anywhere else TAB lists the possible
      completions of a device/filename. ESC at any time exits. ]
      
      grub edit> kernel /platform/i86pc/multiboot -x
    4. 按 Enter 键接受所做更改,并返回到引导参数屏幕。

      屏幕将显示编辑后的命令。


      GNU GRUB version 0.95 (615K lower / 2095552K upper memory)
      +----------------------------------------------------------------------+
      | root (hd0,0,a)                                                       |
      | kernel /platform/i86pc/multiboot -x                                  |
      | module /platform/i86pc/boot_archive                                  |
      +----------------------------------------------------------------------+
      Use the ^ and v keys to select which entry is highlighted.
      Press 'b' to boot, 'e' to edit the selected command in the
      boot sequence, 'c' for a command-line, 'o' to open a new line
      after ('O' for before) the selected line, 'd' to remove the
      selected line, or escape to go back to the main menu.-
    5. 键入 b 将节点引导至非群集模式。


      注 –

      对内核引导参数命令所做的这一更改在系统引导后将失效。下次重新引导节点时,系统将引导至群集模式。如果希望引导至非群集模式,请重新执行上述步骤,并将 -x 选项添加到内核引导参数命令中。


  5. 通过创建 UFS 快照来备份根 (/) 文件系统。

    1. 确保文件系统有足够的磁盘空间可用于后备存储文件。


      # df -k
      
    2. 确保名称和位置相同的后备存储文件尚不存在。


      # ls /backing-store-file
      
    3. 创建 UFS 快照。


      # fssnap -F ufs -o bs=/backing-store-file /file-system
      
    4. 检验是否已创建快照。


      # /usr/lib/fs/ufs/fssnap -i /file-system
      
  6. 将节点重新引导到群集模式。


    # init 6
    

示例 12–3 备份根 (/) 文件系统

在以下示例中,根 (/) 文件系统的快照保存至 /usr 目录下的 /scratch/usr.back.file 中。`


# fssnap -F ufs -o bs=/scratch/usr.back.file /usr
  /dev/fssnap/1

Procedure如何为镜像执行联机备份 (Solaris Volume Manager)

对于镜像的 Solstice DiskSuite 元设备或 Solaris Volume Manager 卷,无需将其卸载或将整个镜像脱机就可以对其进行备份。您必须暂时使其中一个子镜像脱机(因而失去镜像),但备份完成后可立即使之联机并重新同步,这样就不必停止系统,也不用拒绝用户访问数据。通过使用镜像来执行联机备份,可创建活动文件系统的“快照”备份。

如果在某个程序将数据写入卷后又立即运行了 lockfs 命令,则可能会出现问题。要避免此故障,请暂时停止在此节点上运行的所有服务。另外,在执行此备份过程之前,请确保群集正在无故障运行。

phys-schost# 提示符表示全局群集提示符。此操作过程适用于全局群集。

此过程提供了 Sun Cluster 命令的长格式。此外,大多数命令还有简短格式。这些命令除了名称长短的不同以外,其功能都是相同的。有关命令及其简短格式的列表,请参见附录 B

  1. 在要备份的群集节点上,成为超级用户或使用等效角色。

  2. 使用 metaset(1M) 命令确定哪个节点对备份的卷拥有所有权。


    # metaset -s setname
    
    -ssetname

    指定磁盘集名称。

  3. lockfs(1M) 命令与 -w 选项配合使用可禁止对文件系统执行写入操作。


    # lockfs -w mountpoint 
    

    注 –

    仅当镜像上还有 UFS 文件系统时才必须锁定此文件系统。例如,如果 Solstice DiskSuite 元设备或 Solaris Volume Manager 卷设置为数据库管理软件或其他某个特定应用程序的原始设备,则无需使用 lockfs 命令。但是,您可能要运行适当的、与供应商相关的实用程序来刷新任意缓冲区并锁定访问。


  4. 使用 metastat(1M) 命令来确定子镜像的名称。


    # metastat -s setname -p
    
    -p

    以类似于 md.tab 文件的格式显示状态。

  5. 使用 metadetach(1M) 命令使一个子镜像与镜像脱离。


    # metadetach -s setname mirror submirror
    

    注 –

    将继续从其他子镜像进行读取。但是,对镜像进行第一次写操作后,脱机子镜像将立即不再同步。脱机子镜像重新联机后,这种不一致现象就会得到纠正。您无需运行 fsck 命令。


  6. 通过结合使用 lockfs 命令和 -u 选项,解除对文件系统的锁定,允许写入操作继续执行。


    # lockfs -u mountpoint 
    
  7. 执行文件系统检查。


    # fsck /dev/md/diskset/rdsk/submirror
    
  8. 将脱机子镜像备份到磁带或另一介质上。

    使用 ufsdump(1M) 命令或通常使用的备份实用程序。


    # ufsdump 0ucf dump-device submirror
    

    注 –

    对子镜像使用原始设备 (/rdsk) 名称,而不使用块设备 (/dsk) 名称。


  9. 使用 metattach(1M) 命令将元设备或卷重新置于联机状态。


    # metattach -s setname mirror submirror
    

    当元设备或卷处于联机状态后,将会自动与镜像重新同步。

  10. 使用 metastat 命令可检验该子镜像是否正在重新同步。


    # metastat -s setname mirror
    

示例 12–4 为镜像执行联机备份 (Solaris Volume Manager)

在下面的示例中,群集节点 phys-schost-1 是元集 schost-1 的属主,因此备份过程是从 phys-schost-1 执行的。镜像 /dev/md/schost-1/dsk/d0 由子镜像 d10d20d30 组成。


[Determine the owner of the metaset:]
# metaset -s schost-1
Set name = schost-1, Set number = 1
Host                Owner
  phys-schost-1     Yes 
...
[Lock the file system from writes:] 
# lockfs -w /global/schost-1
[List the submirrors:]
# metastat -s schost-1 -p
schost-1/d0 -m schost-1/d10 schost-1/d20 schost-1/d30 1
schost-1/d10 1 1 d4s0
schost-1/d20 1 1 d6s0
schost-1/d30 1 1 d8s0
[Take a submirror offline:]
# metadetach -s schost-1 d0 d30
[Unlock the file system:]
# lockfs -u /
[Check the file system:]
# fsck /dev/md/schost-1/rdsk/d30
[Copy the submirror to the backup device:]
# ufsdump 0ucf /dev/rmt/0 /dev/md/schost-1/rdsk/d30
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Tue Apr 25 16:15:51 2000
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/md/schost-1/rdsk/d30 to /dev/rdsk/c1t9d0s0.
  ...
  DUMP: DUMP IS DONE
[Bring the submirror back online:]
# metattach -s schost-1 d0 d30
schost-1/d0: submirror schost-1/d30 is attached
[Resynchronize the submirror:]
# metastat -s schost-1 d0
schost-1/d0: Mirror
    Submirror 0: schost-0/d10
      State: Okay         
    Submirror 1: schost-0/d20
      State: Okay
    Submirror 2: schost-0/d30
      State: Resyncing
    Resync in progress: 42% done
    Pass: 1
    Read option: roundrobin (default)
...

Procedure如何为卷执行联机备份 (Veritas Volume Manager(Veritas 卷管理器))

Veritas Volume Manager(Veritas 卷管理器) 将镜像卷标识为丛。无需卸载丛或使整个卷脱机就可备份丛。这是通过创建卷的快照副本并备份此临时卷来完成的,您无需停止系统或拒绝用户访问数据。

执行此备份过程之前,请确保群集正在无故障运行。

phys-schost# 提示符表示全局群集提示符。此操作过程适用于全局群集。

此过程提供了 Sun Cluster 命令的长格式。此外,大多数命令还有简短格式。这些命令除了名称长短的不同以外,其功能都是相同的。有关命令及其简短格式的列表,请参见附录 B

  1. 登录到群集的任意节点,成为该群集上磁盘组的当前主节点的超级用户,或使用一个可提供 solaris.cluster.admin RBAC 授权的角色。

  2. 列出磁盘组信息。


    # vxprint -g diskgroup
    
  3. 确定哪个节点当前已导入该磁盘组,这个节点就是该磁盘组的主节点。


    # cldevicegroup status
    
  4. 创建卷的快照。


    # vxassist -g diskgroup snapstart volume
    

    注 –

    创建快照可能需要较长时间,具体情况取决于卷大小。


  5. 检验是否已创建新卷。


    # vxprint -g diskgroup
    

    当快照完成后,所选磁盘组的 State 字段会显示 Snapdone 状态。

  6. 停止正在访问文件系统的任何数据服务。


    # clresourcegroup offline resource-group
    

    注 –

    停止所有数据服务,以确保正确备份数据文件系统。如果没有运行任何数据服务,则无需执行步骤 6步骤 8


  7. 创建一个名为 bkup-vol 的备份卷,然后将快照卷附加到此卷。


    # vxassist -g diskgroup snapshot volume bkup-vol
    
  8. 使用 clresourcegroup 命令重新启动在步骤 6 中停止的所有数据服务。


    # clresourcegroup online - zone -n node resourcegroup
    
    node

    节点名称。

    zone

    可控制资源组的全局群集非投票节点 (node) 的名称。只有在创建资源组时指定了非投票节点的情况下,才能指定 zone

  9. 检验该卷目前是否已附加到新卷 bkup-vol


    # vxprint -g diskgroup
    
  10. 注册对设备组配置所做的更改。


    # cldevicegroup sync diskgroup
    
  11. 检查备份卷。


    # fsck -y /dev/vx/rdsk/diskgroup/bkup-vol
    
  12. 执行一次备份,以便将卷 bkup-vol 复制到磁带或另一介质上。

    使用 ufsdump(1M) 命令或通常使用的备份实用程序。


    # ufsdump 0ucf dump-device /dev/vx/dsk/diskgroup/bkup-vol
    
  13. 删除临时卷。


    # vxedit -rf rm bkup-vol
    
  14. 注册对磁盘组配置所做的更改。


    # cldevicegroup sync diskgroup
    

示例 12–5 为卷执行联机备份 (Veritas Volume Manager(Veritas 卷管理器))

在以下示例中,群集节点 phys-schost-2 是设备组 schost-1 的主属主。因此,备份过程从 phys-schost-2 执行的。将复制卷 /vo101,然后将其与新卷 bkup-vol 关联。


[Become superuser or assume a role that provides solaris.cluster.admin RBAC authorization on 
the primary node.]
[Identify the current primary node for the device group:]
# cldevicegroup status
-- Device Group Servers --
                         Device Group     Primary           Secondary
                         ------------     -------           ---------
 Device group servers:   rmt/1            -                 -
 Device group servers:   schost-1         phys-schost-2     phys-schost-1

-- Device Group Status --
                             Device Group        Status              
                             ------------        ------              
 Device group status:        rmt/1               Offline
 Device group status:        schost-1            Online
[List the device group information:]
# vxprint -g schost-1
TY NAME            ASSOC     KSTATE   LENGTH   PLOFFS STATE   TUTIL0  PUTIL0
dg schost-1       schost-1   -        -        -      -        -      -
  
dm schost-101     c1t1d0s2   -        17678493 -      -        -      -
dm schost-102     c1t2d0s2   -        17678493 -      -        -      -
dm schost-103     c2t1d0s2   -        8378640  -      -        -      -
dm schost-104     c2t2d0s2   -        17678493 -      -        -      -
dm schost-105     c1t3d0s2   -        17678493 -      -        -      -
dm schost-106     c2t3d0s2   -        17678493 -      -        -      -
 
v  vol01          gen        ENABLED  204800   -      ACTIVE   -      -
pl vol01-01       vol01      ENABLED  208331   -      ACTIVE   -      -
sd schost-101-01  vol01-01   ENABLED  104139   0      -        -      -
sd schost-102-01  vol01-01   ENABLED  104139   0      -        -      -
pl vol01-02       vol01      ENABLED  208331   -      ACTIVE   -      -
sd schost-103-01  vol01-02   ENABLED  103680   0      -        -      -
sd schost-104-01  vol01-02   ENABLED  104139   0      -        -      -
pl vol01-03       vol01      ENABLED  LOGONLY  -      ACTIVE   -      -
sd schost-103-02  vol01-03   ENABLED  5        LOG    -        -      -
[Start the snapshot operation:]
# vxassist -g schost-1 snapstart vol01
[Verify the new volume was created:]
# vxprint -g schost-1
TY NAME            ASSOC    KSTATE    LENGTH   PLOFFS STATE   TUTIL0  PUTIL0
dg schost-1       schost-1   -        -        -      -        -      -
  
dm schost-101     c1t1d0s2   -        17678493 -      -        -      -
dm schost-102     c1t2d0s2   -        17678493 -      -        -      -
dm schost-103     c2t1d0s2   -        8378640  -      -        -      -
dm schost-104     c2t2d0s2   -        17678493 -      -        -      -
dm schost-105     c1t3d0s2   -        17678493 -      -        -      -
dm schost-106     c2t3d0s2   -        17678493 -      -        -      -
  
v  vol01          gen        ENABLED  204800   -      ACTIVE   -      -
pl vol01-01       vol01      ENABLED  208331   -      ACTIVE   -      -
sd schost-101-01  vol01-01   ENABLED  104139   0      -        -      -
sd schost-102-01  vol01-01   ENABLED  104139   0      -        -      -
pl vol01-02       vol01      ENABLED  208331   -      ACTIVE   -      -
sd schost-103-01  vol01-02   ENABLED  103680   0      -        -      -
sd schost-104-01  vol01-02   ENABLED  104139   0      -        -      -
pl vol01-03       vol01      ENABLED  LOGONLY  -      ACTIVE   -      -
sd schost-103-02  vol01-03   ENABLED  5        LOG    -        -      -
pl vol01-04       vol01      ENABLED  208331   -      SNAPDONE -      -
sd schost-105-01  vol01-04   ENABLED  104139   0      -        -      -
sd schost-106-01  vol01-04   ENABLED  104139   0      -        -      -
[Stop data services, if necessary:]
# clresourcegroup offline nfs-rg
[Create a copy of the volume:]
# vxassist -g schost-1 snapshot vol01 bkup-vol
[Restart data services, if necessary:]
# clresourcegroup online -n phys-schost-1 nfs-rg
[Verify bkup-vol was created:]
# vxprint -g schost-1
TY NAME           ASSOC       KSTATE   LENGTH   PLOFFS STATE   TUTIL0  PUTIL0
dg schost-1       schost-1    -        -        -      -        -      -
 
dm schost-101     c1t1d0s2    -        17678493 -      -        -      -
...
 
v  bkup-vol       gen         ENABLED  204800   -      ACTIVE   -      -
pl bkup-vol-01    bkup-vol    ENABLED  208331   -      ACTIVE   -      -
sd schost-105-01  bkup-vol-01 ENABLED  104139   0      -        -      -
sd schost-106-01  bkup-vol-01 ENABLED  104139   0      -        -      -
 
v  vol01          gen         ENABLED  204800   -      ACTIVE   -      -
pl vol01-01       vol01       ENABLED  208331   -      ACTIVE   -      -
sd schost-101-01  vol01-01    ENABLED  104139   0      -        -      -
sd schost-102-01  vol01-01    ENABLED  104139   0      -        -      -
pl vol01-02       vol01       ENABLED  208331   -      ACTIVE   -      -
sd schost-103-01  vol01-02    ENABLED  103680   0      -        -      -
sd schost-104-01  vol01-02    ENABLED  104139   0      -        -      -
pl vol01-03       vol01       ENABLED  LOGONLY  -      ACTIVE   -      -
sd schost-103-02  vol01-03    ENABLED  5        LOG    -        -      -
[Synchronize the disk group with cluster framework:]
# cldevicegroup sync schost-1
[Check the file systems:]
# fsck -y /dev/vx/rdsk/schost-1/bkup-vol
[Copy bkup-vol to the backup device:]
# ufsdump 0ucf /dev/rmt/0 /dev/vx/rdsk/schost-1/bkup-vol
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Tue Apr 25 16:15:51 2000
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/vx/dsk/schost-2/bkup-vol to /dev/rmt/0.
  ...
  DUMP: DUMP IS DONE
[Remove the bkup-volume:]
# vxedit -rf rm bkup-vol
[Synchronize the disk group:]
# cldevicegroup sync schost-1

Procedure如何备份群集配置

为确保群集配置已归档并可轻松恢复,请定期对群集配置加以备份。Sun Cluster 3.2 可将群集配置导出到一个可扩展标记语言(eXtensible Markup Language, XML) 文件。

  1. 登录到群集的任意节点,成为超级用户或使用一个可提供 solaris.cluster.read RBAC 授权的角色。

  2. 将群集配置信息导出到一个文件中。


    # /usr/cluster/bin/cluster export -o configfile
    
    configfile

    群集命令正在将群集配置信息导出到的 XML 配置文件的名称。有关 XML 配置文件的信息,请参见 clconfiguration(5CL)

  3. 检验群集配置信息是否已成功导出至 XML 文件。


    # vi configfile