計劃使用zabbix監控管理全單位的PC的基本硬件信息,因爲開始的規劃的硬盤比較小,擔憂監控時磁盤不夠。數據庫
在些先考慮能過LVM增容zabbix的數據庫存儲空間。app
System Center 2012–VMM(virtral machine manager)-簡稱爲:VMMdom
1.打開VMM管理臺,找到增容的設備-右鍵屬性-硬件配置-磁盤(增長)自定義須要增長的容量後,點擊:確認ide
2.SSH鏈接Centos虛擬機器,查看新增硬盤設備ui
[root@localhost ~]# dmesg | grep 「sd 1」spa
sd 1:0:0:0: Attached scsi generic sg1 type 0
sd 1:0:0:0: [sdb] 167772160 512-byte logical blocks: (85.8 GB/80.0 GiB)
sd 1:0:0:0: [sdb] Write Protect is off
sd 1:0:0:0: [sdb] Mode Sense: 0f 00 10 00
sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA
sdb: unknown partition table
sd 1:0:0:0: [sdb] Attached SCSI diskcode
已經在線增長硬盤完成。那麼下面開始擴容LVMorm
3.開始建立分區blog
[root@localhost ~]# 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 0x5ebe1b5d.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.ip
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): 1 #主分區爲第一主分區
First cylinder (1-10443, default 1): 1 #磁盤的起始位置
Last cylinder, +cylinders or +size{K,M,G} (1-10443, default 10443): #默認所有都
Using default value 10443
Command (m for help): p #查看建立的分區
Disk /dev/sdb: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 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: 0x5ebe1b5d
Device Boot Start End Blocks Id System
/dev/sdb1 1 10443 83882373+ 83 Linux #須要修改分區類型到LVM
修改分區類型:使用t 選項
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
查看一下分區類型並保存退出。
Command (m for help): p
Disk /dev/sdb: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 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: 0x0d3c2108
Device Boot Start End Blocks Id System
/dev/sdb1 1 10443 83883366 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
建立PV並查看PV,使用命令:pvcreate 與 pvdisplay
[root@localhost ~]# pvcreate /dev/sdb1
dev_is_mpath: failed to get device for 8:17
Physical volume "/dev/sdb1" successfully created
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup
PV Size 19.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4994
Free PE 0
Allocated PE 4994
PV UUID qOY1yW-Ynm7-2d1g-2nMH-G6nN-evtl-Cjp02F
"/dev/sdb1" is a new physical volume of "80.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 80.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID Um4a9O-gFHb-Gg70-2gxB-v50x-mmuZ-XyYymh
擴展新硬盤到VG組中
[root@localhost ~]# vgextend VolGroup /dev/sdb1
Volume group "VolGroup" successfully extended
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 99.50 GiB
PE Size 4.00 MiB
Total PE 25473
Alloc PE / Size 4994 / 19.51 GiB
Free PE / Size 20479 / 80.00 GiB
VG UUID iprcvl-yS2E-Z9t0-diqk-LaNC-rXqX-1Rd9VI
增容到LV中
[root@localhost ~]# lvextend -L +80G /dev/VolGroup/lv_root
Extending logical volume lv_root to 97.57 GiB
Insufficient free space: 20480 extents needed, but only 20479 available #報錯 告訴我可用的容量爲20479
[root@localhost ~]# lvextend -L +79G /dev/VolGroup/lv_root
Extending logical volume lv_root to 96.57 GiB
Logical volume lv_root successfully resized
查看了一下LV容量
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/VolGroup/lv_root
LV Name lv_root
VG Name VolGroup
LV UUID BJWEPf-lBb5-2hqB-om6A-UP31-mPI0-qPRxWZ
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2015-05-29 23:23:23 +0800
LV Status available
# open 1
LV Size 96.57 GiB #成功增容
Current LE 24722
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
更新文件系統
resize2fs -f /dev/VolGroup/lv_root
-f 強制
[root@localhost ~]# resize2fs -f /dev/VolGroup/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 7
Performing an on-line resize of /dev/VolGroup/lv_root to 25315328 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 25315328 blocks long.
df 查看一下增容的文件系統
[root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 96G 8.8G 82G 10% / [root@localhost ~]#