RAID:

HBA:基于主机的适配器

RAID:Redundent Array of Inexpensive Disks 廉价磁盘阵列

Independent       独立磁盘阵列

Level:仅用于标识磁盘组合方式的不同,不能取代数据备份

raid0,raid1,raid5,raid10,raid50,jbod

raid0:提高读写性能,没有容错能力。至少需要两块磁盘 100%

raid1:至少需要两块硬盘,镜像,硬件容错能力,读性能提升,写性能下降 50%

raid4:至少需要三块硬盘,允许一块盘出错,读写性能提升,(n-1)/n

raid5: 至少需要三块硬盘,允许一块盘出错,读写性能提升,(n-1)/n

raid6: 至少需要四块磁盘,允许两块盘出错。读写性能提升,(n-2)/n

raid10:至少需要四块磁盘。允许不同组内个各坏一块盘,读写性能提升,50%

raid01:

jbod:

md,可以组合任何块设备

mdadm,/etc/mdadm.conf

mdadm:模式化的工具

-A  Assemble 装配模式

-C  Create 创建模式

-n #:用于创建RAID设备的个数

-x #: 热备磁盘的个数

-l :指定RAID级别

-a :=yes(自动为创建的RAID设备创建设备文件) md mdp part p 如何创建设备文件

-c:指定块的大小,默认为512KB

-F FOLLOW 监控

-S 停止RAID

-D --detail: 显示阵列详细信息

Manage 管理模式专用项

-f:模拟损害

-r:模拟移除设备

-a:模拟添加新设备

watch

-n #:每个#执行一次指定的命令,单位为s

[root@mail ~]# watch -n1 'cat /proc/mdstat'

