设为首页 收藏本站
查看: 791|回复: 0

[经验分享] RHEL6.5 配置 RAID5下的 LVM卷

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-8-15 09:00:11 | 显示全部楼层 |阅读模式
安装mdadm挂载RHEL6.5的安装光盘
1
2
3
4
5
6
7
[iyunv@leaus ~]# mount /dev/cdrom/mnt/cdrom/
mount: block device /dev/sr0 iswrite-protected, mounting read-only
[iyunv@leaus ~]# cd /mnt/cdrom/Packages/
#使用rpm命令安装mdadm
[iyunv@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
[iyunv@leaus Packages]# rpm -qa mdadm
mdadm-3.2.5-4.el6.x86_64
[iyunv@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
[iyunv@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




以上共有四个分区,其中/dev/sda 为系统盘,剩余三个盘用于配置RAID5卷



格式化硬盘
raid分区类型为fd
具体操作为
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
[iyunv@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.



依次对/dev/sdb、/dev/sdc、/dev/sdd进行格式化操作

建立raid5卷
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




格式化RAID5卷

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
[iyunv@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卷加入启动
[iyunv@leaus ~]# mdadm --detail --scan >> /etc/mdadm.conf
[iyunv@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>



在RAID5 上创建LVM卷

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
[iyunv@leaus /]# pvcreate /dev/md0
  Physical volume "/dev/md0" successfully created
#创建VG
[iyunv@leaus /]# vgcreate t1 /dev/md0
  Volume group "t1" successfully created
#创建LV
[iyunv@leaus /]# lvcreate -L 20G -n file1 t1
  Logical volume "file1" created
#格式化LV
[iyunv@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分区
[iyunv@leaus /]# mount /dev/t1/file1 /root/data
[iyunv@leaus /]# cd /root/data/
[iyunv@leaus data]# ll
total 16
drwx------. 2 root root 16384 Aug 14 20:25 lost+found
#写入文件
[iyunv@leaus /]# cd /root/data/
[iyunv@leaus data]# touch 123.txt
[iyunv@leaus data]# touch 456.txt




察看硬盘损坏后的磁盘系统
缺少了/dev/sdd

1
2
3
4
5
6
[iyunv@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
[iyunv@leaus ~]# cd /root/data/
[iyunv@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




RAID5的Rebuild
去掉损坏硬盘
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
[iyunv@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



将/dev/sdd进行格式化
参考之前进行的格式化过程
在RAID5中添加硬盘
1
2
3
4
5
6
7
8
9
[iyunv@leaus ~]#mdadm /dev/md0 --add /dev/sdd
[iyunv@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
[iyunv@leaus ~]# mount /dev/mapper/t1-file1 /root/data/
[iyunv@leaus ~]# cd /root/data
[iyunv@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、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-23881-1-1.html 上篇帖子: linux软件包管理之RPM 下篇帖子: 在CentOS-7.0下高级硬盘管理RAID 1+0方案
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表