Article Title: select the ext3 log mode. 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. Linux is an open and Internet-based operating system. The development of Internet and network-centric computing models, such as e-commerce, have been rapidly accepted and popularized, all of which provide more opportunities for Linux to become the preferred platform for enterprises and departments. At the same time, Linux also provides a good growth and habitat environment for its own development with its huge capacity to accommodate new technologies. This is manifested in the development of its core technology, which provides high-performance system technical support for managing data, storing data, allocating data, and upgrading data in a Linux environment. Ext3 file systems are one of the most prominent technologies.
Log File System
Generally, when a file is written to a system running, the metadata of the file (such as permission, owner, Creation Time, and access time) is not written ), if the system shuts down abnormally after the file content is written and before the file metadata is written, the file system uninstalls the file during the write process abnormally, and the file system is in an inconsistent state. When the system restarts, Linux runs the fsck program, scans the entire file system, ensures that all file blocks are correctly allocated or used, finds the damaged directory item, and tries to fix it. However, The fsck does not guarantee repair damage. In this case, inconsistent metadata in the file fills up the space of the lost file, and the file items in the directory items may be lost, resulting in the loss of the file.
To minimize File System inconsistencies and shorten the startup time of the operating system, the file system needs to track records that cause system changes. These records are stored in a separate location from the file system, usually we call it "log ". Once these logs are securely written, the log file system can apply them to clear records that cause system changes and make them a set that causes changes to the file system, place them in the transaction processing of the database, and maintain the normal operation of valid data in the state, not in conflict with the performance of the entire system. When any system crashes or needs to be restarted, the data is restored according to the information records in the log file. Because log files have regular checkpoints, they are usually very neat. The file system design mainly considers efficiency and performance issues.
Linux supports many log file systems, including FAT, VFAT, HPFS (OS/2), NTFS (Windows NT), UFS, XFS, JFS, ReiserFS, ext2, and ext3.
Ext3 supports multiple log Modes
Ext3 is a high-level version of ext2 file system and is fully compatible with ext2. The main difference between ext2 and ext2 is its ability to quickly update files. The consistency between files and directories in the file system must be ensured when the computer reads or writes data from the disk. The data in all log files is stored in the storage device in the form of data blocks, when a disk is partitioned, the file system is created. data is stored and organized by file and directory. Linux Files And Directories use hierarchical file systems. Generally, the file system is installed by running the "mount" command during system installation, the linked list for use is stored in the file/etc/fstab, and the linked list for maintenance and installation is stored in the/etc/mtab.
Ext3 supports multiple log modes, including changing the metadata of the file system or the data of the file system (including changes to the file itself, the following three log modes are activated when the/etc/fstab file is booted:
◆ Data = journal log Mode
Logs contain all the data and metadata that change the file system. It is the slowest of the three ext3 log modes, but it minimizes the possibility of errors. In the "data = journal" mode, ext3 is required to write each change twice to the file system and once to write logs. This reduces the overall performance of the file system, but it is indeed the user's most beloved model. Because metadata and data updates are recorded in ext3, these logs work when a system restarts.
◆ Data = ordered log Mode
Only the metadata of the file system is changed, and the overflow file data must be added to the disk. This is the default ext3 log mode. This mode reduces the redundancy between writing to the file system and writing logs, so the speed is fast. Although changes in file data are not recorded in logs, they must be done, in addition, the daemon program of ext3 is executed before the related file system metadata changes, that is, the file system data must be modified before the metadata is recorded, which will slightly reduce the system performance (speed ), however, the file data in the file system can be synchronized with the metadata of the corresponding file system.
◆ Data = writeback log Mode
Only the metadata of the file system is recorded, but according to the standard file system, the write program still records the changes of the file data on the disk to maintain the consistency of the file system. This is the fastest ext3 log mode. Because it only records changes in metadata, and does not need to wait for updates related to file data, such as file size and directory information, updates to file data and changes in recorded metadata can not be synchronized, that is, ext3 supports asynchronous logs. The defect is that when the system is shut down, the updated data cannot be written to the disk, which cannot be solved yet.
There are differences between different log modes, but the setting method is as convenient. You can use the ext3 File System to specify the log mode, which is completed at/etc/fstab startup. For example, if you select data = writeback log mode, you can make the following settings:
/Dev/hda5/opt ext3 data = writeback 1 0
In general, the data = ordered log mode is the default mode of the ext3 file system.
Select log Mode
1. Consider Data Integrity
When an ext3 file system is used to shut down abnormally, the complete data performance is reliably guaranteed. You can also choose the type and level of data protection. For example, you can choose to ensure the consistency of the file system and allow the data on the file system to be damaged during abnormal shutdown, which can increase the speed (but not all) in some situations ). In addition, you can choose to keep the data consistent with the file system, which means that after an abnormal shutdown, no data spam will be seen in the newly written file. This security option that keeps data consistent with the file system is usually set by default.
In most cases, you add data to the end of the file. In some cases (such as databases), users write data between existing files and even overwrite existing files. This operation usually truncates the file before writing data. If the data = ordered mode is selected and the system crashes while writing files, the data block may be partially rewritten, but the newly added data write process is not complete, therefore, such incomplete data blocks cannot be part of the file data. The only way to get the residual data block after the crash is that a program is overwriting the middle of the existing file during the crash, and the program uses fsync () and O_SYNC to force write operations, in this case, data can be written in a specific order.
2. Speed considerations
Ext3 writes more data than ext2. However, ext3 is faster than ext2 (even for high-speed data streams ). This is because the ext3 log has the function of optimizing the rotation of the Hard Disk Head. By selecting one of the three log modes, you can select the optimization speed, but this will more or less cause incomplete data. Below we will compare these three log modes.
◆ Using data = writeback can significantly improve the speed, but it also reduces the protection of data consistency. Select another log mode. Data Consistency protection is basically the same as ext2 file system. The difference is that during normal operations, the system constantly maintains the integrity of the file system, including frequent shared write operations to create and delete a large number of small files. If you switch from ext2 to ext3 and find that the application performance is greatly reduced, the data = writeback option may be helpful for improving the performance. Even if you do not have data consistency protection measures, you can still enjoy the ext3 advantage (the file system is always consistent ). In many log file systems, this mode is set to the default mode.
◆ Data = ordered (default mode) can ensure that the data is consistent with the file system. This means that no junk data will be seen in newly written files during abnormal shutdown.
◆ To ensure moderate speed in most cases, the data = journal mode requires larger logs. Of course, the recovery time required after an abnormal shutdown is longer, but the speed is faster in some database operations.
We recommend that you use the default mode. To change the mode, add the data = mode option to the corresponding file system in the/etc/fstab file.
In this way, the pros and cons of speed and file data integrity can be weighed, and the speed can be adjusted for some special applications.
The Linux operating system is the fastest growing operating system in recent years. As the first officially supported log file system, ext3 is fully compatible with ext2. Ext3 provides support for multiple log modes, improves the performance of the Linux system, and solves the inconsistency problem in the system. Ext3 file system is an excellent and promising file 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