使用raid0创建一个6G大小的磁盘。

  1. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    [root@mail ~]# fdisk /dev/sdc
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel with disk identifier 0xba68f31c.
    Changes will remain in memory only, until you decide to write them.
    After that, of course, the previous content won't be recoverable.
     
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
     
    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
             switch off the mode (command 'c') and change display units to
             sectors (command 'u').
     
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-2610, default 1):
    Using default value 1
    Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +6G
     
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 2
    First cylinder (785-2610, default 785):
    Using default value 785
    Last cylinder, +cylinders or +size{K,M,G} (785-2610, default 2610): +6G
     
    Command (m for help): t
    Partition number (1-4): 1
    Hex code (type L to list codes): fd
    Changed system type of partition 1 to fd (Linux raid autodetect)
     
    Command (m for help): t
    Partition number (1-4): 2
    Hex code (type L to list codes): fd
    Changed system type of partition 2 to fd (Linux raid autodetect)
     
    Command (m for help): w
    The partition table has been altered!
     
    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@mail ~]# mdadm -C /dev/md0 -a yes -l 0 -n 2 /dev/sdc{1,2}
    mdadm: Defaulting to version 1.2 metadata
    mdadm: array /dev/md0 started.
    [root@mail ~]# cat /proc/mdstat
    Personalities : [raid0]
    md0 : active raid0 sdc2[1] sdc1[0]
          12585984 blocks super 1.2 512k chunks
           
    unused devices: <none>
    [root@mail ~]# mdadm -D /dev/md0
    /dev/md0:
            Version : 1.2
      Creation Time : Tue May 10 20:19:43 2016
         Raid Level : raid0
         Array Size : 12585984 (12.00 GiB 12.89 GB)
       Raid Devices : 2
      Total Devices : 2
        Persistence : Superblock is persistent
     
        Update Time : Tue May 10 20:19:43 2016
              State : clean
     Active Devices : 2
    Working Devices : 2
     Failed Devices : 0
      Spare Devices : 0
     
         Chunk Size : 512K
     
               Name : mail.saviorsyang.com:0  (local to host mail.saviorsyang.com)
               UUID : b5ec8803:366d2e9d:a1ddd0f2:58101d5c
             Events : 0
     
        Number   Major   Minor   RaidDevice State
           0       8       33        0      active sync   /dev/sdc1
           1       8       34        1      active sync   /dev/sdc2
     
    [root@mail ~]# mke2fs -t ext4 /dev/md0
    mke2fs 1.43-WIP (20-Jun-2013)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=128 blocks, Stripe width=256 blocks
    786864 inodes, 3146496 blocks
    157324 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=3225419776
    97 block groups
    32768 blocks per group, 32768 fragments per group
    8112 inodes per group
    Superblock backups stored on blocks:
      32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
     
    Allocating group tables: done                           
    Writing inode tables: done                           
    Creating journal (32768 blocks):
    done
    Writing superblocks and filesystem accounting information: done
     
    [root@mail ~]# mkdir  /test/md0
    [root@mail ~]# mount /dev/md0 /test/md0
    [root@mail ~]# mount
    /dev/mapper/vg_demo-lv_root on / type ext4 (rw)
    proc on /proc type proc (rw)
    sysfs on /sys type sysfs (rw)
    devpts on /dev/pts type devpts (rw,gid=5,mode=620)
    tmpfs on /dev/shm type tmpfs (rw)
    /dev/sda1 on /boot type ext4 (rw)
    /dev/sdb1 on /student type ext4 (rw)
    /dev/sr0 on /mnt type iso9660 (ro)
    none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
    /dev/md0 on /test/md0 type ext4 (rw)

    使用raid1创建一个2G大小的磁盘。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    [root@mail ~]# fdisk /dev/sdc
     
    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
             switch off the mode (command 'c') and change display units to
             sectors (command 'u').
     
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    e
    Partition number (1-4):
    Value out of range.
    Partition number (1-4): 3
    First cylinder (1569-2610, default 1569):
    Using default value 1569
    Last cylinder, +cylinders or +size{K,M,G} (1569-2610, default 2610):
    Using default value 2610
     
    Command (m for help): n
    Command action
       l   logical (5 or over)
       p   primary partition (1-4)
    l
    First cylinder (1569-2610, default 1569):
    Using default value 1569
    Last cylinder, +cylinders or +size{K,M,G} (1569-2610, default 2610): +2G
     
    Command (m for help): n
    Command action
       l   logical (5 or over)
       p   primary partition (1-4)
    l
    First cylinder (1831-2610, default 1831):
    Using default value 1831
    Last cylinder, +cylinders or +size{K,M,G} (1831-2610, default 2610): +2G
     
    Command (m for help): w
    The partition table has been altered!
     
    Calling ioctl() to re-read partition table.
     
    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table. The new table will be used at
    the next reboot or after you run partprobe(8) or kpartx(8)
    Syncing disks.
     
    [root@mail ~]# fdisk /dev/sdc
     
    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
             switch off the mode (command 'c') and change display units to
             sectors (command 'u').
     
    Command (m for help): t
    Partition number (1-6): 5
    Hex code (type L to list codes): fd
    Changed system type of partition 5 to fd (Linux raid autodetect)
     
    Command (m for help): t
    Partition number (1-6): 6
    Hex code (type L to list codes): fd
    Changed system type of partition 6 to fd (Linux raid autodetect)
     
    Command (m for help): w
    The partition table has been altered!
     
    Calling ioctl() to re-read partition table.
     
    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table. The new table will be used at
    the next reboot or after you run partprobe(8) or kpartx(8)
    Syncing disks.
         
    [root@mail ~]# partx /dev/sdc
    # 1:        63- 12594959 ( 12594897 sectors,   6448 MB)
    # 2:  12594960- 25189919 ( 12594960 sectors,   6448 MB)
    # 3:  25189920- 41929649 ( 16739730 sectors,   8570 MB)
    # 4:         0-       -1 (        0 sectors,      0 MB)
    # 5:  25189983- 29398949 (  4208967 sectors,   2154 MB)
    # 6:  29399013- 33607979 (  4208967 sectors,   2154 MB)
     
    [root@mail ~]# cat /proc/partitions
    major minor  #blocks  name
     
       8       32   20971520 sdc
       8       33    6297448 sdc1
       8       34    6297480 sdc2
       8       35         31 sdc3
       8       37    2104483 sdc5
       8       38    2104483 sdc6
       8        0   52428800 sda
       8        1     512000 sda1
       8        2   51915776 sda2
       8       16  524288000 sdb
       8       17  524281243 sdb1
       8       48   20971520 sdd
      11        0    3763200 sr0
     252        0   47816704 dm-0
     252        1    4096000 dm-1
       9        0   12585984 md0
    [root@mail ~]# mdadm -C /dev/md1 -a yes -l 1 -n 2 /dev/sdc{5,6}
    mdadm: Note: this array has metadata at the start and
        may not be suitable as a boot device.  If you plan to
        store '/boot' on this device please ensure that
        your boot-loader understands md/v1.x metadata, or use
        --metadata=0.90
    Continue creating array? yes
    mdadm: Defaulting to version 1.2 metadata
    mdadm: array /dev/md1 started.
    [root@mail ~]# cat /proc/mdstat
    Personalities : [raid0] [raid1]
    md1 : active raid1 sdc6[1] sdc5[0]
          2102400 blocks super 1.2 [2/2] [UU]
          [=================>...]  resync = 85.5% (1800064/2102400) finish=0.0min speed=200007K/sec
           
    md0 : active raid0 sdc2[1] sdc1[0]
          12585984 blocks super 1.2 512k chunks
           
    unused devices: <none>
    [root@mail ~]# cat /proc/mdstat
    Personalities : [raid0] [raid1]
    md1 : active raid1 sdc6[1] sdc5[0]
          2102400 blocks super 1.2 [2/2] [UU]
           
    md0 : active raid0 sdc2[1] sdc1[0]
          12585984 blocks super 1.2 512k chunks
           
    unused devices: <none>
     
     
    [root@mail ~]#
    [root@mail ~]# mke2fs -t ext4 /dev/md1
    mke2fs 1.43-WIP (20-Jun-2013)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    131648 inodes, 525600 blocks
    26280 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=541065216
    17 block groups
    32768 blocks per group, 32768 fragments per group
    7744 inodes per group
    Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912
     
    Allocating group tables: done                           
    Writing inode tables: done                           
    Creating journal (16384 blocks): done
    Writing superblocks and filesystem accounting information: done
     
    [root@mail ~]# mkdir -pv /test/md1
    [root@mail ~]# mount /dev/md1 /test/md1
    [root@mail ~]# mount
    /dev/mapper/vg_demo-lv_root on / type ext4 (rw)
    proc on /proc type proc (rw)
    sysfs on /sys type sysfs (rw)
    devpts on /dev/pts type devpts (rw,gid=5,mode=620)
    tmpfs on /dev/shm type tmpfs (rw)
    /dev/sda1 on /boot type ext4 (rw)
    /dev/sdb1 on /student type ext4 (rw)
    /dev/sr0 on /mnt type iso9660 (ro)
    none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
    /dev/md1 on /test/md1 type ext4 (rw)

