實驗目的:
1。將sdc,sdd, sde 3塊硬碟組成raid5模式
2。建立lvm
3。模擬故障,sdd出故障,刪除該硬碟,再重新新增硬碟,恢復raid5
4。增加lvm容量
實驗步驟
1,格式化3塊硬碟
fdisk /dev/sdc //格式化/dev/sdc
command (m for help): n //增加乙個新的分割槽
command action
e extended
p primary partition (1-4)
p //建立主分割槽
partition number (1-4): 1 //分割槽號為1
first cylinder (1-2610, default 1): //設定分割槽大小
using default value 1
last cylinder or +size or +sizem or +sizek (1-2610, default 2610):
using default value 2610
command (m for help): t //改變系統的id
selected partition 1
hex code (type l to list codes): fd //設定系統hex為fd,即raid模式
changed system type of partition 1 to fd (linux raid autodetect)
command (m for help): w //儲存
分別格式化/dev/sdd /dev/sde
fdisk -l //檢視分割槽情況
建立raid5
[root@localhost ~]# mdadm --create /dev/md0 --level=5 --raid-device=3 /dev/sdc1 /dev/sdd1 /dev/sde1 //建立raid5,/dev/md0陣列裝置名,level=5陣列模式raid5,raid-device=3raid有3塊硬碟
mdadm: array /dev/md0 started.
[root@localhost ~]# cat /proc/mdstat //檢視資料同步情況
[root@localhost ~]# tail /var/log/messages //檢視系統日誌
建立raid5的配置檔案
[root@localhost ~]# echo device /dev/sdc1 /dev/sdd1 /dev/sde1 /etc/mdadm.conf
[root@localhost ~]# mdadm --detail --scan >> /etc/mdadm.conf
[root@localhost ~]# cat /etc/mdadm.conf
array /dev/md0 level=raid5 num-devices=3 uuid=36f261b7:4899a54c:9edf36d1:9eb86529
[root@localhost ~]# mdadm -s /dev/md0 //停止陣列
mdadm: stopped /dev/md0
[root@localhost ~]# mdadm -as /dev/md0 //啟動陣列
mdadm: /dev/md0 has been started with 3 drives.
2 建立lvm
[root@localhost ~]# pvcreate /dev/md0 //建立pv
physical volume 「/dev/md0」 successfully created
[root@localhost ~]# vgcreate lvm1 /dev/md0 //建立vg
volume group 「lvm1」 successfully created
[root@localhost ~]# vgdisplay //檢視vg
[root@localhost ~]# lvcreate -l 500m -n web1 lvm1 //建立lv ,名為web1,大小為500m
logical volume 「web1」 created
[root@localhost ~]# lvcreate -l 500m -n web2 lvm1 //建立lv ,名為web2,大小為500m
logical volume 「web2」 created
[root@localhost ~]# mke2fs -j /dev/lvm1/web1 //格式化web1
[root@localhost ~]# mke2fs -j /dev/lvm1/web2 //格式化web2
檢視/web1的容量
[root@localhost ~]# df -h /web1
[root@localhost ~]# pvdisplay
3模擬故障
[root@localhost ~]# mdadm /dev/md0 -f /dev/sdd1 //標記/dev/sdd1為故障盤
[root@localhost ~]# more /proc/mdstat
personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sde1[2] sdd13 sdc1[0] //[f]表示為故障盤
[root@localhost ~]# mdadm /dev/md0 -r /dev/sdd1 //移除故障盤
mdadm: hot removed /dev/sdd1
[root@localhost ~]# more /proc/mdstat //檢視陣列情況
personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sde1[2] sdbc[0]
[root@localhost ~]# pvdisplay /dev/md0 //檢視pv情況,發現容量沒減少
[root@localhost ~]# fdisk /dev/sdd //重新格式化sdd,重新新增進陣列
command (m for help): n
command action
e extended
p primary partition (1-4)
ppartition number (1-4): 1
partition 1 is already defined. delete it before re-adding it.
command (m for help): t
selected partition 1
hex code (type l to list codes): fd
command (m for help): w
the partition table has been altered!
calling ioctl() to re-read partition table.
syncing disks.
[root@localhost ~]# mdadm /dev/md0 -a /dev/sdd1 //增加
mdadm: re-added /dev/sdd1
[root@localhost ~]# more /proc/mdstat //開始同步資料
[root@localhost ~]# pvdisplay
[root@localhost ~]# vgdisplay lvm1
[root@localhost ~]# df -h /web1
4。增加lvm容量
[root@localhost ~]# lvextend -l +50m /dev/lvm1/web1 //增加web1 50m
rounding up size to full physical extent 52.00 mb
extending logical volume web1 to 552.00 mb
logical volume web1 successfully resized
[root@localhost ~]# resize2fs /dev/lvm1/web1 //重新整理
resize2fs 1.39 (29-may-2006)
filesystem at /dev/lvm1/web1 is mounted on /web1; on-line resizing required
performing an on-line resize of /dev/lvm1/web1 to 565248 (1k) blocks.
the filesystem on /dev/lvm1/web1 is now 565248 blocks long.
Linux 建立RAID裝置 LVM裝置
soft raid fdisk dev sda p n t 6 fd ls dev cat proc mdstat mdadm c dev md0 a yes l 0 n 2 dev sda6 dev sda7 a 當啟用裝置的時候,自動生成檔案 a給已經建立好的riad新增熱佩芬盤 mdadm a...
Linux下配置LVM和RAID例項
在我們舉例的系統上,有四塊大小相等的scsi硬碟 fdisk l 檢視系統硬碟 第一塊scsi硬碟上有我們的系統分割槽。其它3塊都沒有分割槽。首先,我們為每塊csci硬碟建立分割槽 fdisk dev sbd command m for help new command action e exten...
linux建立lvm分割槽
有一塊空白的磁碟需要將它劃分為lvm分割槽,可以用fisk l命令檢視新增的磁碟大小 使用pvcreate dev sdb命令將物理儲存介質 the physical media 這裡指系統的儲存裝置 硬碟,如 dev hda dev sda等等,是儲存系統最低層的儲存單元轉換為物理卷 physic...