day21

RAID 0 RIAD 1 RIAD5 RIAD 10的特点和区别


day21_第1张图片
day21_第2张图片
day21_第3张图片
day21_第4张图片

Raid是廉价冗余磁盘阵列(Redundant Array of Inexpensive Disk)的简称, 有时也简称磁盘阵列(Disk Array)。



RAID分为两类:


软RAID,系统层面实现的,性能差。(基本上不使用)


硬RAID,硬件层面实现的,性能好。

主板板载RAID:功能弱,0,1

独立RAID卡:功能强,0,1,5,10 *****工作选择。


LVM全称(Logic Volume Management (Manager))逻辑卷管理,它的最大用途是可以【灵活的管理磁盘的容量】,让磁盘分区可以随意放大或缩小,便于更好的应用磁盘的剩余空间,如果过于强


调性能与备份,那么还是应该使用RAID功能,而不是LVM。


LVM是软件层面实现的,性能太低。性能降低5-10%。

买服务器插满磁盘,分区规划好,永远都不需要LVM。




RAID1又称为Mirror或Mirroring(镜像),

它的宗旨是最大限度的保证用户数据的可用性和可修复性。

RAID1的操作方式是把用户写入一个磁盘的数据百分之百地自动复制到另外

一个磁盘上,从而实现存储双份的数据。



RAID5描述 中庸

RAID5是一种存储性能、数据安全和存储成本兼顾的存储解决方案。


RAID5需要三块或以上的物理磁盘,可以提供热备盘实现故障的恢复;

采用【奇偶校验】,可靠性强,且只有同时损坏两块硬盘时数据才会完全损坏,

只损坏一块硬盘时,系统会根据存储的奇偶校验位重建数据,临时提供服务;此时如果有热备盘,系统还会自动在热备盘上重建故障磁盘上的数据;

RIAD 0 RIAD 1 RIAD 5 RIAD10



分区知识A:

回忆:

(1)什么是分区?

磁盘分区就相当于给磁盘打隔断。


(2)磁盘和分区在Linux里的命名。

IDE /dev/hda hdb

SCSI sda sdb

分区数字表示:sda1 sda2 sda3


(3)磁盘分区类型和特点:

1、主分区(primary)P

1)系统中必须要存在的分区,系统盘选择主分区安装。

2)数字编号只能是1-4.sda1、sda2、sda3、sda4。

3)主分区最多四个,最少一个。

2、扩展分区(extend)E

1)相当于一个独立的小磁盘。独立的分区表,不能独立存在。

2)有独立的分区表。

3)不能独立存在,即不能直接存放数据。

4)必须在扩展分区上建立逻辑分区才能存放数据。

5)占用主分区的编号(主分区+扩展分区)之和最多4个。

6)扩展分区可以没有,最多只能有一个。

3、逻辑分区(logic)L

2)数字编号只能是从5开始。

3)存放于扩展分区之上。

4)存放任意普通数据。


磁盘分区注意事项要点

一块硬盘的分区方式只能为如下组合之一:

(1)任意多个主分区,但要求1≤主分区数量≤4。

例如:一个硬盘可以分为4个主分区3个主分区2个主分区或1个主分区。

(2)扩展分区可以和主分区组合,但要求2≤(主分区+扩展分区)数量≤4)。

例如:3个主分区+1个扩展分区或2个主分区+1个扩展分区或1个主分区+1个扩展分区。

当总分区的数量大于4个的时候,必须提前分一个扩展分区,扩展分区最多只能有一个。

(3)如果要分成四个磁盘分区的话,那么最多就是可以:

P+ P + P + P

P+ P + P + E


问题:如果给一个磁盘分6个分区有哪些方案,同时写出分区/dev/sda(数字)。

3P+1E(3L)  1 2 3 5 6 7

2P+1E(4L)  12 5678

1P+1E(5L)  1 56789


分区分完了,空间还有剩余浪费掉空间。

P+ P + P + P