Linux软raid创建的更多相关文章

  1. Linux 常见 RAID 及软 RAID 创建

    RAID可以大幅度的提高磁盘性能,以及可靠性,这么好的技术怎么能不掌握呢!此篇介绍一些常见RAID,及其在Linux上的软RAID创建方法. mdadm 创建软RAID mdadm -C -v /de ...

  2. 网易视频云技术分享:linux软raid的bitmap分析

    网易视频云是网易倾力打造的一款基于云计算的分布式多媒体处理集群和专业音视频技术,提供稳定流畅.低时延.高并发的视频直播.录制.存储.转码及点播等音视频的PAAS服务,在线教育.远程医疗.娱乐秀场.在线 ...

  3. linux软raid练习

    创建一个空间大小为10G的raid5,要求其chunk为1024k,格式为ext4文件系统,开机可自动挂载至/backup目录,并支持acl功能: 1 2 3 4 5 6 7 8 9 10 11 12 ...

  4. Linux中的LVM和软RAID

        在实际工作中,会经常碰到所给的服务器硬盘容量太小,而实际的应用软件中却需要一个容量较大的分区进行数据存储等,除了通过硬件RAID卡来实现合并多硬盘外,其实我们也可以通过软件的方式来实现. 实验 ...

  5. Linux下创建软Raid

    1- Linux下创建软Raid   步骤1.创建磁盘,并转换为fd #fdisk /dev/sdb //这里使用新的磁盘sdb 然后输入n ,创建分区 使用默认的起始点 输入大小为+100M 然后重 ...

  6. ☆RHEL6创建软raid的使用☆——经典之作

    raid主要的种类 1.raid0  扩展卷   raid 0又称Stripee或Striping,中文译为集带工作方式, 有时也可以理解为拼凑. 它是将要存取的数据以条带状的形式尽量平均分配到多个硬 ...

  7. linux磁盘管理系列-软RAID的实现

    1 什么是RAID RAID全称是独立磁盘冗余阵列(Redundant Array of Independent Disks),基本思想是把多个磁盘组合起来,组合一个磁盘阵列组,使得性能大幅提高. R ...

  8. linux磁盘管理系列二:软RAID的实现

    磁盘管理系列 linux磁盘管理系列一:磁盘配额管理   http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_040_quota.html l ...

  9. LINUX中软RAID的实现方案

    转自linux就该这么学 应用场景 Raid大家都知道是冗余磁盘的意思(Redundant Arrays of Independent Disks,RAID),可以按业务系统的需要提供高可用性和冗余性 ...

