Principles of VG, PV, and filesystem on AIX (from the IBM minicomputer World)

Source: Internet
Author: User

Before using PV, we must "add" it to the volume group (VG, volume group) or directly create a volume group on it. When a PV belongs to a VG, its space is divided into many smaller allocation units, each of which is called a physical partitions (PP physical partition ). Such as cutting various irregular stones into the same size and size of "Bricks" in the construction process. The purpose is to pile up the "Bricks" as needed during the construction process, it is not limited by the shape and size of the "stone. Therefore, the PP size in VG is equal, regardless of the original disk size. We can continue to create logical volume (LV, logical volume) on VG, which is a device left for the program to use. It can span multiple disks (that is, PV), but not VG. When creating a logical volume, you must specify the name and size of the logical volume. The unit of size is the size of PP, that is, at least one pp space is required.
There are no special restrictions. However, by default, each LV may have a PP limit of 256 or 512 (depending on different operating system versions). However, this restriction is soft and can be modified at will.

The real unit of the logical volume is PP, but it is called LP, that is, logical partitions (LP, logical partition). The reason for introducing the additional LP is the image. AIX implements data mirroring through the multiples of PP and LP. Each LP corresponds to 1-3 pp physical spaces according to image requirements. 1 indicates no image, 2 indicates one image, and 3 indicates two images. In Aix, a logical volume is treated as a special block device. You can see the corresponding device name in the/dev/directory, for example:
/Dev/rmylv-> charact (character) device name
/Dev/mylv-> block device name

Logical volumes can be directly used by applications. This method is called the bare device method. You can also create a file system on a logical volume and use it as a normal file.

When AIX identifies a new PV, it first checks whether it has a PVID. PVID is the unique identification number assigned to each PV, which is recorded in the disk's operating system retention zone. If AIX has (or has) recognized this disk, A copy of PVID is also recorded in the ODM. If the old disk is removed, the corresponding device (hdisk will change to defined State) in Aix. However, the hdisk device number is retained. When the disk "returns", the hdisk is changed to the available state again when the disk is used. If it is a brand new disk with no PVID, AIX can only see the disk device available, while PVID is none. In this case, apart from creating an VG on it or adding it to an existing VG, setting a new PVID, and deleting the PV from the system, you cannot perform other operations. The create VG and add VG action will automatically assign a new PVID to the PV. The command for resetting PVID has two options:
# Chdev-l hdiskx-A Pv = Yes ------> force hdiskx to assign a new PV ID
# Chdev-l hdiskx-A Pv = clear ------> force clear the pv id used by hdiskx

Note:
PV management in the system relies entirely on pv id. Although device numbers such as hdiskx are available, the operating system still relies on PVID for disk identification, that is, hdisk numbers may change, even for the same minicomputer, The PVID will never change, even if the PVID on the other machine is obtained (until the above operation can change the PVID ). The PVID remains unchanged. identifying shared disks by pv id is also the basis for double-click hot backup. On the other hand, if you use the above command to change the pv id, the operating system will think that the original disk has disappeared and cannot be recovered.
Unfortunately, if the original PV still belongs to a VG, the VG can no longer find its original member disk (the PVID has changed), and the data on this disk cannot be retrieved, although the disk and data are still there. To solve this problem, you can only use the underlying ODM operation, which is beyond the scope of this book. If you are interested, you can study the relevant materials on your own.

VG can be accessed only after it is activated (read/write and view VG information). At the same time, VG is also "locked" by the operating system image executing the activation command ", access to images of other operating systems is not allowed (including executing activation commands ). The activation and release of VG commands are as follows:
# Varyonvg vg_name activate this VG and do not allow access from other Operating System Images
# Varyoffvg vg_name release this VG and allow access from other Operating System Images

Note that this "Lock" is only a logical lock (marking on the disk), and when VG is activated, if the machine suddenly goes down, the operating system may not be able to execute the disk UNLOCK Command (clear the flag), and other machines will no longer be able to activate this volume group! You need to execute a force command with the-F parameter to activate this volume group:
# Varyonvg-F vg_name
Sometimes you even need to use a lower-level command to manually clear the lock flag, which is lquerypr or pcmquerypr. Because this command is an underlying command, it is easy for beginners to operate improperly and leads to incorrect results. Please use it with caution.

Vgda (volume group descriptor Area)
PV can be used only after it is added to VG. One PV can belong to only one VG (one VG may have a maximum of PVS according to its type ). Which PVS are included in VG in a region, which is vgda. vgda records a lot of important information about VG, including the PVID of all PVS contained in VG.

 