(4)磁盘分区工作原理:

磁盘是按柱面分区的。


磁盘分区登记的地点,磁盘分区表。

磁盘分区表存放分区结果信息的。

磁盘分区表位置,0磁道0磁头1扇区(512字节)

占用1扇区的前446字节(系统引导信息的)后面的64字节(分区表),

剩下2个字节分区结束标志。

磁盘分区表的容量是有限的,64字节,一个分区固定占16字节。

64/16=4分区(主分区+扩展分区)













(5)磁盘分区实战


磁盘分区关键就是修改64字节的的分区表而已。

磁盘分区常用命令fdisk,修改MBR分区表,MBR格式。

缺陷,被修改的磁盘大小不能大于2T。

磁盘分区其他命令parted,gpt分区格式,既能修改小于2T也能修改大于2T的磁盘。


小于2T就用fdisk

大于2T就用parted

fdisk -l查看所有磁盘

fdisk /dev/sdb   #<==开始给sdb磁盘分区

m   #<==查看分区的帮助信息。

d   delete a partition            #<==删除一个分区。

n   add a new partition           #<==添加一个新分区。

p   print the partition table     #<==查看分区结果信息。

q   quit without saving changes   #<==退出不保存。

w   write table to disk and exit  #<==保存并退出。




[root@oldboyedu ~]# fdisk -l

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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 /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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: 0x000cd234


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048      526335      262144   83  Linux

/dev/sda2          526336     2099199      786432   82  Linux swap / Solaris

/dev/sda3         2099200    41943039    19921920   83  Linux


[root@oldboyedu ~]# fdisk /dev/sdb   #<==开始给sdb磁盘分区

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 0xbc9b0906.


Command (m for help): m   #<==查看分区的帮助信息。

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

d   delete a partition            #<==删除一个分区。

   g   create a new empty GPT partition table

   G   create an IRIX (SGI) partition table

   l   list known partition types

m   print this menu               #<==查看分区的帮助信息。

n   add a new partition           #<==添加一个新分区。

   o   create a new empty DOS partition table

p   print the partition table     #<==查看分区结果信息。

q   quit without saving changes   #<==退出不保存。

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

w   write table to disk and exit  #<==保存并退出。

   x   extra functionality (experts only)


Command (m for help):


开始实践:


问题:如果给一个磁盘分6个分区有哪些方案,同时写出分区/dev/sda(数字)。

3P+1E(3L)  1 2 3 5 6 7

2P+1E(4L)  12 5678

1P+1E(5L)  1 56789

用下面方案:

3P+1E(3L)  1 2 3 5 6 7每个150M




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

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 0x827687e9.


Command (m for help): ^C

[root@oldboyedu ~]#

[root@oldboyedu ~]#

[root@oldboyedu ~]#

[root@oldboyedu ~]#

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

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 0xbc9b0906.


Command (m for help): m

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   g   create a new empty GPT partition table

   G   create an IRIX (SGI) partition table

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)


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):

First sector (2048-2097151, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +150M

Partition 1 of type Linux and of size 150 MiB is set


Command (m for help): p


Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0xbc9b0906


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      309247      153600   83  Linux


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):

First sector (309248-2097151, default 309248):

Using default value 309248

Last sector, +sectors or +size{K,M,G} (309248-2097151, default 2097151): +150m

Unsupported suffix: 'm'.

Supported: 10^N: KB (KiloByte), MB (MegaByte), GB (GigaByte)

            2^N: K  (KibiByte), M  (MebiByte), G  (GibiByte)

Last sector, +sectors or +size{K,M,G} (309248-2097151, default 2097151): +150M

Partition 2 of type Linux and of size 150 MiB is set


Command (m for help): p


Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0xbc9b0906


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      309247      153600   83  Linux

/dev/sdb2          309248      616447      153600   83  Linux


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):

First sector (616448-2097151, default 616448):

Using default value 616448

Last sector, +sectors or +size{K,M,G} (616448-2097151, default 2097151): +150M