随机推荐

  1. STM32——CAN通讯实现

    CAN通讯的实现步骤: 1.CAN初始化,其中包括:a.配置CAN时钟,配置IO: b.使能CAN中断向量: c.CAN硬件寄存器配置初始化: d.过滤器初始化: e.打开CAN中断. 2.CAN发送 ...

  2. ibatis入门教程

    转载自  http://www.cnblogs.com/ycxyyzw/archive/2012/10/13/2722567.html iBatis 简介: iBatis 是apache 的一个开源项 ...

  3. 解决PyScripter中文乱码问题

    环境: PyScripter 2.6.0.0 python3.4 问题: PyScripter有个小坑,打开文件后中文都成了乱码.在PyScripter中新建的文件中文可以正常显示,但是重新打开后中文 ...

  4. linux内核分析——扒开系统调用的三层皮(下)

    20135125陈智威 原创作品转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 ” 实验 ...

  5. NSOperation操作依赖和监听

    1.操作依赖 NSOperation之间可以设置依赖来保证执行顺序 比如一定要让操作A执行完后,才能执行操作B,可以这么写 [operationB addDependency:operationA]; ...

  6. 听课程C# Intermediate: Classes, Interfaces and OOP的笔记,持续修改更新ing

    在第二章第7节中,我尝试并给我的Vistal Studio 2015加装了Resharper,感觉非常好用,现在就分享下我的一点心得. 首先为了防止Resharper的快捷键失灵,可以先重置所有的 V ...

  7. 2014西安现场赛F题 UVALA 7040

    地址 题意:求在m种颜色中挑选k种颜色,给n个花朵涂色有几种方法. 分析:画图可以发现,基本的公式就是k ×(k-1)^(n-1).但这仅保证了相邻颜色不同,总颜色数不超过k种,并没有保证恰好出现k种 ...

  8. [.NET] CErrStack 方便地管理错误或异常

    Option Explicit On Option Strict On Imports System.Reflection Imports System.Diagnostics Public Stru ...

  9. ListView到顶部不可再拉

    ListView到顶部不可再拉,主要针对魅族.索爱等手机: 如果你的程序针对的是2.3及以上版本,可以直接调用AbsListView的setOverScrollMode方法来解决这个问题. 如果还要兼 ...

  10. 第一章Android系统移植与驱动开发概述--读书笔记

    以前,初步学习过嵌入式Linux驱动开发的基础课程,对于驱动开发可以说是有了一点点微末的基础吧.首先我们要对Android嵌入式系统有一个初步的认识,Android系统发展到今天已经具备了完善的架构. ...