Use lvm to support extended partitions and use lvm to expand partitions
Background:
As a Database Engineer, you must be very cautious about database operation settings. due to negligence, potential risks are immeasurable !!!
The following is a small detail about how to store datadir:
In order to use lvm to support the expansion due to insufficient database space in the future:
Separate mysql database datadir into one partition:
1. Create a separate Partition
Use less than 2 TB: for example, fdisk/dev/sdb
Restart OS
Create:
Pvcreate/dev/sdb1 ---> physical volume
Vgcreate volume group name (obtained by yourself) physical volume name (similar to/dev/sdb1)
Lvcreate-L size-n logical volume name (obtained by yourself) volume group name
Format:
Mkfs. ext4 "LV Path" (lvdisplay can be queried)
Mount the file system:
Mount "LV Path" mount point
Note: add the created File System to/etc/fstab.
2. Create the datadir directory under the above mount point
When datadir times out and the partition space of the mount point in the directory is insufficient, scale up:
1. vgextend volume group name/dev/sdb1
2. lvextend-L + size logical volume name/dev/sdb1 ---> increase logical volume
Or:
Lvextend logical volume name/dev/sdb1
3. e2fsck-f logical volume name ---> check the partition to be adjusted
Resize2fs logical volume name ---> increase the File System
4. mount Points
5. df-h ---> check whether the partition is increased.
To increase the logical volume, first increase the logical volume and then increase the file system with resize2fs.