您现在的位置是:首页> 操作系统> Linux
LVM实战案例之pv,vg,lv创建到挂载
- 5794人已阅读
- 时间:2018-10-20 15:13:56
- 分类:Linux
一、LVM中PV创建,VG创建,LV创建,LV格式化,LV挂载实例
实战测试环境如下:
[root@db01 /]# fdisk -l |grep "Disk /dev/sd" ###查看当前所加载磁盘 Disk /dev/sda: 53.7 GB, 53687091200 bytes Disk /dev/sdb: 107.4 GB, 107374182400 bytes Disk /dev/sdc: 107.4 GB, 107374182400 bytes Disk /dev/sdd: 1073 MB, 1073741824 bytes Disk /dev/sde: 2147 MB, 2147483648 bytes Disk /dev/sdf: 2147 MB, 2147483648 bytes Disk /dev/sdg: 2147 MB, 2147483648 bytes Disk /dev/sdh: 2147 MB, 2147483648 bytes
【实战内容】
根据以上测试环境,先使用dev/sde dev/sdf dev/sdg 演示LVM的创建,再使用/dev/sdh进行扩容
操作步骤
1.先使用dev/sde /dev/sdf /dev/sdg创建pv
2.根据创建的pv创建vg
3.从刚创建的vg中划出lv
【实战开始】
(1)创建PV,包含/dev/sde /dev/sdf /dev/sdg
[root@db01 /]# pvcreate /dev/sde /dev/sdf /dev/sdg Physical volume "/dev/sde" successfully created Physical volume "/dev/sdf" successfully created Physical volume "/dev/sdg" successfully created [root@db01 /]# pvs ###查看pv的信息 PV VG Fmt Attr PSize PFree /dev/sde lvm2 a-- 2.00g 2.00g /dev/sdf lvm2 a-- 2.00g 2.00g /dev/sdg lvm2 a-- 2.00g 2.00g [root@db01 /]# [root@db01 /]# pvdisplay ###查看pv相关属性 "/dev/sde" is a new physical volume of "2.00 GiB" ###物理卷 /dev/sde的信息 --- NEW Physical volume --- PV Name /dev/sde ##物理卷名称 VG Name ##卷组名称 PV Size 2.00 GiB ###物理卷 /dev/sde 大小 Allocatable NO ###分配情况,NO:未分配 Yes:已分配 PE Size 0 ###PE 物理扩展大小,为0 表示还未创建vg Total PE 0 ###总PE数量 Free PE 0 ###空闲PE数量 Allocated PE 0 ###分配PE数量 PV UUID ycc95W-fTpg-toEV-DqPI-4qun-FcDr-tukLcL ###PV的标识 "/dev/sdf" is a new physical volume of "2.00 GiB" --- NEW Physical volume --- PV Name /dev/sdf VG Name PV Size 2.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID VfAa2h-Ubkp-7S1F-927g-buPO-UPXY-9eRHMu "/dev/sdg" is a new physical volume of "2.00 GiB" --- NEW Physical volume --- PV Name /dev/sdg VG Name PV Size 2.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID Cc2Zm7-iSUO-P7T1-5vtm-rGRO-TdPB-huDMLm
(2)根据PV创建VG,VG的命名为oraclevg
[root@db01 /]# vgcreate oraclevg /dev/sde /dev/sdf /dev/sdg Volume group "oraclevg" successfully created [root@db01 /]# [root@db01 /]# vgs ###查看vg的信息 VG #PV #LV #SN Attr VSize VFree oraclevg 3 0 0 wz--n- 5.99g 5.99g [root@db01 /]# [root@db01 /]# vgdisplay ###查看vg相关属性 --- Volume group --- VG Name oraclevg ###vg 名称 System ID Format lvm2 ###vg 格式 Metadata Areas 3 ### 组成vg的pv数 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 ###创建的LV数量 Open LV 0 Max PV 0 Cur PV 3 ### 组成vg的pv数 Act PV 3 VG Size 5.99 GiB ###vg 的容量大小 PE Size 4.00 MiB ### PE大小 Total PE 1533 ###总PE数量 Alloc PE / Size 0 / 0 ###已分配PE数量 Free PE / Size 1533 / 5.99 GiB ###空闲PE数量 VG UUID izNwjZ-XBiO-UVVl-y3H6-kvM4-gFUy-CXiaD1 ###vg标识符
(3)在oraclevg上创建LV用到的命令
lvcreate [选项] [参数]
选项:L:指定逻辑卷的大小,单位“kKmMgGtT"
l:指定逻辑卷的大小,单位”LE数“
实战在oraclevg上创建LV名为lvoracle大小为2G
[root@db01 /]# lvcreate -n lvoracle -L 2G oraclevg Logical volume "lvoracle" created [root@db01 /]# lvdisplay --- Logical volume --- LV Path /dev/oraclevg/lvoracle LV Name lvoracle VG Name oraclevg LV UUID Npy07F-TV79-hMIE-fn7j-zboc-u63a-08iRah LV Write Access read/write LV Creation host, time db01, 2017-11-21 12:32:31 +0800 LV Status available # open 0 LV Size 2.00 GiB Current LE 512 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
(4)对lvoracle进行格式化
[root@db01 /]# mkfs.ext4 /dev/oraclevg/lvoracle mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131072 inodes, 524288 blocks 26214 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=536870912 16 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 26 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
(5)将lvoracle挂载到/ora01
[root@db01 /]# mkdir /ora01 [root@db01 /]# mount /dev/oraclevg/lvoracle /ora01/ [root@db01 /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 45G 4.4G 39G 11% / tmpfs 1004M 0 1004M 0% /dev/shm /dev/sda1 485M 39M 421M 9% /boot /dev/sdb2 79G 184M 75G 1% /oracle /dev/sdb1 20G 172M 19G 1% /soft /dev/sdd1 1007M 18M 939M 2% /alexpeng /dev/mapper/oraclevg-lvoracle 2.0G 67M 1.9G 4% /ora01 [root@db01 /]#
(6)设置开机启动
[root@db01 /]# vi /etc/fstab UUID=3e8b0960-23d2-48f3-8661-3f24ce85e9e6 / ext4 defaults 1 1 ..... sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /dev/sdd1 /alexpeng ext4 defaults 0 0 /dev/oraclevg/lvoracle /ora01 ext4 defaults 0 0
下节祥哥讲LVM扩容,这节就不写了。想看的在博客中搜索吧。
下一篇:LVM实战案例之LVM扩容
相关文章
- linux的PV,VG,LV关系和操作详解
- linux磁盘分区与LVM详解
- LVM实战案例之LVM扩容
- LVM实战案例之LVM空间缩减(本次对PV,VG,LV等进行空间缩减)
- LVM实战案例之LVM删除
- LVM灾难修复坏一个硬盘怎么办
- MySql常用命令语法总结
- PHP获取操作系统函数
- apache的Rewrite详解
- linux修改用户密码命令
- linux查看与修改主机名
- linux修改SSH默认的端口号22
- 解决ssh登录后闲置时间过长而断开连接
- LINUX查看端口使用情况
- linux下查看CPU信息
- CMD常用命令总结
- LINUX系统如何区别是VPS还是独立的服务器
- linux设置IP地址
- vsftpd的配置文件详解
- linux中nmcli命令使用及网络配置包含无线
- sublime text3之Emmet插件快捷键助快速编程
- DVI-I和DVI-D区别与详解
- linux下fdisk命令实战案例之详解
- linux下parted命令实战分区
- apache配置SSL证书超详细教程
- CentOS7 systemctl配置文件详解