码迷,mamicode.com
首页 > 其他好文 > 详细

TAID5

时间:2017-06-05 00:31:50      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:tar   man   altered   roc   stop   writing   cgroup   etc   故障   

建立raid5
    创建raid5
    添加新1G热背盘,模拟磁盘故障,自动顶替
    移除故障盘
    停止阵列,重新激活阵列
    再加新的1G热备盘,扩展阵列容量,从3个磁盘扩展到4个
        环境:sde1,sde2,sde3,sde4,sde5,sde6 每个1G


创建六个分区,从第四个开始用扩展分区
[root@ZQ ~]# fdisk /dev/sde
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x8800cb6a.

Command (m for help): p

Disk /dev/sde: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8800cb6a

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +1G
Partition 1 of type Linux and of size 1 GiB is set

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2099200-20971519, default 2099200): 
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-20971519, default 20971519): +1G
Partition 2 of type Linux and of size 1 GiB is set

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (4196352-20971519, default 4196352): 
Using default value 4196352
Last sector, +sectors or +size{K,M,G} (4196352-20971519, default 20971519): +1G
Partition 3 of type Linux and of size 1 GiB is set

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): e
Selected partition 4
First sector (6293504-20971519, default 6293504): 
Using default value 6293504
Last sector, +sectors or +size{K,M,G} (6293504-20971519, default 20971519): 
Using default value 20971519
Partition 4 of type Extended and of size 7 GiB is set

Command (m for help): p

Disk /dev/sde: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8800cb6a

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1            2048     2099199     1048576   83  Linux
/dev/sde2         2099200     4196351     1048576   83  Linux
/dev/sde3         4196352     6293503     1048576   83  Linux
/dev/sde4         6293504    20971519     7339008    5  Extended

Command (m for help): n
All primary partitions are in use
Adding logical partition 5
First sector (6295552-20971519, default 6295552): 
Using default value 6295552
Last sector, +sectors or +size{K,M,G} (6295552-20971519, default 20971519): +1G
Partition 5 of type Linux and of size 1 GiB is set

Command (m for help): n
All primary partitions are in use
Adding logical partition 6
First sector (8394752-20971519, default 8394752): 
Using default value 8394752
Last sector, +sectors or +size{K,M,G} (8394752-20971519, default 20971519): +1G
Partition 6 of type Linux and of size 1 GiB is set

Command (m for help): p

Disk /dev/sde: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8800cb6a

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1            2048     2099199     1048576   83  Linux
/dev/sde2         2099200     4196351     1048576   83  Linux
/dev/sde3         4196352     6293503     1048576   83  Linux
/dev/sde4         6293504    20971519     7339008    5  Extended
/dev/sde5         6295552     8392703     1048576   83  Linux
/dev/sde6         8394752    10491903     1048576   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@ZQ ~]# ll /dev/sde*
brw-rw----. 1 root disk 8, 64 Jun  4 21:45 /dev/sde
brw-rw----. 1 root disk 8, 65 Jun  4 21:45 /dev/sde1
brw-rw----. 1 root disk 8, 66 Jun  4 21:45 /dev/sde2
brw-rw----. 1 root disk 8, 67 Jun  4 21:45 /dev/sde3
brw-rw----. 1 root disk 8, 68 Jun  4 21:45 /dev/sde4
brw-rw----. 1 root disk 8, 69 Jun  4 21:45 /dev/sde5
brw-rw----. 1 root disk 8, 70 Jun  4 21:45 /dev/sde6


创建raid5
[root@ZQ ~]# mdadm -C -v /dev/md5 -l 5 -n 3 -c 32 -x 1 /dev/sde{1,2,3,4}
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: /dev/sde4 is not suitable for this array.     #这里报错,因为第四个分区是扩展分区开始的
mdadm: create aborted
[root@ZQ ~]# mdadm -C -v /dev/md5 -l 5 -n 3 -c 32 -x 1 /dev/sde{1,2,3,5}
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: size set to 1047552K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.

[root@ZQ ~]# cat /proc/mdstat 
Personalities : [raid0] [raid1] [raid6] [raid5] [raid4] 
md5 : active raid5 sde3[4] sde5[3](S) sde2[1] sde1[0]
      2095104 blocks super 1.2 level 5, 32k chunk, algorithm 2 [3/3] [UUU]
      
md1 : active raid1 sdc3[2] sdc2[1]
      1047552 blocks super 1.2 [2/2] [UU]
      
md0 : active raid0 sdb2[1] sdb1[0]
      2095104 blocks super 1.2 512k chunks
      
unused devices: <none>
[root@ZQ ~]# mdadm -Ds
ARRAY /dev/md0 metadata=1.2 name=ZQ:0 UUID=00d9284f:6fd6b3b0:afc571c6:c5441608
ARRAY /dev/md1 metadata=1.2 name=ZQ:1 UUID=137b8247:e0ced5a2:625805ac:e9b31692
ARRAY /dev/md5 metadata=1.2 spares=1 name=ZQ:5 UUID=32056d5a:35cf0716:fd761180:cc7b848b


