在安裝centos的時候因爲對分區不熟悉,選擇了默認分區,致使在安裝mysql的時候,沒有一個單獨的分區來存放data。只能研究下如何調整lvm卷的大小了。。php
用vgdisplay指令查看vg卷的大小node
[root@localhost caoyong]# vgdisplay --- Volume group --- VG Name vg_centoscy System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 8 VG Access read/write VG Status resizable MAX LV 0 Cur LV 4 Open LV 4 Max PV 0 Cur PV 1 Act PV 1 VG Size 465.27 GiB PE Size 4.00 MiB Total PE 119109 Alloc PE / Size 119109 / 465.27 GiB Free PE / Size 0 / 0 VG UUID LKnVzD-DeMj-Fonv-zR9Z-vCHs-1TMl-2ELianVG Name 卷組名稱
Free PE / Size 卷組剩餘空間mysql
vg_centoscy卷組中已經沒有剩餘空間讓我分割給其餘lvm,所以咱們要從其餘lvm中分割一部分空間出來linux
使用lvdisplay指令查看vg_centoscy到lvm分配狀況sql
[root@localhost caoyong]# lvdisplay vg_centoscy --- Logical volume --- LV Path /dev/vg_centoscy/lv_root LV Name lv_root VG Name vg_centoscy LV UUID 4rlwmS-6ZZT-nGFE-aKgl-KZaW-FlUn-fMA9of LV Write Access read/write LV Creation host, time centos-cy, 2010-01-04 10:42:37 +0800 LV Status available # open 1 LV Size 50.00 GiB Current LE 12800 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Path /dev/vg_centoscy/lv_home LV Name lv_home VG Name vg_centoscy LV UUID IknYf3-lhXg-3qAU-kEum-Nhyj-2kiZ-SBdmHg LV Write Access read/write LV Creation host, time centos-cy, 2010-01-04 10:42:47 +0800 LV Status available # open 1 LV Size 400.00 GiB Current LE 102400 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:2 --- Logical volume --- LV Path /dev/vg_centoscy/lv_swap LV Name lv_swap VG Name vg_centoscy LV UUID 8pOAL1-o0kr-0glK-jJve-G6Oo-8mZM-DHxgPE LV Write Access read/write LV Creation host, time centos-cy, 2010-01-04 10:44:04 +0800 LV Status available # open 1 LV Size 3.72 GiB Current LE 952 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 --- Logical volume --- LV Path /dev/vg_centoscy/data LV Name data VG Name vg_centoscy LV UUID p0X3ih-jDiQ-GN3B-R9Zd-U8qI-loSF-Sql6sc LV Write Access read/write LV Creation host, time localhost.localdomain, 2012-12-28 13:07:42 +0800 LV Status available # open 1 LV Size 11.55 GiB Current LE 2957 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:3
lvm的空間調整指令是apache
lvextend 增長lvm空間centos
lvreduce 減小lvm空間dom
這裏使用-L 參數指定須要調整到大小ide
例如lvextend -L 450G /dev/vg_centoscy/lv_home 表示將lv_home卷的大小調整到450G,前提是vg中有足夠的空間。注意,lvextend指令所指定到大小必須大於須要調整到lvm的大小spa
-L指令也能夠用 + 來調整大小 表示當前空間須要增長到大小 好比 -L +50G 表示lv_home卷的空間調整爲400G+50G
lvreduce指令跟lvextend指令徹底相反,這裏就不仔細說明了
[root@localhost caoyong]# lvreduce -L -10G -f /dev/vg_centoscy/lv_home WARNING: Reducing active and open logical volume to 390.00 GiB THIS MAY DESTROY YOUR DATA (filesystem etc.) Reducing logical volume lv_home to 390.00 GiB Logical volume lv_home successfully resized
接下來建立新的lvm
lvmcreate -L 10G -n mylvm /dev/vg_centoscy
[root@localhost caoyong]# lvcreate -L 10G -n mylvm /dev/vg_centoscy Logical volume "mylvm" created在vg_centoscy卷組中建立mylvm卷,咱們使用lvdisplay指令查看,mylvm卷已經建立完成,接下來要將lvm掛載到linux的 / 中
建立/mylvm 分區
[root@localhost caoyong]# mkdir /mylvm
格式化mylvm卷
[root@localhost caoyong]# mke2fs -j -t ext4 /dev/vg_centoscy/mylvm mke2fs 1.41.12 (17-May-2010) 文件系統標籤= 操做系統:Linux 塊大小=4096 (log=2) 分塊大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 655360 inodes, 2621440 blocks 131072 blocks (5.00%) reserved for the super user 第一個數據塊=0 Maximum filesystem blocks=2684354560 80 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 正在寫入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 35 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost caoyong]# mount -t ext4 /dev/vg_centoscy/mylvm /mylvm到這裏,lvm卷的分割,建立和掛載完成。
上述mylvm卷是在寫博文時查看指令和運行結果所臨時分割的空間,data卷是以前操做中分割給mysql做爲數據儲存用的空間。本人初學linux,有什麼遺漏到地方但願有人指正