当前位置:网站首页>Distributed database uses logical volume to manage storage expansion
Distributed database uses logical volume to manage storage expansion
2022-06-21 22:40:00 【Inspur Yunxi database】
Inspur Yunxi database is a domestic distributed database independently developed by Inspur , One feature is the ability to support PB Level data services . At the storage level , Yunxi database can not only use physical disks , You can also use logical volumes to manage storage . Using logical volumes , There are two main scenarios :
(1) When large capacity disks are used in business , When a single physical disk cannot meet the requirements . for example : We need to be in /data Mount 30TB The storage , A single disk does not have this large capacity . If you use logical volumes , Combine multiple small capacity disks into a volume group , Aggregate into one large logical disk , That is to meet the demand .
(2) When the amount of data is uncertain , When you need to expand the disk later . When planning disks early in the business , You don't know exactly how much disk space you need to allocate . If using physical volumes , Later, it cannot be expanded . If you use logical volumes , According to the later demand , Expand and shrink manually .
- Basic concepts -
Logical volumes are managed using logical volume groups (Logic Volume Manager) Created devices , If you want to understand logical volumes , First of all, we need to understand some concepts in logical volume management .
1. Logical volume manager (Logical Volume Manager,LVM):LVM To logically assemble the partitions of one or more hard disks , It's equivalent to a big hard disk to use , When the hard disk is out of space , You can continue to add other hard disk partitions to it , In this way, the dynamic management of disk space can be realized , Compared with ordinary disk partition, it has great flexibility .LVM The system administrator can allocate storage space for applications and users more conveniently .
2. Physical volume (Physical Volume,PV): Refers to a hard disk partition or a device that logically has the same function as a disk partition ( Such as RAID), yes LVM Block of basic storage logic .
3. The volume group (Volume Group,VG):PV Set . Is a storage pool composed of one or more physical volumes , One or more logical volumes can be created on a volume group .
4. Logic volume (Logic Volume,LV):VG A logical disk drawn in . It's similar to not LVM Hard disk partition in the system , It is based on volume groups , Is a standard block device , File systems can be built on top of logical volumes .
Convert a physical disk or disk partition to a physical volume , One or more physical volumes are aggregated to form one or more volume groups , A logical volume is a piece of disk space abstracted from a volume group . The specific structure is as follows :