停止md5
[root@ZQ ~]# mdadm -Ds
ARRAY /dev/md0 metadata=1.2 name=ZQ:0 UUID=00d9284f:6fd6b3b0:afc571c6:c5441608
ARRAY /dev/md1 metadata=1.2 name=ZQ:1 UUID=137b8247:e0ced5a2:625805ac:e9b31692
ARRAY /dev/md5 metadata=1.2 spares=1 name=ZQ:5 UUID=32056d5a:35cf0716:fd761180:cc7b848b
[root@ZQ ~]# mdadm -Ds > /etc/mdadm.conf 
[root@ZQ ~]# cat !$
cat /etc/mdadm.conf
ARRAY /dev/md0 metadata=1.2 name=ZQ:0 UUID=00d9284f:6fd6b3b0:afc571c6:c5441608
ARRAY /dev/md1 metadata=1.2 name=ZQ:1 UUID=137b8247:e0ced5a2:625805ac:e9b31692
ARRAY /dev/md5 metadata=1.2 spares=1 name=ZQ:5 UUID=32056d5a:35cf0716:fd761180:cc7b848b
[root@ZQ ~]# mdadm -S /dev/md5
mdadm: stopped /dev/md5
[root@ZQ ~]# cat /proc/mdstat 
Personalities : [raid0] [raid1] [raid6] [raid5] [raid4] 
md1 : active raid1 sdc3[2] sdc2[1]
      1047552 blocks super 1.2 [2/2] [UU]
      
md0 : active raid0 sdb2[1] sdb1[0]
      2095104 blocks super 1.2 512k chunks
      
unused devices: <none>


激活
[root@ZQ ~]# mdadm -As 
mdadm: Found some drive for an array that is already active: /dev/md1
mdadm: giving up.
mdadm: /dev/md5 has been started with 3 drives and 1 spare.
mdadm: Found some drive for an array that is already active: /dev/md1
mdadm: giving up.


扩展
[root@ZQ ~]# fdisk /dev/md5
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xb42dd723.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-4190207, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4190207, default 4190207): 
Using default value 4190207
Partition 1 of type Linux and of size 2 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@ZQ ~]# mkfs.ext4 /dev/md
md0    md0p1  md1    md1p1  md5    md5p1  
[root@ZQ ~]# mkfs.ext4 /dev/md5p1 
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=8 blocks, Stripe width=16 blocks
131072 inodes, 523520 blocks
26176 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done 

[root@ZQ ~]# mkdir /raid5
[root@ZQ ~]# mount /dev/md5p1 /raid5
[root@ZQ ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        15G  3.6G   12G  24% /
devtmpfs        474M     0  474M   0% /dev
tmpfs           489M  156K  489M   1% /dev/shm
tmpfs           489M  7.0M  482M   2% /run
tmpfs           489M     0  489M   0% /sys/fs/cgroup
/dev/sda1       197M  131M   67M  67% /boot
tmpfs            98M   12K   98M   1% /run/user/1000
/dev/sr0        4.1G  4.1G     0 100% /run/media/zq/CentOS 7 x86_64
/dev/md0p1      2.0G  6.1M  1.9G   1% /raid0
/dev/md1p1      990M  2.6M  921M   1% /raid1
/dev/md5p1      2.0G  6.0M  1.9G   1% /raid5
[root@ZQ ~]# umount /raid5
[root@ZQ ~]# mdadm -a /dev/md5 /dev/sde6
mdadm: added /dev/sde6
[root@ZQ ~]# cat /proc/mdstat 
Personalities : [raid0] [raid1] [raid6] [raid5] [raid4] 
md5 : active raid5 sde6[5](S) sde1[0] sde5[3](S) sde3[4] sde2[1]
      2095104 blocks super 1.2 level 5, 32k chunk, algorithm 2 [3/3] [UUU]
      
md1 : active raid1 sdc3[2] sdc2[1]
      1047552 blocks super 1.2 [2/2] [UU]
      
md0 : active raid0 sdb2[1] sdb1[0]
      2095104 blocks super 1.2 512k chunks
      
unused devices: <none>
[root@ZQ ~]# mdadm -G /dev/md5 -n 4
[root@ZQ ~]# cat /proc/mdstat 
Personalities : [raid0] [raid1] [raid6] [raid5] [raid4] 
md5 : active raid5 sde6[5] sde1[0] sde5[3](S) sde3[4] sde2[1]
      3142656 blocks super 1.2 level 5, 32k chunk, algorithm 2 [4/4] [UUUU]
      
md1 : active raid1 sdc3[2] sdc2[1]
      1047552 blocks super 1.2 [2/2] [UU]
      
md0 : active raid0 sdb2[1] sdb1[0]
      2095104 blocks super 1.2 512k chunks
      
unused devices: <none>
[root@ZQ ~]# cat /etc/mdadm.conf 
ARRAY /dev/md0 metadata=1.2 name=ZQ:0 UUID=00d9284f:6fd6b3b0:afc571c6:c5441608
ARRAY /dev/md1 metadata=1.2 name=ZQ:1 UUID=137b8247:e0ced5a2:625805ac:e9b31692
ARRAY /dev/md5 metadata=1.2 spares=1 name=ZQ:5 UUID=32056d5a:35cf0716:fd761180:cc7b848b

 

TAID5

标签:tar   man   altered   roc   stop   writing   cgroup   etc   故障   

原文地址:http://www.cnblogs.com/zq6041/p/6942438.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!