Because the information in vgda is very important, vgda is saved in multiple copies. If VG has only one disk (PV), there are two vgda copies on this disk. If VG has two disks, the first disk has two vgda copies, the second disk has one copy. If VG contains three or more disks, each disk has a copy of vgda. the ratio of the number of vgda in good condition to the total number of disks in VG is called quorum. If quorum is smaller than 50%, the VG cannot be accessed (if activated, it will be automatically disabled ), this is done to prevent further damage to the data and wait for the professional to fix it (this is based on the design philosophy: If operations that may harm the data, the result of not doing anything is far better than that of having people to do what they want ). Because each disk has at least one vgda, on a new minicomputer, you only need to provide a disk in the position VG to correctly identify all the VG information, and "register" to the new minicomputer. This process is called import. The command is:
# Importvg-y vg_name hdiskx
Vg_name indicates the expected VG name, And hdiskx indicates any disk in the VG. Because you can customize the VG name when executing the importvg command, the VG name is not changed in the system. If you want to change the VG name, execute the exportvg command First (delete the VG definition in the system and use the new name importvg)
If you want to delete a VG from a minicomputer, You need to execute
# Exportvg vg_name
This operation does not perform any operations on the disk, and the data on the disk still exists, including the content in vgda. This command only deletes the definition of the VG In the AIX operating system, and you can re-imprt it back at any time.

When importvg is executed, the operating system can specify that the disk reads the definitions of all disks (PVs) in VG (remember that each disk in VG has at least one vgda, is that the definition of all VG information ?), If the operating system finds that some disks of the VG are not identified by the system (by PVID, that is, the vgda contains a PVID which cannot be found on all disk devices in the operating system, the possible cause is that the disk does not exist or the PVID is not correctly read.) then the system calculates the quorum. If quorum> 50%, you can still execute importvg, but there is a warning. When quorum <50%, you cannot import this VG.

 

Thoughts on PVID
The AIX operating system does not provide any direct command to set the PVID. when creating the VG or adding the disk (PV) to the VG, the operating system automatically specifies a PVID Based on the serial number, current time, and other parameters of the local machine. Therefore, the PVID generated in the system cannot be repeated. After you clear the PVID of a disk using the chpv command, you can directly write the required PVID unless you use the underlying disk editing command, otherwise, there is no way to restore the original PVID of the disk. If the PVID is changed, it means that the disk is completely a new disk and the system will not acknowledge that the disk is still the original VG. Therefore, when you perform the operation to change the PVID, you must know what the possible consequences are, because the operation may lead to unrecoverable data loss.

The vgda space of a common VG can only store 32 PV information. Therefore, a common VG supports only 32 disks. If it is a big ("big") VG, vgda can store 128 PV information; the latest scalable ("extension ")
VG supports 1024 PVS.

Vgsa (volume group status area)
Vgsa is an important area in VG. It consists of 127 bytes. Each PV has a vgsa, and each bit represents the status of a PP of this pv. It can correspond to a maximum of 1016 pp (128*8 = 1024 bits, of which 8 bits are reserved for use, 1016 bits), which limits a PV to 1016 PP at most.

Vgsa uses each bit to indicate the status of the PP. When the operating system writes data to the PP of the image, there will inevitably be a time difference. If a system problem occurs after a new PP occurs, the other PP is not updated. This PP and Its Mutual mirror pp (Do you still remember that one LP mentioned above may correspond to 1-3 pp? The relationship between several pp corresponding to the same LP, that is, the image relationship) is not updated, and the data is older, the operating system uses vgsa to mark the vgsa as stale. The stale status indicates that the PP data of each image is inconsistent. You need to re-Synchronize the data from the "good" image pp. When the Operating System Activates (varyonvg) VG, it will automatically check whether "stale" PP is available on all disks in the VG. If yes, it will automatically synchronize; if the VG is in normal use, the operating system will not take the initiative to synchronize, You need to manually execute the command for synchronization, you can use PV, LV or the whole VG as the unit of stale pp synchronization. You can find the synchronization VG option in the Smit VG menu.

Big VG, scalable VG
When VG is created, the vgda and vgsa sizes are fixed. Therefore, the maximum number of disks and the maximum number of PP of each disk can be determined by VG: each VG can contain up to 32 PVs and a total of 256 PVS (logical volumes, including one reserved for internal use by LVM, with 255 actually available ). In big VG, these restrictions were all broken, with PV expanded to 128 and LV expanded to 512. You can directly create "big" VG, or expand "small" VG to "big" VG.

