Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1104172
  • 博文数量: 286
  • 博客积分: 3124
  • 博客等级: 中校
  • 技术积分: 5186
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-24 23:42
个人简介

Bomi

文章存档

2015年(1)

2013年(1)

2012年(281)

2008年(3)

分类: 系统运维

2012-02-05 00:41:04

我用虚拟机做了也一一次实验,来验证2块硬盘做RAIDZ ,坏一块盘时的可用性以及可修复性。
环境介绍:

如图: 原来系统Labdb001.spruce.cn的硬盘配置为:
IDE 0 Master Solaris-1-VHDD01.vid 18.2GB    (c0d0)
IDE 1 Master Solaris-1-VHDD02.vid 18.2GB     (c0d1)
IDE 1 Slave   Solaris-1-VHDD03.vid 18.2GB     (c1d1)
现在的系统是Solaris 10 X86 05/08
C0d0 是系统盘,UFS.
C0d1 和 c1d1 创建了一个名为 ora的RAIDZ 存储池(zpool ora)
Zpool ora 上我建了两个ZFS文件系统 oracle 和 oracle data
Oracle 被设定mount到 /u01
Oradate 被设定mount到 /u01/oracle
现在系统中有一个用户 Q.Ho ,其主目录被设定为 /u01/Q.Ho
上面现在有1个600多M的文件,Oracle 10.1.0.3 DB的cpio.gz
现在我把c1d1的磁盘控制器改为STAT 接口为#7.
因为Solaris 不可识别SATA控制器,所以这样做之后这块盘在系统中将不可识别。
然后我再增加1块盘:
Solaris-1-VHDD7SATA.vid 18.2GB
从名字上大家可以看出这块盘是原来计划挂在STAT #7上用的。
现在VirtualBox默认把它挂到IDE 1 Slave
下面我示范换盘的具体步骤
首先我启动我的虚拟机。
以root登入后打开一个终端,然后查看当前zfs存储池(zpool)的信息
# zpool list
NAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
ora                    36.2G   1.18G   35.1G     3%  DEGRADED   -
# zpool status
  pool: ora
state: DEGRADED
status: One or more devices could not be opened.  Sufficient replicas exist for
        the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
   see:
scrub: none requested
config:
        NAME        STATE     READ WRITE CKSUM
        ora         DEGRADED     0     0     0
          raidz1    DEGRADED     0     0     0
            c0d1    ONLINE       0     0     0
            c1d1    UNAVAIL      0     0     0  cannot open
errors: No known data errors
现在系统检测到raidz 卷ora两块盘中的一块已经损坏,我们来看看盘上的数据是任然可用:
# pwd
/
# cd /u01
# ls
Q.Ho    ora10g
# cd q.ho
q.ho: does not exist
# cd !.Ho
!.Ho: does not exist
# cd Q.Ho
# ls
solarisx86_DB_10_1_0_3_Disk1.cpio.gz
通过复制文件solarisx86_DB_10_1_0_3_Disk1.cpio.gz到其他目录,证明RAIDZ卷的数据任然可以正确读取。
接下来真是换盘:
首先查看系统中现有的磁盘
#format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
       0. c0d0 <DEFAULT cyl 2372 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
       1. c0d1 <VBOX HAR-22b3a4a7-0486b14-0001-18.20GB>
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0
       2. c1d1 <DEFAULT cyl 2373 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@1,1/ide@1/cmdk@1,0
Specify disk (enter its number):
大家可以看到系统已经看到新换的磁盘c1d1,现在它还是裸盘。
此时c1d1未经过存储池的格式化处理,所以对池任然不可用。
这时使用online命令启用磁盘c1d1是无效的。
# zpool online ora c1d1
Bringing device c1d1 online
# zpool list
NAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
ora                    36.2G   1.18G   35.1G     3%  DEGRADED   -
# zpool status
  pool: ora
state: DEGRADED
status: One or more devices could not be opened.  Sufficient replicas exist for
        the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
   see:
scrub: resilver completed with 0 errors on Sat Aug 23 17:31:37 2008
config:
        NAME        STATE     READ WRITE CKSUM
        ora         DEGRADED     0     0     0
          raidz1    DEGRADED     0     0     0
            c0d1    ONLINE       0     0     0
            c1d1    UNAVAIL      0     0     0  cannot open
errors: No known data errors
正确的方法是使用zpool replace 命令来替换存储池中的设备:
我在同一物理位置替换新的磁盘到存储池 ora
# zpool replace ora c1d1
# zpool list
NAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
ora                    36.2G   1.18G   35.1G     3%  DEGRADED   -
# zpool status
  pool: ora
state: DEGRADED
status: One or more devices is currently being resilvered.  The pool will
        continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scrub: resilver in progress, 59.01% done, 0h0m to go
config:
        NAME            STATE     READ WRITE CKSUM
        ora             DEGRADED     0     0     0
          raidz1        DEGRADED     0     0     0
            c0d1        ONLINE       0     0     0
            replacing   DEGRADED     0     0     0
              c1d1s0/o  UNAVAIL      0     0     0  cannot open
              c1d1      ONLINE       0     0     0
errors: No known data errors
大家可以看到池正在同步RAIDZ 卷中两块硬盘上的数据
一分钟后再次查看存储池的状态
# zpool list
NAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
ora                    36.2G   1.18G   35.1G     3%  ONLINE     -
# zpool status
  pool: ora
state: ONLINE
scrub: resilver completed with 0 errors on Sat Aug 23 17:40:51 2008
config:
        NAME        STATE     READ WRITE CKSUM
        ora         ONLINE       0     0     0
          raidz1    ONLINE       0     0     0
            c0d1    ONLINE       0     0     0
            c1d1    ONLINE       0     0     0
errors: No known data errors
新的硬盘已经被成功替换,RAIDZ 存储池ora已经被修复。
通过这个实验,证明2块盘的RAIDZ 坏一块盘的情况下是可以很方便的进行换盘恢复的。
扩展开来,我们还可以通过换盘的方式更换更大容量的硬盘为存储池扩容。

阅读(2634) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~