Article Title: Detailed description of soalris file system logging. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Application of the logging function in Solaris
In Solaris7 and later versions, there is a function called logging. It is not only easy to install and use, but also very useful for data security.
UFS is a standard file system type that exists in almost all hard disk partitions of Sun workstation (except for individual partitions such as swap. The logging function is a mount option of the UFS file system. It can be set on Hard Disk Partitions including.
Solaris UFS logging works by using blank data blocks in the system. All modifications to the file system data (metadata, or metadata) are written in these blank areas. These Metadata includes the Directory and inode information, not the data in the file. For example, when a file is created, the directory structure is modified and the system assigns a new inode to the new file. These behaviors are written into the logging space. Once the data modification is written to the logging area, the system can perform other operations on the file system. In the background, the information in logging will be synchronized to the file system, and the corresponding directory and I node will be automatically updated to complete file system operations. Data is also written into the hard disk. Therefore, it is much faster to perform logging and write data in the background than to directly modify various management information distributed on the hard disk through random I/O access. The size of the logging space depends on the size of the file system. The logging space for each 1 GB disk partition is 1 MB, and the maximum is 64 MB. This part of the logging space is recycled: When the log space is about to fill up, stop writing new metadata until the log space is cleared. After all the modifications to the file system recorded in the log are applied to the file system, the space can be used as the log space to store new metadata data.
Generally, for UFS, if the operating system crashes in any file system operation, the entire file system needs to use the fsck command for consistency check. The execution of this command may take several minutes because it needs to detect all metadata and file data to confirm the integrity of the file system: including the space used, unused, and inode quantity, to fix inconsistencies. Manual intervention is also required when a major problem occurs. During the check, files or directories may be lost. This depends on the extent to which the operation is performed when the crash occurs. If you use the logging function, the situation is completely different. Because the modification of metadata is first written in the log space rather than in the file system. If the system crashes, the detection of file system consistency can be limited to the part recorded in the log, which is simpler and more effective. The system checks the logging data to determine which changes have been made in the last file system, which changes are about to be made, and which changes are being made, operations that have been done and are about to be done, but have not yet been done, are deleted by the system from the log, and those that have done some of them will be completed or completely canceled. If sufficient data is recorded in the log to complete this operation, the Operation will continue. Otherwise, the change will be canceled. Users familiar with database operations will find that this process is very similar to that in database software. The final result is: The file system can be consistent to the maximum extent, without the need for thorough file system detection. The entire file system detection process takes only a few seconds. Starting from Solaris 7, the mount command and the/etc/vfstab file also have a new logging option.
To verify the contribution of the logging option to system performance, we create a script file to create 1000 directories. This operation puts a lot of pressure on the processing of metadata in the system. The experiment is performed on an Ultra 5 machine running Solaris7:
# More logging-test
#! /Bin/ksh
# Test ufs logging performance
# Get to the right place and make a test directory
Cd/big
Mkdir test
# Create 1000 directories
Integer I = 0
While (I <1000 ))
Do
Mkdir test/test $ {I}
I = I + 1
Done
# Chmod a + x logging-test: add the execution permission to the file
The logging option is not used for the first experiment (this option is not used by default in the file systems of Solaris 7 and 8 ).
# Time./logging-test use this command to test the entire execution time
Real 27.7
User 2.0
Sys 4.9
# Time rm-rf/big/test
Real 8.0
User 0.0
Sys 0.3
It takes 35.7 seconds to create and delete a directory. Use the logging option for the second time and perform another test:
# Umount/big
# Mount-o logging/big
# Time./logging-test
Real 13.2
User 1.7
Sys 5.4
# Time rm-rf/big/test
Real 0.8
User 0.0
Sys 0.2
The same command takes only 14 seconds after UFS logging is used, and the performance improvement is very obvious. The next test is more interesting. If you do not use logging and shut down during the execution of the preceding script, you are required to manually execute fsck to repair the system in the single-user State during the next startup, many errors were reported during the repair process. After the repair, the system can boot up. After using the logging function, the same experiment process was encouraging: the system only prompts:
/Dev/c0t1d0s3: is logging
No other error messages are provided.
However, UFS logging has some bugs at the beginning. Before using UFS logging, you need to apply the latest system core patch and test it in another non-production environment.
There is also a newer and useful mount Option: noatime. Without the noatime option, the value of the access time in the I node of each file is updated every time it is accessed. In this way, use ls? The lu command shows the last time the file was read. However, in some cases, we do not care when files are read, such as the content of Web server. However, they add a lot of IO load, thus affecting performance. Using noatime reduces the frequency of updating the access time. It enables the system to update the file access time only when the other I node attributes of the file are modified at the same time. In a file system that does not care about access time, this will not cause any damage to the system.
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