Sun Cluster 3.0 系统管理指南

8.1 备份群集文件

表 8-1 任务图:备份群集文件

任务 

有关说明,请转到... 

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

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

计算存放一个完全备份需要多少磁带。 

"8.1.2 如何确定完全备份所需要的磁带数"

备份根文件系统。 

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

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

"8.1.4 如何执行镜像的联机备份 (Solstice DiskSuite)"

"8.1.5 如何执行卷的联机备份 (VERITAS 卷管理器)"

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

请遵照此过程来确定您要备份的文件系统的名称。

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

    运行此命令不需要成为超级用户。


    % more /etc/vfstab
    
  2. 在安装点列中查找要备份的文件系统的名称。

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


    % more /etc/vfstab 
    

8.1.1.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      -

8.1.2 如何确定完全备份所需要的磁带数

按照此过程来计算备份一个文件系统将需要的磁带数。

  1. 成为您要备份的群集节点上的超级用户。

  2. 估计备份的大小,以字节为单位。


    # ufsdump S filesystem 
    
    S

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

    filesystem

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

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

8.1.2.1 示例-确定所需要的磁带数

在以下示例中,905,881,620 字节将轻松装入一个 4 GB 磁 带 (905,881,620 / 4,000,000,000) 上。


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

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

按照此过程来备份一个群集节点的根 (/) 文件系统。在执行此备份过程前确保群集无故障运行。

  1. 成为您要备份的群集节点上的超级用户。

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


    # scswitch -z -D disk-device-group -h node
    
    -z

    执行切换。

    -D disk-device-group

    磁盘设备组的名称,与磁盘集或磁盘组的名称相同。

    -h node

    充当磁盘设备组的主节点的群集节点的名称。

  3. 停止该节点。


    # shutdown -g0 -y
    
  4. ok 提示符下,以非群集模式重新引导。


    ok boot -x
    
  5. 备份根 (/) 文件系统。

    • 如果根磁盘未封装,请使用以下命令。


      # ufsdump 0ucf dump-device /
      
    • 如果根磁盘已封装,请使用以下命令。


      # ufsdump 0ucf dump-device /dev/vx/rdsk/rootvol
      

    有关详细信息,请参考 ufsdump(1M) 手册页。

  6. 以群集模式重新引导该节点。


    # init 6
    

8.1.3.1 示例-备份根 (/) 文件系统

在以下示例中,根 (/) 文件系统备份到了磁盘 设备 /dev/rmt/0 上。


# ufsdump 0ucf /dev/rmt/0 /
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Tue Apr 18 18:06:15 2000
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s0 (phys-schost-1:/) to /dev/rmt/0
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 859086 blocks (419.48MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: 859066 blocks (419.47MB) on 1 volume at 2495 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Tue Apr 18 18:06:15 2000

8.1.4 如何执行镜像的联机备份 (Solstice DiskSuite)

不用卸装一个镜像的元设备或使整个镜像脱机,就可以备份该镜 像的元设备。必须使其子镜像之一临时脱机,因而它就失去了镜像,但备份完成后可立即使之联机并再 同步;这样就不必停止系统,也不用拒绝用户访问数据。使用镜像来执行联机备份可创建活动文件 系统的“快照”备份。

如果一个程序在卷上写入了数据后 lockfs 命令随即运行,则可能 会发生故障。要避免此故障,请暂时停止在此节点上运行的所有服务。此外,请在执行此备份过程前确保群集无故障运行。

  1. 成为您要备份的群集节点上的超级用户。

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


    # metaset -s setname
    
    -s setname

    指定磁盘集名称。

  3. 使用 lockfs(1M) 命令和 -w 选项来锁定文件系统的写操作。


    # lockfs -w mount-point 
    


    注意:

    仅在镜像上驻留着一个 UFS 文件系统时才必须锁定此文件系统。例如,如果元设备被设置 为数据库管理软件或其他某个特定的应用程序的原始设备,就不必使用 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 mount-point
    

  7. 执行文件系统检查。


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

    使用 ufsdump(1M) 命令或其他您通常使用的无论什么备份公用程序。


    注意:

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



    # ufsdump 0ucf dump-device submirror
    
  9. 使用 metattach(1M) 命令来使元设备重新联机。


    # metattach -s setname mirror submirror
    

    使元设备联机后,它自动地重新与镜像同步。

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


    # metastat -s setname mirror
    

8.1.4.1 示例-执行镜像的联机备份 (Solstice DiskSuite)

在以下示例中,群集节点 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
[Resync 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)
...

8.1.5 如何执行卷的联机备份 (VERITAS 卷管理器)

VERITAS Volume Manager 将一个镜像的卷识别为一个丛。不用卸装一个丛或使整个卷脱机,就可以 备份该镜像的元设备。这是通过创建卷的快照副本并备份此临时卷来完成的,不用停止系统或拒绝用户对数据的访问。

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

  1. 登录到群集中的任一节点上,并成为群集中该磁盘组的当前主节点上的超级用户。

  2. 列出磁盘组信息。


    # vxprint -g diskgroup
    
  3. 运行 scstat(1M) 来查看哪个节点当前导入了磁盘组,导入了磁盘组即表示它是磁盘组的主节点。


    # scstat -D
    
    -D

    显示所有磁盘设备组的状态。

  4. 使用 vxassist(1M) 命令创建卷的一个快照。


    # vxassist -g diskgroup snapstart volume
    

    注意:

    创建快照可能需要很长一段时间,时间的长度取决于卷的大小。


  5. 使用 vxprint(1M) 命令来检验已创建新卷。


    # vxprint -g diskgroup
    

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

  6. 停止正在使用 scswitch(1M) 命令访问文件系统的任何数据服务。


    # scswitch -z -g nfs-rg -h ""
    

    注意:

    建议停止数据服务,以确保正确备份数据文件系统。如果没有数据服务在运行中,则不必 执行步骤 6步骤 8


  7. 创建一个名为 bkup-vol 的备份卷并 使用 vxassist 命令将快照卷连接到此备份卷。


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


    # scswitch -z -g nfs-rg -h nodename
    
  9. 使用 vxprint 命令,检验该卷此时是否连接到了 新卷 bkup-vol


    # vxprint -g diskgroup
    
  10. 使用 scconf(1M) 命令注册磁盘组配置更改。


    # scconf -c -D name=diskgroup,sync
    
  11. 使用 fsck 命令检查备份卷。


    # 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(1M) 移除临时卷。


    # vxedit -rf rm bkup-vol
    
  14. 使用 scconf 命令注册磁盘组配置更改。


    # scconf -c -D name=disk-group,sync
    

8.1.5.1 示例-执行卷的联机备份 (VERITAS 卷管理器)

在以下示例中,群集节点 phys-schost-2 是元集磁盘 组 schost-1 的主属主,所以备份过程是从 phys-schost-2 开 始执行的。卷 /vo101 被复制,然后与一个新卷 bkup-vol 关联。


[Become superuser on the primary node.]
[Identify the current primary node for the disk group:]
# scstat -D
-- 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 disk 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:]
# scswitch -z -g nfs-rg -h ""
[Create a copy of the volume:]
# vxassist -g schost-1 snapshot vol01 bkup-vol
[Restart data services, if necessary:]
# scswitch -z -g nfs-rg -h phys-schost-1
[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 -      -        -      -
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  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:]
# scconf -c -D name=schost-1,sync
[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:]
# scconf -c -D name=schost-1,sync