Chinaunix首页 | 论坛 | 博客
  • 博客访问: 23709
  • 博文数量: 5
  • 博客积分: 147
  • 博客等级: 入伍新兵
  • 技术积分: 75
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-15 12:37
文章分类

全部博文(5)

文章存档

2012年(5)

我的朋友

分类: LINUX

2012-09-11 01:29:49

首先创建riad0

1.       /dev/sdb/dev/sdc各创建10G分区

[root@localhost ~]# fdisk /dev/sdb

Command (m for help): p

 

Disk /dev/sdb: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        2610    20964793+   5  Extended

 

Command (m for help): n

Command action

   l   logical (5 or over)

   p   primary partition (1-4)

l

First cylinder (1-2610, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +10240M

 

Command (m for help): t

Partition number (1-5): 5

Hex code (type L to list codes): fd

Changed system type of partition 5 to fd (Linux raid autodetect)

 

Command (m for help): w

The partition table has been altered!

创建/dev/sdc同操作

2. partprobe命令手动把磁盘操作写入到磁盘状态信息表里面(重要:否侧下面操作可能报错)

      [root@localhost ~]# partprobe

Warning: Unable to open /dev/hdc read-write (Read-only file system).  /dev/hdc has been opened read-only.

3.创建raid0分区

  

[root@localhost ~]# mdadm -C /dev/md0 -ayes -l0 -n2 /dev/sdb5,/dev/sdc5

mdadm: array /dev/md0 started.

   -C 创建 后面跟创建后raid磁盘号

-ayes(autoyes) 是创建后自动激活

-llevel)创建raid的级别

-n 创建raid所用磁盘(分区)的数量 后面跟磁盘路径

4. 格式化文件系统/dev/md0

 [root@localhost ~]# mkfs.ext3 /dev/md0

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

2506752 inodes, 5004160 blocks

250208 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

153 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000

 

Writing inode tables: 139/153

5.在根目录创建raid0目录然后把/dev/md0挂载到/raid0

  [root@localhost /]# mkdir raid0

  [root@localhost /]# mount -t ext3 /dev/md0 /raid0

[root@localhost /]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda2             18844872   4799332  13072808  27% /

/dev/sda5               342239     10296    314274   4% /test

/dev/sda1               101086     11985     83882  13% /boot

tmpfs                   255272         0    255272   0% /dev/shm

/dev/md0              19701940    176200  18524908   1% /raid0

6.为保证系统重启后能自动挂载需要写入/etc/fstab文件

[root@localhost /]# vi /etc/fstab

LABEL=/                 /                       ext3    defaults        1 1

LABEL=/test             /test                   ext3    defaults,usrquota        1 2

LABEL=/boot1            /boot                   ext3    defaults        1 2

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

LABEL=SWAP-sda3         swap                    swap    defaults        0 0

/dev/md0                /raid0                  ext3    defaults        0 1

之后一定要mount –a 测试下配置错误会导致重启不能启动

 

 

 

 

下面做raid1

1. 首先在创建连个相同容量的分区(容量必须相同)

2.partprobe更新磁盘状态信息

  [root@localhost ~]# partprobe

Warning: Unable to open /dev/hdc read-write (Read-only file system).  /dev/hdc has been opened read-only.

2.       创建raid1

[root@localhost ~]# mdadm -C /dev/md1 -ayes -l1 -n2 /dev/sdb6 /dev/sdc6

mdadm: array /dev/md1 started.

3.       格式化/dev/md1

[root@localhost ~]# mkfs.ext3 /dev/md1

4.       挂载/dev/md1/raid1

[root@localhost ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda2              18G  4.6G   13G  27% /

/dev/sda5             335M   11M  307M   4% /test

/dev/sda1              99M   12M   82M  13% /boot

tmpfs                 250M     0  250M   0% /dev/shm

/dev/md0               19G  173M   18G   1% /raid0

/dev/md1               11G  155M  9.7G   2% /raid1

5.       重启后自动挂载写入到/etc/fstab

6.       然后mount –a 测试(重要)

 

 

 

下面做raid5

1.       添加3块容量相同的硬盘/dev/sdd;/dev/sde;/dev/sdf然后格式化idfd的分区

[root@localhost ~]# fdisk -l /dev/sd{d,e,f}

 

Disk /dev/sdd: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdd1               1        2610    20964793+  fd  Linux raid autodetect

 

Disk /dev/sde: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sde1               1        2610    20964793+  fd  Linux raid autodetect

 

Disk /dev/sdf: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdf1               1        2610    20964793+  fd  Linux raid autodetect

2.       partprobe更新磁盘状态

3.       创建raid5

[root@localhost ~]# mdadm -C /dev/md5 -ayes -l5 -n3 /dev/sd{d,e,f}1

mdadm: /dev/sdd1 appears to contain an ext2fs file system

    size=41929344K  mtime=Thu Sep  6 22:09:09 2012

mdadm: /dev/sdd1 appears to be part of a raid array:

    level=raid5 devices=3 ctime=Thu Sep  6 22:02:17 2012

mdadm: /dev/sde1 appears to be part of a raid array:

    level=raid5 devices=3 ctime=Thu Sep  6 22:02:17 2012

mdadm: /dev/sdf1 appears to contain an ext2fs file system

    size=41929344K  mtime=Thu Sep  6 22:09:09 2012

mdadm: /dev/sdf1 appears to be part of a raid array:

    level=raid5 devices=3 ctime=Thu Sep  6 22:02:17 2012

Continue creating array? y

mdadm: array /dev/md5 started

 

4格式化/dev/md5

[root@localhost ~]# mkfs.ext3 /dev/md5

5.挂载/dev/md5/raid5df查看

[root@localhost ~]# mount /dev/md5 /raid5

[root@localhost ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda2              18G  4.6G   13G  27% /

/dev/sda5             335M   11M  307M   4% /test

/dev/sda1              99M   12M   82M  13% /boot

tmpfs                 250M     0  250M   0% /dev/shm

/dev/md5               40G  177M   38G   1% /raid5

/dev/md0               40G  177M   38G   1% /raid0

/dev/md1               11G  155M  9.7G   2% /raid1

1.    写入/etc/fstab保证重启后自动挂载(mount –a测试)

mknod /dev/md* b 9 0用于创建一个块文件

如何删除一个raid5

2.  umount /raid5

3.  mdadm –S /dev/md5

4.  mdadm –zero-superblock /dev/sda{3..5}

5.  重新添加分区到raid5

6.  Mdadm –C /dev/md5 –ayes –l5 –n3 /dev/sda{3..5}

7.  查看raid详细情况

8.     Mdadm –D /dev/md0cat /proc/mdstat

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