In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use lvm", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use lvm" this article.
The use of lvm
Lvm is very useful. In a production system, if there is not enough space, it is very inconvenient to expand capacity before using lvm.
To find a storage that you want to expand to the capacity you want, and then import the original data into the new device, which is also a kind of storage for the existing device.
Waste, with lvm, it is different. I can directly add storage space to the system without changing the original system.
The following is the partition of my 146hard drive, my server plans to use the user oracle database
For some zones with little spatial change, I still use ext3 format, but for some zones with great changes in space 0, I use lvm.
In this way, we are fully prepared for future expansion.
[root@dbolap] # df-h
Filesystem Size Used Avail Use% Mounted on
/ dev/sda1 981M 202M 730M 22% /
None 1004M 0 1004M 0% / dev/shm
/ dev/sda8 2.0G 36M 1.8G 2% / tmp
/ dev/sda6 3.9G 2.0G 1.8G 53% / usr
/ dev/sda7 2.0G 115M 1.8G 7% / var
/ dev/mapper/vg_home-lv_home
9.6G 54m 9.1G 1% / home
/ dev/mapper/vg_u01-lv_u01
110G 92m 105G 1% / U01
[root@dbolap ~] #
I. steps for the use of LVM:
1)。 Create a partition of type LVM (8e)
2)。 Establish LVM physical physics PV
3)。 Set up LVM administrators group VG
4)。 Set up the LVM logic LV
5)。 Establish a file system
6)。 Attach a file system
7)。 Using the file system
II. Automatic mounting of LVM on boot
The purpose of the fstab file:
The file / etc/fstab stores the file system information in the system. When the file is set up correctly, you can use "mount / directoryname".
To load a file system, each file system corresponds to a separate line, with fields separated by spaces or tab keys. Meanwhile, fsck and mount
, umount and other commands all make use of this program.
Lvm boot automatic mount, you can modify the / etc/fstab file, and then restart the machine
Eg:
[root@dbolap ~] # vi / etc/fstab
# This file is edited by fstab-sync-see 'man fstab-sync' for details
LABEL=/ / ext3 defaults 1 1
None / dev/pts devpts gid=5,mode=620 0 0
None / dev/shm tmpfs defaults 0 0
None / proc proc defaults 0 0
None / sys sysfs defaults 0 0
LABEL=/tmp / tmp ext3 defaults 1 2
LABEL=/usr / usr ext3 defaults 1 2
LABEL=/var / var ext3 defaults 1 2
LABEL=SWAP-sda5 swap swap defaults 0 0
/ dev/vg_home/lv_home / home ext3 defaults 1 0
/ dev/vg_u01/lv_u01 / u01 ext3 defaults 1 0
/ dev/hda / media/cdrom auto pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0
/ dev/scd0 / media/cdrecorder auto pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0
~
~
The following is a brief description of the format of the fstab file:
Here is a sample routine for the / etc/fatab file:
Fs_spec fs_file fs_type fs_options fs_dump fs_pass
/ dev/hda1 / ext2 defaults 1 1
IDE devices are generally described as / dev/hdaXN,X is the IDE device channel (a, b, or c), N represents the partition number; SCSI device 1 is described as / dev/
SdaXN . In the case of NFS, the format is generally:
, for example: `knuth.aeb.nl:/'. For procfs, use `proc' to define it.
Fs_file-this field describes the directory point that you want the file system to load, and for swap devices, this field is none; for loading directory name packages
In the case of spaces, 40 is used to represent spaces.
(fat32 format of Windows system), NTFS, iso9600, etc.
Codepage national language code page
Iocharset character set
Fs_options-specifies that the file system on which the device is mounted is a specific parameter option that needs to be used, with multiple parameters separated by commas. For
Most systems use "defaults" to meet their needs. Other common options include:
Option meaning
Ro loads the file system in read-only mode
Sync does not buffer the write operations of the device, which prevents damage to the file system during an abnormal shutdown, but slows down the computer
User allows ordinary users to mount the file system
Quota enforces a disk quota limit on this file system
Noauto no longer uses the mount-a command (such as when the system boots) to mount the file system
Fs_dump-this option is used by the "dump" command to check how often a file system should be dumped, and set this field to 0 if no dump is needed
Fs_pass-this field is used by the fsck command to determine the order of file systems that need to be scanned at startup, and the corresponding field of the root file system "/" should have a value of 1.
Other file systems should be 2. Set this field to 0 if the file system does not need to be scanned at startup
III. Online expansion method of lv for LVM
Usually, after we operate pvextend, we must execute the relevant commands of resize. Usually for security reasons, it is done under offline, that is, after umount.
But sometimes we can't let some production systems offline. Therefore, we must ensure that under the premise of online, the corresponding LV of extend.
Here are the commands that should be executed for the following file system types in the case of Online.
1:ext3
Ext2online / dev/foovg/lvbar
2:reiserfs
Resize_reiserfs / dev/foovg/lvbar
3:xfs
Xfs_growfs / dev/foovg/lvbar
4:jfs
Mount-o remount,resize / dev/foovg/lvbar
Strictly speaking, jfs does not count as an online operation. If there happens to be an IO operation in the partition of this mounting, I am afraid there will be a problem with this execution. So I'll check again later on this reservation.
IV. Lvm common commands
LVM creates and uses favorites
A, concept:
1) .PV (Physical Volume): physical disk, which is at the bottom of LVM, and can be a physical hard disk or partition.
2) .VG (Volume Group): the PV group, which is built on top of PV, can contain one or more VG.
3) .LV (Logical Volume): logical partition, which is based on PV and is equivalent to the concept of original partition. But the size can be changed dynamically.
4) .PE (Physical Extend): physical area, the smallest unit of storage that can be used for allocation in PV, which can be specified when creating a PV, such as 1, 2, 4, 8. ... 64m, the PE of all PV in the same VG should be the same.
5) .le (Logical Extend): logical region, the smallest storage unit in a LV that can be allocated, depending on the size of the PE in the PV where the LV resides, which is an integral multiple of the PE.
6) .VGDA (Volume Group Descriptor Area): the pvcreate group description area, which exists in each PV, is used to describe information such as the PV itself, the VG contained in the PV, the LV in the VG, and the physical area allocation in the LV, which is established when the PV is established using the pvcreate command.
B, steps:
1)。 Create a partition of type LVM
2)。 Establish LVM physical physics PV
3)。 Set up LVM administrators group VG
4)。 Set up the LVM logic LV
5)。 Establish a file system
6)。 Attach a file system
7)。 Using the file system
C, command
1). PV (physical physics) correlation
Pvdisplay: displaying PV properti
Pvscan: look for PV on all the hard drives of the system
Pvcreate: create PV (initialize VGDA on PV)
For example: PV was created for / dev/hda1
[root@mylinux] # pvcreate / dev/hda1
Pvdata: displays the details of a PV
For example:
[root@mylinux] # pvdata / dev/hda1
Pvchange: changing the PV property
Pvmove: moving PE/LE between PV
2) .VG correlation
Vgdisplay: displays the VG preferences group properti
Vgscan: find the existing VG groups in the system
Vgcreate: create a VG administrators group (initialize VGDA on VG)
For example: create a logical group demoVG1 that contains physical hda1 and hdb1
[root@mylinux] # vgcreate demoVG1 / dev/hda1 / dev/hdb1
Vgdata: displays VGDA information on the VG administrators group
Vgchange: change the properties of the VG administrators group
This command has two commonly used parameters:
-aRutMART available {y | n}: when operating VG, control the usability of a VG, in other words, whether a VG can be recognized by the system kernel.
-xmam talk music {y | n}: controls whether a VG can be expanded or reduced (controls whether the PV in a VG can be allocated).
Vgmove: move PE/LE between VG groups
Vgextend: used to add a new PV to VG
For example: [root@mylinux] # vgextend demoVG1 / dev/hdd1
Vgreduce: used to remove PV from VG
For example: [root@mylinux] # vgreduce demoVG1 / dev/hdd1
Vgmerge: used to merge administrators groups. The VG to be merged must be inactive.
For example, merge demoVG21 and demoVG2 into demoVG1 and display the results:
[root@mylinux] # vgmerge demoVG1 demoVG2
Vgmerge-ERROR:volume group "demoVG2" must be inactive
[root@mylinux] # vgchange-an demoVG2
Vgchange-volume group "demoVG2" successfully deactivated
[root@mylinux] # vgmerge demoVG1 demoVG2
Vgmerge-doing automatic backup of volume group "demoVG1"
Vgmerge-volume group "demoVG2" successfully merged into "demoVG1"
Vgsplit: the VG,VG that is used to split an existing VG,VG must be active.
For example:
[root@mylinux] # vgchange-a y demoVG2
[root@mylinux] # vgsplit demoVG2 demoVG4 / dev/hdd2 / dev/hdd5 / dev/hdd6 / dev/hdd7
Vgremove: used to delete VG, which requires that the VG to be deleted must be inactive.
For example:
[root@mylinux] # vgchange-an demoVG1
[root@mylinux] # vgremove demoVG1
Vgrename: used to rename VG and does not require VG to be inactive.
For example:
[root@mylinux] # vgrename demoVG2 demoVG3
Vgck: used to detect the consistency of VGDA in VG.
Vgcfgbackup: back up the VGDA information of all physical VG in the system to / etc/lvmconf
[root@mylinux] # vgcfgbackup
Vgcfgrestore: used to recover VGDA information from / etc/lvmconf for each physical slave in all VG of the system. VG must be inactive.
For example:
[root@mylinux] # vgchange-an demoVG3
[root@mylinux] # vgmknodes
Vgexport: used to output the administrators group. The pending output group must be inactive. This command is required when Physics in a group needs to be transferred to another system.
For example:
[root@mylinux] # vgchange-an demoVG3
[root@mylinux] # vgexport demoVG3
Vgimport: used to enter the quota group.
For example:
[root@mylinux] # vgimport demoVG1 / dev/hdd1
3) .LV correlation
Lvdisplay: display the properties of LV lvscan: find the existing LV of the system
Lvcreate: creating LV
Lvdata: displaying LVDA information on LV
Lvchange: changing the LV property
For example:
[root@mylinux] # lvchange-an / dev/demoVG1/demoLV11
Lvmove: moving PE/LE between LV
Lvextend: expand LV capacity. The most prominent feature of LVM is to dynamically adjust the size of LV space at any time.
For example:
[root@mylinux] # lvscan | grep LV11
Lvscan-- ACTIVE "/ dev/demoVG1/demoLV11" [200MB]
[root@mylinux] # lvextend-L + 10m / dev/demoVG1/demoLV11 (add 10MB space for demoLV11)
Lvreduce: reduce the capacity of LV.
For example:
[root@mylinux] # lvextend-L-10m / dev/demoVG1/demoLV11 (reduce 10MB space for demoLV11)
Lvrename:LV renaming
For example:
[root@mylinux] # lvrename / dev/demoVG1/demoLV11 / dev/demoVG1/demoLV01
Lvremove: delete LV (logical contacts)
For example:
[root@mylinux] # lvremove / dev/demoVG1/demoLV01 resize2fs/e2fsadm/resize_reiserfs: similar to the extend command.
4)。 Create a file system
Use the command mkfs to create a partition of type ext3 on demoLV31:
[root@mylinux] # mkfs-t ext3 / dev/demoVG3/demoLV31
Use the command mkfs.ext3 to create an ext3 partition on demoLV31:
[root@mylinux] # mkfs.ext3 / dev/demoVG3/demoLV31
Use the command mkreiserfs to create a reiserfs partition on demoLV31:
[root@mylinux] # mkreiserfs / dev/demoVG3/demoLV31
Use the command mkjfs to create a jfs partition on demoLV31:
[root@mylinux] # mkfs.jfs / dev/demoVG3/demoLV31
5)。 Attach a file system
Create four directories first:
[root@mylinux] # mkdir / mnt/mnt_lv11 / mnt/mnt_lv12 / mnt/mnt_jfs / mnt/mnt_reiserfs
Hang command:
Mkfs hook-up:
[root@mylinux] # mount-t ext3 / dev/demoVG3/demoLV31 / mnt/mnt_lv11
Mkfs.ext3 hook-up:
[root@mylinux] # mount / dev/demoVG3/demoLV31 / mnt/mnt_lv12
Mkjfs hook-up:
[root@mylinux] # mount-t jfs / dev/demoVG3/demoLV31 / mnt/mnt_jfs
Mkreiserfs hook-up:
[root@mylinux] # mount-t reiserfs / dev/demoVG3/demoLV31 / mnt/mnt_reiserfs
6)。 Use
* * slightly * *
7) .LVM related commands
Lvmdiskscan: detect logical administrator information in hard drives and partitions
Lvmsadc: collects read and write statistics for logical posts
Lvmsar: view log file information for LVM
Lvmchange: resets the LVM component
The above is all the content of this article "how to use lvm". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.