- establish LVM -
1. First, through fdisk -l or lsblk View the properties of the disk , Find the name of the disk you want to add .
vdc Is a disk manually attached to the virtual machine , Execute the order as follows :
[email protected]:~# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTvda 252:0 0 40G 0 disk|-vda1 252:1 0 571M 0 part /boot`-vda2 252:2 0 39.5G 0 part /vdb 252:16 0 64M 0 disk[email protected]:~# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTvda 252:0 0 40G 0 disk|-vda1 252:1 0 571M 0 part /boot`-vda2 252:2 0 39.5G 0 part /vdb 252:16 0 64M 0 diskvdc 252:32 0 10G 0 disk[email protected]:~# fdisk -lDisk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x9b600047Device Boot Start End Sectors Size Id Type/dev/vda1 * 2048 1171455 1169408 571M 83 Linux/dev/vda2 1171456 83886046 82714591 39.5G 83 LinuxDisk /dev/vdb: 64 MiB, 67108864 bytes, 131072 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x00000000Disk /dev/vdc: 10 GiB, 10737418240 bytes, 20971520 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes
2. Use fdisk Partition the disk logically
fdisk /dev/vdc
m To see command help ;
n Add a new partition, Partition , And the size of the partition , Default values are used here , Create a partition ;
w Command save and exit .
[email protected]:~# fdisk /dev/vdcWelcome to fdisk (util-linux 2.31.1).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Device does not contain a recognized partition table.Created a new DOS disklabel with disk identifier 0xbb7719f5.Command (m for help): nPartition typep primary (0 primary, 0 extended, 4 free)e extended (container for logical partitions)Select (default p):Using default response p.Partition number (1-4, default 1):First sector (2048-20971519, default 2048):Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519):Created a new partition 1 of type 'Linux' and of size 10 GiB.Command (m for help): wThe partition table has been altered.Calling ioctl() to re-read partition table.Syncing disks.[email protected]:~# fdisk -l......Device Boot Start End Sectors Size Id Type/dev/vdc1 2048 20971519 20969472 10G 83 Linux
3. Use lvm To manage this partition
1). Installation is required first lvm
apt-get install lvm2
2). establish Physical Volume(PV)
pvcreate /dev/vdc1
After success, you can pass pvdisplay Check the information
[email protected]:~# pvcreate /dev/vdc1Physical volume "/dev/vdc1" successfully created.[email protected]:~# pvdisplay"/dev/vdc1" is a new physical volume of "<10.00 GiB"--- NEW Physical volume ---PV Name /dev/vdc1VG NamePV Size <10.00 GiBAllocatable NOPE Size 0Total PE 0Free PE 0Allocated PE 0PV UUID 5FxevL-aneV-Xhe6-pFEv-b3pH-l4v4-Gb6TeA
3). establish Volume Group (VG).
vgcreate vg-newsql /dev/vdc1
[email protected]:~# vgcreate vg-newsql /dev/vdc1Volume group "vg-newsql" successfully created[email protected]:~# vgscanReading volume groups from cache.Found volume group "vg-newsql" using metadata type lvm2
4). establish Logical Volumes (LV).
lvcreate -n lv-newsql -l 100%VG vg-newsql( Will all vg-newsql All the memory for this lv-newsql Logic volume )
[email protected]:~# lvcreate -n lv-newsql -l 100%VG vg-newsqlLogical volume "lv-newsql" created.[email protected]:~# lvdisplay--- Logical volume ---LV Path /dev/vg-newsql/lv-newsqlLV Name lv-newsqlVG Name vg-newsqlLV UUID bMsyAX-xatH-cdTY-JbzE-4ao5-QR6h-j4Z7ONLV Write Access read/writeLV Creation host, time newsqltest, 2021-01-27 16:09:54 +0800LV Status available# open 0LV Size <10.00 GiBCurrent LE 2559Segments 1Allocation inheritRead ahead sectors auto- currently set to 256Block device 253:0
4. Format and mount logical volumes to /data
1). The first step is to format the logical volume
mkfs.ext4 /dev/vg-newsql/lv-newsql
2). Mount the logical volume to home Under the folder
mount /dev/vg-newsql/lv-newsql /data
[email protected]:~# mkfs.ext4 /dev/vg-newsql/lv-newsqlmke2fs 1.44.1 (24-Mar-2018)Creating filesystem with 2620416 4k blocks and 655360 inodesFilesystem UUID: a667f950-9b91-45ce-9931-8fb147173054Superblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632Allocating group tables: doneWriting inode tables: doneCreating journal (16384 blocks): doneWriting superblocks and filesystem accounting information: done[email protected]:~# mount /dev/vg-newsql/lv-newsql /datamount: /data: mount point does not exist.[email protected]:~# mkdir /data[email protected]:~# mount /dev/vg-newsql/lv-newsql /data[email protected]:~# df -hFilesystem Size Used Avail Use% Mounted onudev 3.9G 0 3.9G 0% /devtmpfs 798M 3.2M 795M 1% /run/dev/vda2 39G 2.8G 35G 8% /tmpfs 3.9G 0 3.9G 0% /dev/shmtmpfs 5.0M 0 5.0M 0% /run/locktmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup/dev/vda1 547M 77M 430M 16% /boottmpfs 798M 0 798M 0% /run/user/0/dev/mapper/vg--newsql-lv--newsql 9.8G 37M 9.3G 1% /data
thus ,10G The disk of is mounted to by volume group /data Catalog .
- Capacity expansion -
1. Add disks :
[email protected]:~# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTvda 252:0 0 40G 0 disk|-vda1 252:1 0 571M 0 part /boot`-vda2 252:2 0 39.5G 0 part /vdb 252:16 0 64M 0 diskvdc 252:32 0 10G 0 disk`-vdc1 252:33 0 10G 0 part`-vg--newsql-lv--newsql 253:0 0 10G 0 lvm /datavdd 252:48 0 10G 0 disk
2. Format disk
1). When the disk size is less than 2TB When , And create LVM Of the 2 The steps are the same :
fdisk /dev/vdd
m To see command help
n Add a new partition, Partition , And the size of the partition , I use the default values here , Create a partition
w Command save and exit
2) When more than 2TB When , Use the following command :
a. edit /dev/sda disk
parted /dev/vde
b. Set the partition type
mklabel gpt
c. Set the default unit to TB、GB
unit TB
d. Create partition size
mkpart primary 0 0 or mkpart primary 0.00TB 2.10TB
e. quit
f. Format disk
mkfs.ext4 /dev/vde
[email protected]:~# parted /dev/vdeGNU Parted 3.2Using /dev/vdeWelcome to GNU Parted! Type 'help' to view a list of commands.(parted) helpalign-check TYPE N check partition N for TYPE(min|opt) alignmenthelp [COMMAND] print general help, or help on COMMANDmklabel,mktable LABEL-TYPE create a new disklabel (partition table)mkpart PART-TYPE [FS-TYPE] START END make a partitionname NUMBER NAME name partition NUMBER as NAMEprint [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partitionquit exit programrescue START END rescue a lost partition near START and ENDresizepart NUMBER END resize partition NUMBERrm NUMBER delete partition NUMBERselect DEVICE choose the device to editdisk_set FLAG STATE change the FLAG on selected devicedisk_toggle [FLAG] toggle the state of FLAG on selected deviceset NUMBER FLAG STATE change the FLAG on partition NUMBERtoggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBERunit UNIT set the default unit to UNITversion display the version number and copyright information of GNU Parted(parted) mklabel gpt(parted) unit TB(parted) mkpart primary 0 0 or mkpart primary 0.00TB 2.10TBalign-check TYPE N check partition N for TYPE(min|opt) alignmenthelp [COMMAND] print general help, or help on COMMANDmklabel,mktable LABEL-TYPE create a new disklabel (partition table)mkpart PART-TYPE [FS-TYPE] START END make a partitionname NUMBER NAME name partition NUMBER as NAMEprint [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partitionquit exit programrescue START END rescue a lost partition near START and ENDresizepart NUMBER END resize partition NUMBERrm NUMBER delete partition NUMBERselect DEVICE choose the device to editdisk_set FLAG STATE change the FLAG on selected devicedisk_toggle [FLAG] toggle the state of FLAG on selected deviceset NUMBER FLAG STATE change the FLAG on partition NUMBERtoggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBERunit UNIT set the default unit to UNITversion display the version number and copyright information of GNU PartedWarning: You requested a partition from 0.00TB to 2.10TB (sectors 0..4101562500).The closest location we can manage is 0.00TB to 0.00TB (sectors 34..2047).Is this still acceptable to you?Yes/No? yesWarning: The resulting partition is not properly aligned for best performance.Ignore/Cancel? ignore(parted) quitInformation: You may need to update /etc/fstab.
[email protected]:~# mkfs.ext4 /dev/vdemke2fs 1.44.1 (24-Mar-2018)Found a gpt partition table in /dev/vdeProceed anyway? (y,N) yCreating filesystem with 550502400 4k blocks and 137625600 inodesFilesystem UUID: a08b03f2-05b7-4029-b317-0e07f93fb6d2Superblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,102400000, 214990848, 512000000Allocating group tables: doneWriting inode tables: doneCreating journal (262144 blocks): doneWriting superblocks and filesystem accounting information: done
3. establish pv volume , And use lvm To manage the creation of Physical Volume The steps are the same :
pvcreate /dev/vdd1
4. Expand the physical hard disk to the same volume group , Each group manages different physical disks :
vgextend vg-newsql /dev/vdd1
[email protected]:~# vgextend vg-newsql /dev/vdd1Volume group "vg-newsql" successfully extended
5. Allocate space from volume group to logical volume :
lvextend -l +100%FREE /dev/mapper/vg--newsql-lv--newsql( Allocate space to the logical volume )
[email protected]:~# lvextend -l +100%FREE /dev/mapper/vg--newsql-lv--newsqlSize of logical volume vg-newsql/lv-newsql changed from <10.00 GiB (2559 extents) to 19.99 GiB (5118 extents).Logical volume vg-newsql/lv-newsql successfully resized.
6. Restart the logical volume for it to take effect :
resize2fs /dev/mapper/vg--newsql-lv--newsql
[email protected]:~# resize2fs /dev/mapper/vg--newsql-lv--newsqlresize2fs 1.44.1 (24-Mar-2018)Filesystem at /dev/mapper/vg--newsql-lv--newsql is mounted on /data; on-line resizing requiredold_desc_blocks = 2, new_desc_blocks = 3The filesystem on /dev/mapper/vg--newsql-lv--newsql is now 5240832 (4k) blocks long.
7. see :
df -h When the logical volume is found (resize2fs /dev/mapper/vg--newsql-lv--newsql) When the space increases , Indicates successful addition .
[email protected]:~# df -hFilesystem Size Used Avail Use% Mounted onudev 3.9G 0 3.9G 0% /devtmpfs 798M 3.2M 795M 1% /run/dev/vda2 39G 2.8G 35G 8% /tmpfs 3.9G 0 3.9G 0% /dev/shmtmpfs 5.0M 0 5.0M 0% /run/locktmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup/dev/vda1 547M 77M 430M 16% /boot/dev/mapper/vg--newsql-lv--newsql 20G 44M 19G 1% /data
边栏推荐
- Use for, while and do while to find the sum of 1-100 circularly
- 力扣:零钱兑换
- Fedora 36 compiling and installing opencv 4.6.0 -- the road to building a dream
- Text text associated with scroll scroll bar in Tkinter
- WPF dependent properties
- MySql踩坑记录
- STM32下载一次程序后就无法再次下载,程序无法运行。
- Pi4j GPIO pin pull-up resistance, pull-down resistance concept
- WPF 手写板
- Livres obligatoires
猜你喜欢

