Linux 磁盘管理~~~~RAID1

Linux 磁盘管理~~~~RAID1

 

 

实验环境

     Linux操作系统的pc机上添加230g大小的磁盘

   

 

 

实施步骤:

    1.0

       对磁盘进行分区

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

Device contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with diskidentifier 0x5a1d7a13.

Changes will remain in memory only, untilyou decide to write them.

After that, of course, the previous contentwon‘t be recoverable.

 

Warning: invalid flag 0x0000 of partitiontable 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-3916, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G}(1-3916, default 3916): +300M

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

[root@host129 ~]# fdisk /dev/sdc

Device contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with diskidentifier 0xa5a6acdf.

Changes will remain in memory only, untilyou decide to write them.

After that, of course, the previous contentwon‘t be recoverable.

 

Warning: invalid flag 0x0000 of partitiontable 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-3916, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G}(1-3916, default 3916): +400M

 

Command (m for help): w

 

 

 

安装mdadm

[root@host129 ~]# mkdir /mnt/cdrom

[root@host129 ~]# mount /dev/cdrom/mnt/cdrom/

mount: block device /dev/sr0 iswrite-protected, mounting read-only

[root@host129 ~]# cd /mnt/cdrom/Packages/

[root@host129 Packages]# ls mdadm*

mdadm-3.2.5-4.el6.x86_64.rpm

[root@host129 Packages]# rpm -Uvhmdadm-3.2.5-4.el6.x86_64.rpm

创建RAID1

[root@host129 Packages]# mdadm-Cv /dev/md0 -l1 -n2  /dev/sdc /dev/sdb

mdadm: /dev/sdc appears to bepart of a raid array:

    level=raid0 devices=0 ctime=Thu Jan  1 08:00:00 1970

mdadm: partition table existson /dev/sdc but will be lost or

       meaningless after creating array

mdadm: Note: this array hasmetadata at the start and

    may not be suitable as a boot device.  If you plan to

    store ‘/boot‘ on this device please ensurethat

    your boot-loader understands md/v1.xmetadata, or use

    --metadata=0.90

mdadm: /dev/sdb appears to bepart of a raid array:

    level=raid0 devices=0 ctime=Thu Jan  1 08:00:00 1970

mdadm: partition table existson /dev/sdb but will be lost or

       meaningless after creating array

mdadm: size set to 31440768K

Continue creating array? y

mdadm: Defaulting to version1.2 metadata

mdadm: array /dev/md0 started.

[root@host129 Packages]# ls/dev/md0

/dev/md0

查看

[root@host129 Packages]# mdadm--detail /dev/md0

/dev/md0:

        Version : 1.2

  Creation Time : Thu Aug 14 16:02:21 2014

     Raid Level : raid1

     Array Size : 31440768 (29.98 GiB 32.20 GB)

  Used Dev Size : 31440768 (29.98 GiB 32.20 GB)

   Raid Devices : 2

  Total Devices : 2

    Persistence : Superblock is persistent

 

    Update Time : Thu Aug 14 16:04:40 2014

          State : clean, resyncing

 Active Devices : 2

Working Devices : 2

 Failed Devices : 0

  Spare Devices : 0

 

  Resync Status : 89% complete

 

           Name : host129.localdomain:0  (local to host host129.localdomain)

           UUID : 10fa6c5d:1afaebc6:85f51847:e1f0b2ed

         Events : 14

 

    Number  Major   Minor   RaidDevice State

       0      8       32        0     active sync   /dev/sdc

       1      8       16        1     active sync   /dev/sdb

 

格式化

 

[root@host129 Packages]# mkfs.ext4 /dev/md0

mke2fs 1.41.12 (17-May-2010)

文件系统标签=

操作系统:Linux

块大小=4096 (log=2)

分块大小=4096 (log=2)

Stride=0 blocks, Stripewidth=0 blocks

1966080 inodes, 7860192 blocks

393009 blocks (5.00%) reservedfor the super user

第一个数据块=0

Maximum filesystem blocks=4294967296

240 block groups

32768 blocks per group, 32768fragments per group

8192 inodes per group

Superblock backups stored onblocks:

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

        4096000

 

正在写入inode: 完成

Creating journal (32768blocks): 完成

Writing superblocks andfilesystem accounting information: 完成

 

This filesystem will beautomatically checked every 39 mounts or

180 days, whichever comesfirst.  Use tune2fs -c or -i to override.

 

 

创建一个系统文件

[root@host129 ~]# mkdir /qq

[root@host129 ~]# mount /dev/md0/qq/

[root@host129 ~]# ll /qq 

[root@host129 ~]# vi /etc/txt

查看 和写入到配置=文件

[root@host129 ~]# mdadm -Ds

ARRAY/dev/md0 metadata=1.2 name=host129.localdomain:0UUID=10fa6c5d:1afaebc6:85f51847:e1f0b2ed

[root@host129 ~]# mdadm -Ds >>/etc/mdadm.conf

 

 

重启PC 进行验证

    [root@host129~]# reboot

     [root@host129 ~]# mount


[root@host129 ~]# cat /proc/mdstat

删除硬盘2 进行 模拟故障


查看日志

[root@host129 ~]# dmesg

 

 

重组RAID1  模拟恢复,还是30GB的硬盘,添加新的磁盘文件将30GBC.VMDK


fdisk-l /dev/sdb

加入新的

  

[root@host129 ~]# mdadm /dev/md0 -a /dev/sdc

mdadm:added /dev/sdc

[root@host129 ~]# cat /proc/mdstat


在日志中可以查看到重建的过程

本文出自 “何苦,如此痛楚” 博客,谢绝转载!

Linux 磁盘管理~~~~RAID1,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。