91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

詳解基于Linux的LVM無縫磁盤水平擴容

發布時間:2020-09-02 09:01:08 來源:腳本之家 閱讀:154 作者:CandyMi 欄目:服務器

環境

名稱 屬性
CPU x5650
內存 4G
磁盤 20G+4TB

詳解基于Linux的LVM無縫磁盤水平擴容 

詳解基于Linux的LVM無縫磁盤水平擴容

這時候,我們假設服務器已經有如下東西:

  • 安裝好了Parted(yum install parted)
  • 分區容量已經告捷,公司為服務器增加了一塊4T硬盤用來增加容量!
  • 除了/boot分區外,其余都為LVM 模式的擴展邏輯分區

軟件安裝與信息查看

首先查看軟件是否安裝:

[root@Candy ~]# rpm -qa | grep lvm
lvm2-libs-2.02.118-2.el6.x86_64
lvm2-2.02.118-2.el6.x86_64
[root@Candy ~]# lv
lvchange   lvextend   lvmdiskscan lvmsar    lvresize
lvconvert  lvm     lvmdump   lvreduce   lvs
lvcreate   lvmchange  lvmetad   lvremove   lvscan
lvdisplay  lvmconf   lvmsadc   lvrename
[root@Candy ~]# rpm -qa | grep parted
parted-2.1-29.el6.x86_64

軟件準備好后順便查看下 VM 硬件:

[root@Candy ~]# df -h
Filesystem      Size Used Avail Use% Mounted on
/dev/mapper/vg_candy-root
           7.3G 231M 6.7G  4% /
tmpfs         1.9G   0 1.9G  0% /dev/shm
/dev/sda1       477M  30M 422M  7% /boot
/dev/mapper/vg_candy-home
           3.9G 8.0M 3.7G  1% /home
/dev/mapper/vg_candy-usr
           3.9G 382M 3.3G 11% /usr
/dev/mapper/vg_candy-var
           3.9G  63M 3.6G  2% /var
[root@Candy ~]# fdisk -l
Disk /dev/sda: 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: 0x0006e71c
  Device Boot   Start     End   Blocks  Id System
/dev/sda1  *      1     64   512000  83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2       64    2611  20458496  8e Linux LVM
Disk /dev/sdb: 4398.0 GB, 4398046511104 bytes
255 heads, 63 sectors/track, 534698 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/mapper/vg_candy-root: 8061 MB, 8061452288 bytes
255 heads, 63 sectors/track, 980 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/mapper/vg_candy-usr: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 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/mapper/vg_candy-var: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 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/mapper/vg_candy-home: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 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
[root@Candy ~]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb

這時候我們看到,Centos 已經知道有個sdb的盤了,但是沒掛載與分區。

使用Parted進行擴容前的分區

現在假設除了/boot 其余分區都滿了! 我們需要先進行分區,將4T的硬盤用上(/dev/sdb).

[root@Candy ~]# parted /dev/sdb
GNU Parted 2.1
使用 /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
新的磁盤標簽類型? gpt
(parted) mkpart
分區名稱? []?
文件系統類型? [ext2]? ext4
起始點? 0T
結束點? 4T
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 4398GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start  End   Size  File system Name 標志
 1   1049kB 4398GB 4398GB
(parted)set 1 lvm on
(parted)p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 4398GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start  End   Size  File system Name 標志
1   1049kB 4398GB 4398GB           lvm
(parted)q
[root@Candy ~]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdb1

現在讓我們來解釋一下操作:

  1. mklabel將磁盤轉換為gpt分區,因為MBR分區無法支持TB級硬盤(具體請自行查閱,parted當然也支持TB級以下的操作)
  2. mkpart將轉換好的gpt磁盤進行分區,需要提供文件系統類型、開始點、結束點。
  3. 輸入p 打印出剛才才做后生成的分區。
  4. set 1 lvm on 是將num為1的分區,tager設置為LVM ,這樣才能添加到vm卷組里

下一步,我們查看我們的LVM組名叫什么:

[root@Candy ~]# vgs
 VG    #PV #LV #SN Attr  VSize VFree
 vg_candy  1  4  0 wz--n- 19.51g  0
 
[root@Candy ~]# vgdisplay
 --- Volume group ---
 VG Name        vg_candy
 System ID
 Format        lvm2
 Metadata Areas    1
 Metadata Sequence No 5
 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        19.51 GiB
 PE Size        4.00 MiB
 Total PE       4994
 Alloc PE / Size    4994 / 19.51 GiB
 Free PE / Size    0 / 0
 VG UUID        Gcm5Ml-fc88-Xk5q-xuPC-Kj7Y-alfK-i770Gc