Partition 3 of type Linux and of size 150 MiB is set


Command (m for help): p


Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0xbc9b0906


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      309247      153600   83  Linux

/dev/sdb2          309248      616447      153600   83  Linux

/dev/sdb3          616448      923647      153600   83  Linux


Command (m for help): n

Partition type:

   p   primary (3 primary, 0 extended, 1 free)

   e   extended

Select (default e): p

Selected partition 4

First sector (923648-2097151, default 923648):

Using default value 923648

Last sector, +sectors or +size{K,M,G} (923648-2097151, default 2097151): +150M

Partition 4 of type Linux and of size 150 MiB is set


Command (m for help): p


Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0xbc9b0906


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      309247      153600   83  Linux

/dev/sdb2          309248      616447      153600   83  Linux

/dev/sdb3          616448      923647      153600   83  Linux

/dev/sdb4          923648     1230847      153600   83  Linux


Command (m for help): n

If you want to create more than four partitions, you must replace a

primary partition with an extended partition first.


Command (m for help): d

Partition number (1-4, default 4): 4

Partition 4 is deleted


Command (m for help): p


Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0xbc9b0906


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      309247      153600   83  Linux

/dev/sdb2          309248      616447      153600   83  Linux

/dev/sdb3          616448      923647      153600   83  Linux


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 (923648-2097151, default 923648):

Using default value 923648

Last sector, +sectors or +size{K,M,G} (923648-2097151, default 2097151):

Using default value 2097151

Partition 4 of type Extended and of size 573 MiB is set


Command (m for help): p


Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0xbc9b0906


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      309247      153600   83  Linux

/dev/sdb2          309248      616447      153600   83  Linux

/dev/sdb3          616448      923647      153600   83  Linux

/dev/sdb4          923648     2097151      586752    5  Extended


Command (m for help): n

All primary partitions are in use

Adding logical partition 5

First sector (925696-2097151, default 925696):

Using default value 925696

Last sector, +sectors or +size{K,M,G} (925696-2097151, default 2097151): +150M

Partition 5 of type Linux and of size 150 MiB is set


Command (m for help): p  


Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0xbc9b0906


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      309247      153600   83  Linux

/dev/sdb2          309248      616447      153600   83  Linux

/dev/sdb3          616448      923647      153600   83  Linux

/dev/sdb4          923648     2097151      586752    5  Extended

/dev/sdb5          925696     1232895      153600   83  Linux


Command (m for help): n

All primary partitions are in use

Adding logical partition 6

First sector (1234944-2097151, default 1234944):

Using default value 1234944

Last sector, +sectors or +size{K,M,G} (1234944-2097151, default 2097151): +150M

Partition 6 of type Linux and of size 150 MiB is set


Command (m for help): p


Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0xbc9b0906


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      309247      153600   83  Linux

/dev/sdb2          309248      616447      153600   83  Linux

/dev/sdb3          616448      923647      153600   83  Linux

/dev/sdb4          923648     2097151      586752    5  Extended

/dev/sdb5          925696     1232895      153600   83  Linux

/dev/sdb6         1234944     1542143      153600   83  Linux


Command (m for help): n

All primary partitions are in use

Adding logical partition 7

First sector (1544192-2097151, default 1544192):

Using default value 1544192

Last sector, +sectors or +size{K,M,G} (1544192-2097151, default 2097151): +150M

Partition 7 of type Linux and of size 150 MiB is set


Command (m for help): p


Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0xbc9b0906


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      309247      153600   83  Linux

/dev/sdb2          309248      616447      153600   83  Linux

/dev/sdb3          616448      923647      153600   83  Linux

/dev/sdb4          923648     2097151      586752    5  Extended

/dev/sdb5          925696     1232895      153600   83  Linux

/dev/sdb6         1234944     1542143      153600   83  Linux

/dev/sdb7         1544192     1851391      153600   83  Linux


Command (m for help): w

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.

你可能感兴趣的:(day21)