RHEL6.5 配置 RAID5下的 LVM卷
时间:2014-09-18 22:57 来源:linux.it.net.cn 作者:it
安装mdadm
1
2
3
4
5
6
7
[root
@leaus
~]
# mount /dev/cdrom/mnt/cdrom/
mount: block device /dev/sr0 iswrite-protected, mounting
read-only
[root
@leaus
~]
# cd /mnt/cdrom/Packages/
#使用rpm命令安装mdadm
[root
@leaus
Packages]
# rpm -ivhmdadm-3.2.5-4.el6.x86_64.rpm
Preparing...
########################################### [100%]
package mdadm-3.2.5-4.el6.x86_64 is already installed
查看安装文件
1
2
3
4
5
[root
@leaus
Packages]
# rpm -qa mdadm
mdadm-3.2.5-4.el6.x86_64
[root
@leaus
Packages]
# rpm -qc mdadm
/etc/cron.d/raid-check
/etc/sysconfig/raid-check
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
[root
@leaus
~]
# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x0006c28a
Device Boot Start
End
Blocks Id System
/dev/sda1 * 1 131 1048576 83 Linux
Partition 1 does not
end
on cylinder boundary.
/dev/sda2 131 2742 20971520 83 Linux
/dev/sda3 2742 4047 10485760 83 Linux
/dev/sda4 4047 5222 9436160 5 Extended
/dev/sda5 4048 4309 2097152 82 Linux swap / Solaris
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00000000
Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00000000
Disk /dev/sdd: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00000000
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
[root
@leaus
~]
# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x27088e01.
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):
Value out of range.
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):
Using
default
value 2610
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): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
1
2
3
4
5
6
7
8
mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
#察看磁盘分区 会发现多出来一个分区
Disk /dev/md0: 42.9 GB, 42915069952 bytes
2 heads, 4 sectors/track, 10477312 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 524288 bytes / 1048576 bytes
Disk identifier: 0x00000000
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
[root
@leaus
~]
# 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
2621440 inodes, 10477312 blocks
523865 blocks (5.00%) reserved
for
the super user
First data block=0
Maximum filesystem blocks=4294967296
320 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, 7962624
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
#把raid5卷加入启动
[root
@leaus
~]
# mdadm --detail --scan >> /etc/mdadm.conf
[root
@leaus
~]
# cat /proc/mdstat
#查看raid5完成
Personalities :
[raid6]
[raid5]
[raid4]
md0 : active raid5 sdd[3] sdc[1] sdb[0]
41909248 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2]
[UU_]
[========>............] recovery = 44.6% (9351040/20954624) finish=2.2min speed=85136K/sec
unused devices: <none>
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
#创建PV
[root
@leaus
/]
# pvcreate /dev/md0
Physical volume
"/dev/md0"
successfully created
#创建VG
[root
@leaus
/]
# vgcreate t1 /dev/md0
Volume group
"t1"
successfully created
#创建LV
[root
@leaus
/]
# lvcreate -L 20G -n file1 t1
Logical volume
"file1"
created
#格式化LV
[root
@leaus
/]
# mkfs.ext4 /dev/t1/file1
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, 5242880 blocks
262144 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 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
#挂载LV分区
[root
@leaus
/]
# mount /dev/t1/file1 /root/data
[root
@leaus
/]
# cd /root/data/
[root
@leaus
data]
# ll
total 16
drwx------. 2 root root 16384 Aug 14 20:25 lost+found
#写入文件
[root
@leaus
/]
# cd /root/data/
[root
@leaus
data]
# touch 123.txt
[root
@leaus
data]
# touch 456.txt
1
2
3
4
5
6
[root
@leaus
~]
# cat /proc/mdstat
Personalities :
[raid6]
[raid5]
[raid4]
md0 : active raid5 sdb[1] sdc[3]
41909248 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2]
[_UU]
unused devices: <none>
1
2
3
4
5
6
[root
@leaus
~]
# cd /root/data/
[root
@leaus
data]
# ll
total 16
-rw
-r--r--. 1 root root 0 Aug 14 20:34 123.txt
-rw
-r--r--. 1 root root 0 Aug 14 20:34 456.txt
drwx------. 2 root root 16384 Aug 14 20:25 lost+found
1
2
mdadm /dev/md0 --fail /dev/sdb1 让坏硬盘在raid中失效
mdadm /dev/md0 --remove /dev/sdb1 移除坏硬盘
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
[root
@leaus
~]
# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x0006c28a
Device Boot Start
End
Blocks Id System
/dev/sda1 * 1 131 1048576 83 Linux
Partition 1 does not
end
on cylinder boundary.
/dev/sda2 131 2742 20971520 83 Linux
/dev/sda3 2742 4047 10485760 83 Linux
/dev/sda4 4047 5222 9436160 5 Extended
/dev/sda5 4048 4309 2097152 82 Linux swap / Solaris
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xf770fa99
Device Boot Start
End
Blocks Id System
/dev/sdb1 1 2610 20964793+ fd Linux raid autodetect
Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xb1a21bfd
Device Boot Start
End
Blocks Id System
/dev/sdc1 1 2610 20964793+ fd Linux raid autodetect
Disk /dev/sdd: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00000000
Disk /dev/md0: 42.9 GB, 42915069952 bytes
2 heads, 4 sectors/track, 10477312 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 524288 bytes / 1048576 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/t1-file1: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 524288 bytes / 1048576 bytes
Disk identifier: 0x00000000
1
2
3
4
5
6
7
8
9
[root
@leaus
~]
#mdadm /dev/md0 --add /dev/sdd
[root
@leaus
~]
#cat /proc/mdstat
#察看RAID5的同步完成情况
Personalities :
[raid6]
[raid5]
[raid4]
md0 : active raid5 sdd[4] sdb[1] sdc[3]
41909248 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2]
[_UU]
[=>...................] recovery = 8.0% (1682688/20954624) finish=2.2min speed=140224K/sec
unused devices: <none>
1
2
3
4
5
6
7
[root
@leaus
~]
# mount /dev/mapper/t1-file1 /root/data/
[root
@leaus
~]
# cd /root/data
[root
@leaus
data]
# ll
total 16
-rw
-r--r--. 1 root root 0 Aug 14 20:34 123.txt
-rw
-r--r--. 1 root root 0 Aug 14 20:34 456.txt
drwx------. 2 root root 16384 Aug 14 20:25 lost+found
(责任编辑:IT)
安装mdadm
查看安装文件
(责任编辑:IT) |