手机版
你好,游客 登录 注册
背景:
阅读新闻

磁盘管理——RAID 0

[日期:2013-08-11] 来源:Linux社区  作者:justdb [字体:大 中 小]

第二步 格式化

[root@serv01 /]# mkfs.ext4 /dev/md0
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=128 blocks, Stripe width=256 blocks
262144 inodes, 1047552 blocks
52377 blocks (5.00%) reserved for the superuser
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments pergroup
8192 inodes per group
Superblock backups stored on blocks:
      32768,98304, 163840, 229376, 294912, 819200, 884736
 
Writing inode tables: done                         
Creating journal (16384 blocks): mdone
Writing superblocks and filesystemaccounting information: done
 
This filesystem will be automaticallychecked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@serv01 /]# mount /dev/md0 /web/
[root@serv01 /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2            9.7G  1.1G 8.1G  12% /
tmpfs                188M    0 188M  0% /dev/shm
/dev/sda1            194M  25M 160M  14% /boot
/dev/sda5            4.0G  137M 3.7G  4% /opt
/dev/sr0              3.4G  3.4G    0 100% /iso
/dev/md0              4.0G  72M 3.7G  2% /web
 
[root@serv01 /]# vim /etc/fstab
[root@serv01 /]# echo "/dev/md0 /webext4 defaults 1 2" >> /etc/fstab
[root@serv01 /]# cat /etc/fstab
 
#
# /etc/fstab
# Created by anaconda on Tue Jul 2300:54:37 2013
#
# Accessible filesystems, by reference, aremaintained under '/dev/disk'
# See man pages fstab(5), findfs(8),mount(8) and/or blkid(8) for more info
#
UUID=110fab7c-85c4-4bae-9114-98bc2ada24d8/                      ext4    defaults        1 1
UUID=ab434325-bf02-48e9-8ce7-78494a8ac71e/boot                  ext4    defaults        1 2
UUID=02ed2b3b-b7e1-493d-9a43-8e1dcac8aa6f/opt                    ext4    defaults        1 2
UUID=a088a35a-16d8-456a-a177-95c769c16e41swap                    swap    defaults        0 0
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
/dev/md0 /web ext4 defaults 1 2

第三步 重启后更名的解决及演示RAID0的应用

#然后重启,发现错误
#查看,发现已经更名
 
[root@serv01 ~]# ls /dev/md
md/  md127
[root@serv01 ~]# mdadm --manage /dev/md127--stop
mdadm: stopped /dev/md127
[root@serv01 ~]# ls /dev/md
md-device-map
[root@serv01 ~]# mdadm --datail /dev/md0
mdadm: unrecognized option '--datail'
Usage: mdadm --help
  forhelp
#查看RAID状态,发现没有使用
[root@serv01 ~]# cat /proc/mdstat
Personalities : [raid0]
unused devices: <none>
#固定名字,然后启动RAID
[root@serv01 ~]# mdadm --assemble /dev/md0/dev/sdb1 /dev/sdc1
mdadm: /dev/md0 has been started with 2drives.
#查看状态,已经启动了
[root@serv01 ~]# cat /proc/mdstat
Personalities : [raid0]
md0 : active raid0 sdb1[0] sdc1[1]
    4190208 blocks super 1.2 512k chunks
   
unused devices: <none>
#将RAID的信息保存到配置文件
[root@serv01 ~]# mdadm --detail —scan >/etc/mdadm.conf
#然后输入设备的挂载信息
[root@serv01 ~]# echo "/dev/md0 /webext4 defaults 1 2" >> /etc/fstab
#然后重启
[root@serv01 ~]# reboot
 
[root@larrywen 0731]# ssh 192.168.1.11
root@192.168.1.11's password:
Last login: Wed Jul 31 23:43:44 2013 from192.168.1.1
[root@serv01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2            9.7G  1.1G 8.1G  12% /
tmpfs                188M    0 188M  0% /dev/shm
/dev/sda1            194M  25M  160M  14% /boot
/dev/sda5            4.0G  137M 3.7G  4% /opt
/dev/md0              4.0G  72M 3.7G  2% /web
/dev/sr0              3.4G  3.4G    0 100% /iso
[root@serv01 ~]# cat /proc/mdstat
Personalities : [raid0]
md0 : active raid0 sdb1[0] sdc1[1]
    4190208 blocks super 1.2 512k chunks
   
unused devices: <none>
#发现正常
[root@serv01 ~]# ls /dev/md
md/ md0
 
#磁盘大小不一样,按照小的,比如一个磁盘是1G,另一个是2G,那么真正有用的只有1G
 
#RAID0:一块坏了,另一块就无法使用
[root@serv01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2            9.7G  1.1G 8.1G  12% /
tmpfs                188M    0 188M  0% /dev/shm
/dev/sda1            194M  25M 160M  14% /boot
/dev/sda5            4.0G  137M 3.7G  4% /opt
/dev/md0              4.0G  72M 3.7G  2% /web
/dev/sr0              3.4G  3.4G    0 100% /iso
[root@serv01 ~]# fdisk /dev/sdb
 
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): p
 
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0xf85ef5bd
 
  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1        261    2096451  fd  Linux raid autodetect
 
Command (m for help): o
Building a new DOS disklabel with diskidentifier 0xc29e300a.
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): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
 
WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.
The kernel still uses the old table. Thenew table will be used at
the next reboot or after you runpartprobe(8) or kpartx(8)
Syncing disks.
[root@serv01 ~]# fdisk -l|/dev/sdb1
-bash: /dev/sdb1: Permission denied
Disk /dev/sdd doesn't contain a validpartition table
Disk /dev/sde doesn't contain a validpartition table
Disk /dev/sdf doesn't contain a validpartition table
Disk /dev/sdg doesn't contain a validpartition table
Disk /dev/md0 doesn't contain a validpartition table
[root@serv01 ~]# fdisk -l|/dev/sdb
-bash: /dev/sdb: Permission denied
Disk /dev/sdd doesn't contain a validpartition table
Disk /dev/sde doesn't contain a validpartition table
Disk /dev/sdf doesn't contain a validpartition table
Disk /dev/sdg doesn't contain a validpartition table
Disk /dev/md0 doesn't contain a validpartition table
#重启发现提示你是否进入修复模式
#重新挂载根分区
mount -o remount,rw /
#删除配置的RAID,然后重启
#重新查看,然后发现RAID已经不能使用了
[root@larrywen 0731]# ssh 192.168.1.11
root@192.168.1.11's password:
Last login: Wed Jul 31 23:49:41 2013 from192.168.1.1
[root@serv01 ~]# cat /proc/mdstat
Personalities : [raid0]
md0 : inactive sdc1[1]
    2095104 blocks super 1.2
     
unused devices: <none>
[root@serv01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2            9.7G  1.1G 8.1G  12% /
tmpfs                188M    0 188M  0% /dev/shm
/dev/sda1            194M  25M 160M  14% /boot
/dev/sda5            4.0G  137M 3.7G  4% /opt
/dev/sr0              3.4G  3.4G    0 100% /iso
[root@serv01 ~]# mdadm --detail /dev/md
md/ md0
[root@serv01 ~]# mdadm --detail /dev/md0
/dev/md0:
      Version : 1.2
 Creation Time : Wed Jul 31 23:30:26 2013
    Raid Level : raid0
  Raid Devices : 2
 Total Devices : 1
  Persistence : Superblock is persistent
 
  Update Time : Wed Jul 31 23:30:26 2013
        State : active, FAILED, Not Started
 Active Devices : 1
Working Devices : 1
 Failed Devices : 0
 Spare Devices : 0
 
    Chunk Size : 512K
 
          Name : serv01.host.com:0  (localto host serv01.host.com)
          UUID : 1f1a007f:7ed82aa0:49722d2f:1e664330
        Events : 0
 
  Number  Major  Minor  RaidDevice State
      0      0        0      0      removed
      1      8      33      1      active sync  /dev/sdc1

相关阅读: 磁盘管理——RAID 1  http://www.linuxidc.com/Linux/2013-08/88616.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款