fork-join线程池

电脑屏幕分辨率怎么调?电脑屏幕修改分辨率SwitchResX

小程序与工业互联网能够相辅相成的原因

Technology sharing | a clustering incremental statistical SQL requirement in MySQL

【深入理解TcaplusDB技术】单据受理之事务执行

可乐与凉茶加速互卷

Contact five heart matchmaker to take off the order

在商业智能BI开发过程中,什么问题的挑战性最大?

【深入理解TcaplusDB技術】TcaplusDB構造數據

关于eureka启动成功但是访问404问题
随机推荐
Use the while loop to calculate the odd and even sums in 1-100 [method 1]
Use for, while and do while to find the sum of 1-100 circularly
语音断点检测(短时改进子带谱熵)
Wonderful review Figure 1 learn about Huawei cloud special dry goods
ES7 create index template
Five minutes, Xie Yunyuan
分布式数据库使用逻辑卷管理存储之扩容
Text text associated with scroll scroll bar in Tkinter
WPF thread manipulation UI problem
Electronic bidding procurement mall system: optimize traditional procurement business and speed up enterprise digital upgrading
[WUSTCTF2020]朴实无华-1
KVM virtual machine online disk expansion -- the road to dream
MATLAB在做图像处理时容易出现的一个误区:为提高运算速度使用预先声明的零矩阵存储图像数据
Required books
FPGA之道——数字系统之间的接口电平标准
Technology sharing | mysql:caching_ sha2_ Password quick Q & A
关于lg(n!)的渐进紧确界
[in depth understanding of tcapulusdb technology] tcapulusdb construction data
联系五心红娘脱单
WPF ListBox虚拟化