[root@Candy ~]# lvscan
 ACTIVE      '/dev/vg_candy/usr' [4.00 GiB] inherit
 ACTIVE      '/dev/vg_candy/var' [4.00 GiB] inherit
 ACTIVE      '/dev/vg_candy/home' [4.00 GiB] inherit
 ACTIVE      '/dev/vg_candy/root' [7.51 GiB] inherit
[root@Candy ~]#

知道lvm卷組叫 'vg_candy'了, 我們就使用vgextend來向lvm 'vg_candy' 卷組添加成員了.

[root@Candy ~]# vgextend vag_candy /dev/sdb1
Physical volume "/dev/sdb1" successfully created
Volume group "vg_candy" successfully extended

現在我們再用vgs命令看一下pv個數:

[root@Candy ~]# vgs
VG    #PV #LV #SN Attr  VSize VFree
vg_candy  2  4  0 wz--n- 4.02t 4.00t

大家對比未添加時的vgs是否有看到PV個數從1變為2了!

現在讓我們用vgdisplay看看現在分區的容量.

[root@Candy ~]# vgdisplay
 --- Volume group ---
 VG Name        vg_candy
 System ID
 Format        lvm2
 Metadata Areas    2
 Metadata Sequence No 6
 VG Access       read/write
 VG Status       resizable
 MAX LV        0
 Cur LV        4
 Open LV        4
 Max PV        0
 Cur PV        2
 Act PV        2
 VG Size        4.02 TiB
 PE Size        4.00 MiB
 Total PE       1053569
 Alloc PE / Size    4994 / 19.51 GiB
 Free PE / Size    1048575 / 4.00 TiB
 VG UUID        Gcm5Ml-fc88-Xk5q-xuPC-Kj7Y-alfK-i770Gc

再次對比未添加的vgdiplay命令發現,FreePE 的value 從 0 / 0 變為 1048575 / 4.00 TiB . 這樣說明Candy已經成功將4TB的lvm 分區添加進入到vg_candy 邏輯卷組里了。

現在我們對所有邏輯分區進行擴容前,df -h 看看有哪些分區。

[root@Candy ~]# df -h
Filesystem         Size Used Avail Use% Mounted on
/dev/mapper/vg_candy-root 7.3G 231M 6.7G  4% /
 tmpfs           1.9G   0 1.9G  0% /dev/shm
/dev/sda1         477M  30M 422M  7% /boot
/dev/mapper/vg_candy-home 3.9G 8.0M 3.7G  1% /home         
/dev/mapper/vg_candy-usr  3.9G 382M 3.3G 11% /usr
/dev/mapper/vg_candy-var  3.9G  63M 3.6G  2% /var

現在麻煩的事已經做完了,接下來就剩下為分區進行擴容了.

為磁盤進行擴容

假設:我們需要向 這些分區都添加500G容量: //home/usr/var

[root@Candy ~]# lvextend -L +500G /dev/mapper/vg_candy-root
 Size of logical volume vg_candy/root changed from 7.51 GiB (1922 extents) to 507.51 GiB (129922 extents).
 Logical volume root successfully resized
 
[root@Candy ~]# lvextend -L +500G /dev/mapper/vg_candy-home
 Size of logical volume vg_candy/home changed from 4.00 GiB (1024 extents) to 504.00 GiB (129024 extents).
 Logical volume home successfully resized
 
[root@Candy ~]# lvextend -L +500G /dev/mapper/vg_candy-usr
 Size of logical volume vg_candy/usr changed from 4.00 GiB (1024 extents) to 504.00 GiB (129024 extents).
 Logical volume usr successfully resized
 
[root@Candy ~]# lvextend -L +500G /dev/mapper/vg_candy-var
 Size of logical volume vg_candy/var changed from 4.00 GiB (1024 extents) to 504.00 GiB (129024 extents).
 Logical volume var successfully resized

大家注意,這一步操作時不可逆的! 如果輸入了錯誤的分區名字還好! 如果添加到其它分區了,就得重復N遍來縮容,比較麻煩哦! 建議大家注仔細核對上面的FileSystem. 切記切記....

提示擴容成功! 讓我們再次用上述命令查看LVM信息:

[root@Candy ~]# vgs
 VG    #PV #LV #SN Attr  VSize VFree
 vg_candy  2  4  0 wz--n- 4.02t 2.05t 
 
[root@Candy ~]# lvscan
 ACTIVE      '/dev/vg_candy/usr' [504.00 GiB] inherit
 ACTIVE      '/dev/vg_candy/var' [504.00 GiB] inherit
 ACTIVE      '/dev/vg_candy/home' [504.00 GiB] inherit
 ACTIVE      '/dev/vg_candy/root' [507.51 GiB] inherit
 
