At one high loaded web project I needed a very fast file system. I decided to use Ext4 with disabled journal (As a google:))).
# Create ext4 fs on /dev/sda10 disk
mkfs.ext4 /dev/sda10
# Enable writeback mode. This mode will typically provide the best ext4 performance.
tune2fs -o journal_data_writeback /dev/sda10
# Delete has_journal option
tune2fs -O ^has_journal /dev/sda10
# Required fsck
e2fsck -f /dev/sda10
# Check fs options
dumpe2fs /dev/sda10 |more
For more performance add fstab opions: data=writeback,noatime,nodiratime
i.e:
/dev/sda10 /opt ext4 defaults,data=writeback,noatime,nodiratime 0 0
Tested at non-boot partition ;)
ext4文件系统关闭journal日志功能
最近在帮一个研究生弄一个虚拟化环境下的基于Innodb的日志文件的读写优化的实验,实验的具体详细内容就不说了,其中有一个步骤需要将MySQL的日志文件放置在一块单独的硬盘里面,这块硬盘要么是ext2,要么是ext4,ext4的性能据说比前面的ext系列的要高,所以选择了ext4。但是ext4具备有日志的功能,如果开启了这个日志功能的话,到时又会有多个虚拟机同时跑,那么这个ext4的日志功能会对我们的实验数据产生一定的影响,并且我们在实验中并不需要到这个日志功能,所以需要将这个日志功能关闭。具体如下步骤:
下面的vda便是虚拟机所导入的硬盘,我们先对这个硬盘格式化一下:
[root@centos7_vm_1 ~]# mkfs.ext4 /dev/vda mke2fs 1.42.9 (28-Dec-2013) Filesystem label=OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks65536 inodes, 262144 blocks13107 blocks (5.00%) reserved for the super user First data block=1Maximum filesystem blocks=3381657632 block groups8192 blocks per group, 8192 fragments per group2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done
先来检测一下/dev/vda硬盘上的ext4文件系统是否带有日志功能:
[root@centos7_vm_1 ~]#dumpe2fs /dev/vda | grep 'Filesystem features' | grep 'has_journal'dumpe2fs 1.42.9 (28-Dec-2013) Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
可以动态地在ext4文件系统创建之后关闭其日志功能:
[root@centos7_vm_1 ~]# tune2fs -O ^has_journal /dev/vda tune2fs 1.42.9 (28-Dec-2013)
如果需要开启的话:
[root@centos7_vm_1 ~]# tune2fs -O has_journal /dev/vda tune2fs 1.42.9 (28-Dec-2013) Creating journal inode: done
参考链接:
http://www.lenky.info/archives/2012/02/990
ext4 disable journal
目录 返回
首页