In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Environment
Name property CPUx5650 memory 4G disk 20G+4TB
At this point, we assume that the server already has the following:
The installation of Parted (yum install parted) partition capacity has been successful, the company added a 4T hard drive for the server to increase capacity! Except for the / boot partition, the rest are extended logical partitions in LVM mode
Software installation and information viewing
First check to see if the software is installed:
[root@Candy ~] # rpm-qa | grep lvmlvm2-libs-2.02.118-2.el6.x86_64lvm2-2.02.118-2.el6.x86_64 [root@Candy ~] # lvlvchange lvextend lvmdiskscan lvmsar lvresizelvconvert lvm lvmdump lvreduce lvslvcreate lvmchange lvmetad lvremove lvscanlvdisplay lvmconf lvmsadc lvrename [root@Candy ~] # rpm-qa | grep partedparted-2.1-29.el6.x86_64
When the software is ready, take a look at the VM hardware:
[root@Candy ~] # df-hFilesystem 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-lDisk / dev/sda: 21.5G2G 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0006e71c Device Boot Start End Blocks Id System/dev/sda1 * 1 64 512000 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 64 2611 20458496 8e Linux LVMDisk / dev/sdb: 4398.0 GB, 4398046511104 bytes255 heads, 63 sectors/track 534698 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk / dev/mapper/vg_candy-root: 8061 MB, 8061452288 bytes255 heads, 63 sectors/track, 980 cylindersUnits = cylinders of 16065 * 512 = 8225 280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk / dev/mapper/vg_candy-usr: 4294 MB, 4294967296 bytes255 heads, 63 sectors/track 522 cylindersUnits = cylinders of 16065 * 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk / dev/mapper/vg_candy-var: 4294 MB, 4294967296 bytes255 heads, 63 sectors/track, 522 cylindersUnits = cylinders of 16065 * 512 = 8225 280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk / dev/mapper/vg_candy-home: 4294 MB, 4294967296 bytes255 heads, 63 sectors/track CylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000 [root@Candy] # ls / dev/sd*/dev/sda / dev/sda1 / dev/sda2 / dev/sdb
At this time, we can see that Centos already knows that there is a sdb disk, but it is not mounted and partitioned.
Partition before capacity expansion using Parted
Now suppose all the partitions except / boot are full! We need to partition first and use the 4T hard drive (/ dev/sdb).
[root@Candy] # parted / dev/sdbGNU Parted 2.1Use / dev/sdbWelcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel new disk label type? Gpt (parted) mkpart partition name? []? File system type? [ext2]? Ext4 starting point? 0T end point? 4T (parted) pModel: VMware, VMware Virtual S (scsi) Disk / dev/sdb: 4398GBSector size (logical/physical): 512B/512BPartition Table: gptNumber Start End Size File system Name Mark 1 1049kB 4398GB 4398GB (parted) set 1 lvm on (parted) pModel: VMware VMware Virtual S (scsi) Disk / dev/sdb: 4398GBSector size (logical/physical): 512B/512BPartition Table: gptNumber Start End Size File system Name Mark 1 1049kB 4398GB 4398GB lvm (parted) Q [root@Candy ~] # ls / dev/sd*/dev/sda / dev/sda1 / dev/sda2 / dev/sdb / dev/sdb1
Now let's explain the operation:
Mklabel converts the disk to gpt partition, because MBR partition cannot support TB-level hard disk (for details, parted also supports operations below TB level) mkpart partitions the converted gpt disk and needs to provide the file system type, start point, and end point. Type p to print out the partition generated after you just did it. Set 1 lvm on is a partition with a num of 1, and tager is set to LVM so that it can be added to the vm volume group
Next, let's look at the name of our LVM group:
[root@Candy ~] # vgs VG # PV # LV # SN Attr VSize VFree vg_candy 1 40 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 ~] #
Knowing that the lvm volume group is called 'vg_candy', we use vgextend to add members to the lvm' vg_candy' volume group.
[root@Candy ~] # vgextend vag_candy / dev/sdb1Physical volume "/ dev/sdb1" successfully createdVolume group "vg_candy" successfully extended
Now let's take a look at the number of pv with the vgs command:
[root@Candy ~] # vgsVG # PV # LV # SN Attr VSize VFreevg_candy 2 40 wz--n- 4.02t 4.00t
Compare the unadded vgs to see whether the number of PV has changed from 1 to 2!
Now let's use vgdisplay to see the capacity of the current partition.
[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
Once again, compared with the unadded vgdiplay command, it is found that the value of FreePE has changed from 0 / 0 to 1048575 / 4.00 TiB. This indicates that Candy has successfully added the lvm partition of 4TB to the vg_candy logical volume group.
Now before we expand all logical partitions, df-h to see which partitions are available.
[root@Candy ~] # df-hFilesystem 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
Now that the trouble is done, all that is left is to expand the partition.
Expand the capacity of the disk
Suppose: we need to add 500G capacity to these partitions: /, / home, / usr, / var
[root@Candy] # lvextend-L + 500G / dev/mapper/vg_candy-root Size of logical volume vg_candy/root changed from 7.51GiB (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
Attention, this step is irreversible! It's okay if you enter the wrong partition name! If you add it to other partitions, you have to repeat N times to scale down, which is more troublesome. It is recommended that you carefully check the above FileSystem. Remember to remember.
It is suggested that the expansion is successful! Let's view the LVM information again with the above command:
[root@Candy ~] # vgs VG # PV # LV # SN Attr VSize VFree vg_candy 2 40 wz--n- 4.02t [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-hFilesystem 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
Everyone may be surprised to see here! Why hasn't df-h changed?
Refresh disk information and write
We need to resize the partition with resize2fs for df-h to work.
The time required by resize2fs is linearly superimposed with the capacity you give. In other words, the more capacity you give, the more time it takes for resize2fs.
[root@Candy ~] # resize2fs / dev//mapper/vg_candy-rootresize2fs 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 = 32Performing 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-usrresize2fs 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 = 32Performing 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-varresize2fs 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 = 32Performing 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-homeresize2fs 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 = 32Performing 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-hFilesystem 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
Concluding remarks
By the way, I will show you a picture of automatic mounting of the system after reboot!
The Linux system is still relatively clever. In fact, restart and not restart can be used, just to demonstrate the effect of restart.
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.