CentOS6.5软raid0创建
时间:2015-03-11 04:52 来源:linux.it.net.cn 作者:IT
CentOS6.5
1.yum install -y mdadm parted
[root@mytest1 ~]# yum install mdadm parted
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mdadm x86_64 3.2.6-7.el6_5.2 updates 337 k
parted x86_64 2.1-21.el6 base 606 k
Transaction Summary
================================================================================
2.对sdb,sdc两块磁盘分区,设置
[root@mytest1 ~]# 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)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305):
Using default value 1305
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help): p
Disk /dev/sdc: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c7662
Device Boot Start End Blocks Id System
/dev/sdc1 1 1305 10482381 fd Linux raid autodetect
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
3.分区同步免reboot
[root@mytest1 ~]# partprobe
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.
4.查看两块磁盘状态
[root@mytest1 ~]# fdisk -l /dev/sdb /dev/sdc
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0af7aca1
Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 fd Linux raid autodetect
Disk /dev/sdc: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c7662
Device Boot Start End Blocks Id System
/dev/sdc1 1 1305 10482381 fd Linux raid autodetect
5.创建raid0
[root@mytest1 ~]# mdadm -C /dev/md0 -ayes -l0 -n2 /dev/sd{b,c}1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
6.查看状态
[root@mytest1 ~]# cat /proc/mdstat
Personalities : [raid0]
md0 : active raid0 sdc1[1] sdb1[0]
20964352 blocks super 1.2 512k chunks
unused devices: <none>
[root@mytest1 ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sun Aug 10 14:15:50 2014
Raid Level : raid0
Array Size : 20964352 (19.99 GiB 21.47 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Sun Aug 10 14:15:50 2014
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Chunk Size : 512K
Name : mytest1:0 (local to host mytest1)
UUID : c62a98dc:7f802f31:6e4435ae:168a6829
Events : 0
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
6.创建mdadm配置文件
[root@mytest1 ~]# echo DEVICE /dev/sd{b,c}1 >> /etc/mdadm.conf
[root@mytest1 ~]# mdadm -Ds >> /etc/mdadm.conf
[root@mytest1 ~]# vi /etc/mdadm.conf
DEVICE /dev/sdb1 /dev/sdc1
ARRAY /dev/md0 level=raid0 num-devices=2 UUID=c62a98dc:7f802f31:6e4435ae:168a6829
7.创建文件系统
[root@mytest1 ~]# 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
1310720 inodes, 5241088 blocks
262054 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
8.开机自动挂载
[root@mytest1 ~]# mkdir /raid0disk
[root@mytest1 ~]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Aug 10 02:32:47 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_mytest1-root / ext4 defaults 1 1
UUID=af6ed5f7-9181-440e-9b49-fff643caba9d /boot ext4 defaults 1 2
/dev/mapper/vg_mytest1-tmp /tmp ext4 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
/dev/md0 /raid0disk ext4 defaults 0 0
~
~
"/etc/fstab" 16L, 816C written
9.挂载后确认
[root@mytest1 ~]# mount -a
[root@mytest1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_mytest1-root 6.8G 781M 5.7G 12% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/sda1 97M 28M 64M 31% /boot
/dev/mapper/vg_mytest1-tmp 1008M 34M 924M 4% /tmp
/dev/md0 20G 172M 19G 1% /raid0disk
(责任编辑:IT)
CentOS6.5 1.yum install -y mdadm parted [root@mytest1 ~]# yum install mdadm parted ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: mdadm x86_64 3.2.6-7.el6_5.2 updates 337 k parted x86_64 2.1-21.el6 base 606 k Transaction Summary ================================================================================ 2.对sdb,sdc两块磁盘分区,设置 [root@mytest1 ~]# 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) p Partition number (1-4): 1 First cylinder (1-1305, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): Using default value 1305 Command (m for help): t Selected partition 1 Hex code (type L to list codes): fd Changed system type of partition 1 to fd (Linux raid autodetect) Command (m for help): p Disk /dev/sdc: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000c7662 Device Boot Start End Blocks Id System /dev/sdc1 1 1305 10482381 fd Linux raid autodetect Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. 3.分区同步免reboot [root@mytest1 ~]# partprobe Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. 4.查看两块磁盘状态 [root@mytest1 ~]# fdisk -l /dev/sdb /dev/sdc Disk /dev/sdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0af7aca1 Device Boot Start End Blocks Id System /dev/sdb1 1 1305 10482381 fd Linux raid autodetect Disk /dev/sdc: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000c7662 Device Boot Start End Blocks Id System /dev/sdc1 1 1305 10482381 fd Linux raid autodetect 5.创建raid0 [root@mytest1 ~]# mdadm -C /dev/md0 -ayes -l0 -n2 /dev/sd{b,c}1 mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md0 started. 6.查看状态 [root@mytest1 ~]# cat /proc/mdstat Personalities : [raid0] md0 : active raid0 sdc1[1] sdb1[0] 20964352 blocks super 1.2 512k chunks unused devices: <none> [root@mytest1 ~]# mdadm -D /dev/md0 /dev/md0: Version : 1.2 Creation Time : Sun Aug 10 14:15:50 2014 Raid Level : raid0 Array Size : 20964352 (19.99 GiB 21.47 GB) Raid Devices : 2 Total Devices : 2 Persistence : Superblock is persistent Update Time : Sun Aug 10 14:15:50 2014 State : clean Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 Chunk Size : 512K Name : mytest1:0 (local to host mytest1) UUID : c62a98dc:7f802f31:6e4435ae:168a6829 Events : 0 Number Major Minor RaidDevice State 0 8 17 0 active sync /dev/sdb1 1 8 33 1 active sync /dev/sdc1 6.创建mdadm配置文件 [root@mytest1 ~]# echo DEVICE /dev/sd{b,c}1 >> /etc/mdadm.conf [root@mytest1 ~]# mdadm -Ds >> /etc/mdadm.conf [root@mytest1 ~]# vi /etc/mdadm.conf DEVICE /dev/sdb1 /dev/sdc1 ARRAY /dev/md0 level=raid0 num-devices=2 UUID=c62a98dc:7f802f31:6e4435ae:168a6829 7.创建文件系统 [root@mytest1 ~]# 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 1310720 inodes, 5241088 blocks 262054 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 160 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 37 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. 8.开机自动挂载 [root@mytest1 ~]# mkdir /raid0disk [root@mytest1 ~]# vi /etc/fstab # # /etc/fstab # Created by anaconda on Sun Aug 10 02:32:47 2014 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/vg_mytest1-root / ext4 defaults 1 1 UUID=af6ed5f7-9181-440e-9b49-fff643caba9d /boot ext4 defaults 1 2 /dev/mapper/vg_mytest1-tmp /tmp ext4 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 /dev/md0 /raid0disk ext4 defaults 0 0 ~ ~ "/etc/fstab" 16L, 816C written 9.挂载后确认 [root@mytest1 ~]# mount -a [root@mytest1 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_mytest1-root 6.8G 781M 5.7G 12% / tmpfs 939M 0 939M 0% /dev/shm /dev/sda1 97M 28M 64M 31% /boot /dev/mapper/vg_mytest1-tmp 1008M 34M 924M 4% /tmp /dev/md0 20G 172M 19G 1% /raid0disk (责任编辑:IT) |