For scalable VG, a maximum of 1024 PVs and 256 (up to 4096 PVS can be set at creation. The following command can be used to create a scalable VG (note that the parameters created on that PV are also included during execution ).
# Mkvg-s vg_name
Essentially, there is no special difference between these VG types. The difference is how much vgda space is reserved by the system. Obviously, the larger the vgda space is to support more disks in VG. In the process of converting "small" VG into "large" VG, AIX only expands the space of vgda. Because vgda starts at the beginning of each PV and must be continuous, if the disk has created an LV and the space is allocated, the vgda space may not expand, changing the VG type will fail. If there is still room for VG, you can use the PP migration command to migrate the PP data that occupies the vgda space in the future to other locations. The following is a demo command (note that this is the underlying LVM command and it is best to use it after testing the system verification) for your reference.

# Lmigratepp-G vgid-P old_pvid-N old_ppnum-P new_pvid-N new_ppnum

Vgid can be obtained through lsvg vg_name. old_pvid and new_pvid are the PVID of the source and target disks, respectively. old_ppnum is 1, which is the first pp (we want to remove the data of the first PP, so that the free location is vgda), new_ppnum is a free pp corresponding to new_pvid, which can be obtained through lspv-M hdiskx.

Physical volume (PV) Control
PV has a parameter that controls whether PP on this physical volume can be allocated to a logical volume. When you expand, create LV, and create a file system, the system will automatically allocate the PP that can be allocated in the VG. If you want to tell the system not to use
The free space on a PV is not allowed by this parameter. Command:
# Chpv-a n hdiskx does not use this PV (hdiskx)
# Chpv-A y hdiskx can use this PV (hdiskx)
Or use the quick index of the Smit command:
# Smit chpv

VG Parameters
# Lsvg vg_name-> View VG Parameters
Activate VG after startup: automatic activation cannot be set for the shared VG (Disk); otherwise, a conflict may occur (one machine activates VG after startup and locks the disk; when another machine is started, it tries to activate the VG. If it is not a parallel volume, an error occurs when both machines activate the same VG at the same time ). If it is used on a single machine, automatic activation is usually required, which avoids manual operations.

 

Quorum required: If quorum is enabled, when the number of inaccessible disks in VG exceeds half, the system will forcibly disable the VG (if the VG has been varyon, The varyoffvg command is automatically executed) alternatively, you cannot activate this volume (if this VG has not been varyon) to prevent further data corruption and wait for professional personnel to process it.

 

Enhanced-capable mode:
If you have installed the bos. clvm. ENH file set (which is not installed by default, You need to select it yourself), you have added another VG mode parameter: enhanced-capable. This mode can coexist with any VG type and needs to be modified using the Smitty chvg or chvg command. This mode is set to work with hacmp (powerha. AIX itself does not support parallel file systems, so the file system cannot be mounted by two AIX kernels at the same time (that is, the dual-host simultaneously mounts the shared file system) to avoid both parties writing data at the same time and damaging the file system. When performing switchover and taking over, Ha needs to run varyoffvg on the umount file system of one node, and then mount the file system from another node varyonvg and mount the file system. Although these operations are automatically completed by the HA, the operation itself has extended the time taken over. The enhanced-capable mode works with Ha. It allows the master node to use VG and mount the file system normally. The slave node is also varyonvg but is read-only and does not mount the file system, in this way, the VG take-over step is omitted, and the take-over time is reduced.

Concurrent
VG mode: VG also has a concurrent mode, which is different from the enhanced-capable model just mentioned. This is a completely parallel mode and works with hacmp, however, in this case, VG cannot (can be created, but should not be created) exist in a file system. It can only have bare devices (that is, LV), and applications control the data read/write lock, to ensure data consistency, the operating system only writes and writes data. The above two modes (they do not coexist) require hacmp to control the varyon/off of VG, and the operating system cannot automatically start varyonvg. For management purposes, you can manually varyonvg.

 

File System; File System Parameters

AIX usually uses JFS (jonural file system, the log file system, or the second generation: jfs2 File System ).
A common file system is an NFS and CD-ROM file system.

JFS is usually similar to a file system in UNIX/linu, but slightly different. It uses a redo log solution similar to a database loop log to operate all file systems (excluding data operations, this operation is only valid for modifying the file system structure, such as modifying the file name and file size. Before you perform this operation, record it in the log before updating. If the minicomputer is down due to a fault during the update process (you may need to modify multiple information on the disk, this may cause incomplete updates and data inconsistency. However, because there is a log mechanism in Aix, when the minicomputer restarts, You can query the log and redo the last update, which ensures data consistency.
This mechanism is widely used in database applications and rarely used in file systems. Therefore, when most Unix systems are restarted after the downtime in Yichang, they usually need to perform file system check and recovery (full file system fsck check) operations, while AIX can avoid unnecessary repairs, this greatly accelerates the restart time.

The Aix file system has many parameters to adjust:
Allow large files: create large files on this file system (more than 2 GB, of course, the fsize limit in/etc/security/limits must be considered ).
Nbpi: number of bytes per I-node. Each inode represents the disk space.
Fragment Size: Legacy technology is rarely used. jfs2 is a fixed value and is no longer considered.
Ag size: the size of the allocation group file allocation group. The minimum unit of file system size is increased each time.
User quota: user space quota, restrict excessive use of the file system.

We know that each file occupies one or more storage spaces represented by inode in Unix. If there are many files and each file is very small, we want inode to represent less space, this improves the storage utilization;
If there are few files and each file is large, the inode represents a larger space, reducing the number of inode (inode itself occupies space) and improving the storage utilization. Therefore, when creating a file system, you must make a balance. Because each inode represents the space (nbpi) that is set during file system creation and cannot be changed. Therefore, to improve efficiency, you must consider it carefully.

Generally, you can set the file system with the parameters shown in Table 4-20.

To check whether the file system enables large file enabled (a file system that supports large file), run the following command:
$ LSFS-Q/home
Name nodename Mount pt vfs size options auto Accounting
/Dev/hd1 --/home JFS 131072 -- Yes No
(LV size: 131072, FS size 131072, frag size: 512, nbpi: 4096, compress: No, BF false, AG: 8)

BF: false indicates standard file system of a common file system.
BF: True indicates large file enhanced File System
Auto: Yes indicates that the file system is automatically mounted after the system is started.
Accounting: No indicates that the file system does not have a quota limit.
When many users share the same file system, they can avoid excessive use of the file system by limiting the user's space usage quota. The quota limit requires a certain amount of system resources. Therefore, for an AIX system, if it is not provided to end users for logon, no quota limit is required.

Jfs2 File System
Jfs2 extends many new features, such as Directory sorting and dynamic space allocation. Because jfs2 uses btree as the new metadata sorting algorithm, many restrictions in JFS are removed:
(1) Dynamic Allocation of inode quantity, limited by file system size
(2) the file system size is limited by the disk space only (1 Pb = 1000 TB = 1000000 GB tested by IBM)
(3) The number of files in the file system is limited by the disk space (1 Pb tested by IBM)
(4) JFS logs can be stored in the logical volume of the file system (inline mode ), instead of using another dedicated logical volume (JFS requires at least one logical volume in each VG to store JFS logs,
However, the file system in the same VG can share the same JFS log logical volume)

Q: What is the use of JFS or jfs2 file system logs?
Answer: any file system must consider its own robustness, that is, it must ensure the correctness of its data structure in case of exceptions, there will be no serious problems. For example, when the disk is writing data, if the machine loses power, the current data writing fails. However, sometimes Data Writing is not a complete failure, and may have been written to the disk, but there is no place in the system to record this situation. In this case, the data on the disk is messy. Especially when the system supports parallel writing, the problem is particularly serious. In case of abnormal shutdown, wrong data will certainly occur. To avoid this, AIX uses the logical volume log technology. Each disk write time limit is used to record the data to be rewritten in a small space called the logical volume log (not to record the data itself, only records the location of the data ). In this way, when data is actually written, the data in the logical volume log must be rewritten somewhere. When the system restarts, the system only needs to scan the logical volume log and check the correctness of the last few pieces of data to ensure that the structure of the entire file system is not chaotic. Of course, data may still be lost, but at least the structure is correct. Logical volume log technology does not require full structure verification, which is much faster than activating other non-log file systems. It is especially important for file systems with hundreds of GB of data, it may take several hours to check whether the structure is correct because the file system is scanned for several hundred GB.

Log also has an impact on the file system performance, especially if the same VG has many file systems with frequent access (file structure changes, such as creating, deleting, increasing, and narrowing, storage location change), because these file systems need to share the same log device, resulting in frequent log write operations, thus affecting performance. The solution is to create a separate Log Device for each busy file system and store it on different disks. This increases the concurrency and improves the file system performance.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.