[root@Candy ~]# vgdisplay
 --- Volume group ---
 VG Name        vg_candy
 System ID
 Format        lvm2
 Metadata Areas    2
 Metadata Sequence No 10
 VG Access       read/write
 VG Status       resizable
 MAX LV        0
 Cur LV        4
 Open LV        4
 Max PV        0
 Cur PV        2
 Act PV        2
 VG Size        4.02 TiB
 PE Size        4.00 MiB
 Total PE       1053569
 Alloc PE / Size    516994 / 1.97 TiB
 Free PE / Size    536575 / 2.05 TiB
 VG UUID        Gcm5Ml-fc88-Xk5q-xuPC-Kj7Y-alfK-i770Gc
 
[root@Candy ~]# df -h
Filesystem         Size Used Avail Use% Mounted on
/dev/mapper/vg_candy-root 7.3G 231M 6.7G  4% /
 tmpfs           1.9G   0 1.9G  0% /dev/shm
/dev/sda1         477M  30M 422M  7% /boot
/dev/mapper/vg_candy-home 3.9G 8.0M 3.7G  1% /home         
/dev/mapper/vg_candy-usr  3.9G 382M 3.3G 11% /usr
/dev/mapper/vg_candy-var  3.9G  63M 3.6G  2% /var

看到這里大家可能奇怪! 為什么df -h 還沒變呢?

刷新磁盤信息與寫入

我們需要用resize2fs 重設分區大小, 這樣才能使df -h 也能生效.

而resize2fs 需要的時間與你給予的容量線性疊加. 也就是說你給的容量越多,resize2fs 的需要的時間就越多。

[root@Candy ~]# resize2fs /dev//mapper/vg_candy-root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev//mapper/vg_candy-root is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 32
Performing an on-line resize of /dev//mapper/vg_candy-root to 133040128 (4k) blocks.
The filesystem on /dev//mapper/vg_candy-root is now 133040128 blocks long.

[root@Candy ~]# resize2fs /dev//mapper/vg_candy-usr
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev//mapper/vg_candy-usr is mounted on /usr; on-line resizing required old desc_blocks = 1, new_desc_blocks = 32
Performing an on-line resize of /dev//mapper/vg_candy-usr to 132120576 (4k) blocks.
The filesystem on /dev//mapper/vg_candy-usr is now 132120576 blocks long.

[root@Candy ~]# resize2fs /dev//mapper/vg_candy-var
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev//mapper/vg_candy-var is mounted on /var; on-line resizing required old desc_blocks = 1, new_desc_blocks = 32
Performing an on-line resize of /dev//mapper/vg_candy-var to 132120576 (4k) blocks.
The filesystem on /dev//mapper/vg_candy-var is now 132120576 blocks long.

[root@Candy ~]# resize2fs /dev//mapper/vg_candy-home
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev//mapper/vg_candy-home is mounted on /home; on-line resizing required old desc_blocks = 1, new_desc_blocks = 32
Performing an on-line resize of /dev//mapper/vg_candy-home to 132120576 (4k) blocks.
The filesystem on /dev//mapper/vg_candy-home is now 132120576 blocks long.

[root@Candy ~]# df -h
Filesystem          Size Used Avail Use% Mounted on
/dev/mapper/vg_candy-root   500G 245M 474G  1% /
tmpfs             1.9G   0 1.9G  0% /dev/shm
/dev/sda1           477M  30M 422M  7% /boot
/dev/mapper/vg_candy-home   496G  16M 471G  1% /home
/dev/mapper/vg_candy-usr   496G 390M 471G  1% /usr
/dev/mapper/vg_candy-var   496G  71M 471G  1% /var

結束語

順便給大家曬一張重啟后系統自動掛載的圖!

詳解基于Linux的LVM無縫磁盤水平擴容

詳解基于Linux的LVM無縫磁盤水平擴容

Linux系統還是比較聰明的. 其實重啟與不重啟都能使用, 只是為大家演示重啟后的效果.

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持億速云。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

隆安县| 云阳县| 芦山县| 环江| 荣昌县| 田阳县| 丹阳市| 岳普湖县| 来宾市| 东丽区| 西充县| 锡林浩特市| 大城县| 三亚市| 永新县| 万宁市| 永仁县| 武川县| 大同县| 呼玛县| 莲花县| 屯昌县| 姚安县| 康乐县| 宜兰县| 陇南市| 大方县| 临沂市| 嘉兴市| 东丽区| 景泰县| 蓬安县| 隆安县| 江源县| 莎车县| 康定县| 衡山县| 航空| 娄底市| 涞源县| 易门县|