搜索

3.7. 数​​​​​​​据​​​​​​​日​​​​​​​志​​​​​​​

download PDF
Ordinarily, GFS2 writes only metadata to its journal. File contents are subsequently written to disk by the kernel's periodic sync that flushes file system buffers. An fsync() call on a file causes the file's data to be written to disk immediately. The call returns when the disk reports that all data is safely written.
数​​​​​​​据​​​​​​​日​​​​​​​志​​​​​​​可​​​​​​​减​​​​​​​小​​​​​​​ fsync() 时​​​​​​​间​​​​​​​,特​​​​​​​别​​​​​​​是​​​​​​​对​​​​​​​于​​​​​​​小​​​​​​​文​​​​​​​件​​​​​​​,因​​​​​​​为​​​​​​​文​​​​​​​件​​​​​​​数​​​​​​​据​​​​​​​在​​​​​​​写​​​​​​​入​​​​​​​元​​​​​​​数​​​​​​​据​​​​​​​外​​​​​​​还​​​​​​​要​​​​​​​写​​​​​​​入​​​​​​​日​​​​​​​志​​​​​​​。​​​​​​​数​​​​​​​据​​​​​​​写​​​​​​​入​​​​​​​日​​​​​​​志​​​​​​​后​​​​​​​ fsync() 就​​​​​​​会​​​​​​​返​​​​​​​回​​​​​​​,这​​​​​​​样​​​​​​​就​​​​​​​比​​​​​​​将​​​​​​​文​​​​​​​件​​​​​​​数​​​​​​​据​​​​​​​写​​​​​​​入​​​​​​​主​​​​​​​文​​​​​​​件​​​​​​​系​​​​​​​统​​​​​​​要​​​​​​​迅​​​​​​​速​​​​​​​。​​​​​​​
依​​​​​​​赖​​​​​​​ fsync() 同​​​​​​​步​​​​​​​文​​​​​​​件​​​​​​​数​​​​​​​据​​​​​​​的​​​​​​​应​​​​​​​用​​​​​​​程​​​​​​​序​​​​​​​可​​​​​​​能​​​​​​​因​​​​​​​使​​​​​​​用​​​​​​​数​​​​​​​据​​​​​​​日​​​​​​​志​​​​​​​而​​​​​​​使​​​​​​​性​​​​​​​能​​​​​​​有​​​​​​​所​​​​​​​提​​​​​​​高​​​​​​​。​​​​​​​在​​​​​​​被​​​​​​​标​​​​​​​记​​​​​​​的​​​​​​​目​​​​​​​录​​​​​​​及​​​​​​​其​​​​​​​所​​​​​​​有​​​​​​​子​​​​​​​目​​​​​​​录​​​​​​​中​​​​​​​生​​​​​​​成​​​​​​​的​​​​​​​ GFS2 文​​​​​​​件​​​​​​​可​​​​​​​自​​​​​​​动​​​​​​​启​​​​​​​用​​​​​​​数​​​​​​​据​​​​​​​日​​​​​​​志​​​​​​​。​​​​​​​现​​​​​​​有​​​​​​​长​​​​​​​度​​​​​​​为​​​​​​​ 0 的​​​​​​​文​​​​​​​件​​​​​​​也​​​​​​​可​​​​​​​以​​​​​​​打​​​​​​​开​​​​​​​或​​​​​​​者​​​​​​​关​​​​​​​闭​​​​​​​其​​​​​​​数​​​​​​​据​​​​​​​日​​​​​​​志​​​​​​​功​​​​​​​能​​​​​​​。​​​​​​​
Enabling data journaling on a directory sets the directory to "inherit jdata", which indicates that all files and directories subsequently created in that directory are journaled. You can enable and disable data journaling on a file or a directory with either of the following methods:
  • 在​​​​​​​文​​​​​​​件​​​​​​​或​​​​​​​者​​​​​​​目​​​​​​​录​​​​​​​中​​​​​​​执​​​​​​​行​​​​​​​ chattr +j 或​​​​​​​者​​​​​​​ chattr -j
  • 使​​​​​​​用​​​​​​​ gfs2_tool setflag 或​​​​​​​者​​​​​​​ gfs2_tool clearflag 命​​​​​​​令​​​​​​​为​​​​​​​文​​​​​​​件​​​​​​​或​​​​​​​者​​​​​​​目​​​​​​​录​​​​​​​设​​​​​​​定​​​​​​​或​​​​​​​者​​​​​​​清​​​​​​​除​​​​​​​ jdata 标​​​​​​​签​​​​​​​
使​​​​​​​用​​​​​​​ chattr 命​​​​​​​令​​​​​​​是​​​​​​​在​​​​​​​某​​​​​​​个​​​​​​​文​​​​​​​件​​​​​​​或​​​​​​​者​​​​​​​目​​​​​​​录​​​​​​​中​​​​​​​启​​​​​​​用​​​​​​​和​​​​​​​禁​​​​​​​用​​​​​​​数​​​​​​​据​​​​​​​日​​​​​​​志​​​​​​​的​​​​​​​首​​​​​​​选​​​​​​​方​​​​​​​法​​​​​​​。​​​​​​​

3.7.1. 使​​​​​​​用​​​​​​​ chattr 命​​​​​​​令​​​​​​​启​​​​​​​用​​​​​​​和​​​​​​​禁​​​​​​​用​​​​​​​数​​​​​​​据​​​​​​​日​​​​​​​志​​​​​​​

您​​​​​​​可​​​​​​​以​​​​​​​使​​​​​​​用​​​​​​​ chattr 命​​​​​​​令​​​​​​​为​​​​​​​某​​​​​​​个​​​​​​​文​​​​​​​件​​​​​​​启​​​​​​​用​​​​​​​或​​​​​​​者​​​​​​​禁​​​​​​​用​​​​​​​数​​​​​​​据​​​​​​​日​​​​​​​志​​​​​​​。​​​​​​​以​​​​​​​下​​​​​​​命​​​​​​​令​​​​​​​为​​​​​​​ /mnt/gfs2/gfs2_dir/newfile 文​​​​​​​件​​​​​​​启​​​​​​​用​​​​​​​了​​​​​​​数​​​​​​​据​​​​​​​日​​​​​​​志​​​​​​​功​​​​​​​能​​​​​​​,并​​​​​​​检​​​​​​​查​​​​​​​是​​​​​​​否​​​​​​​正​​​​​​​确​​​​​​​设​​​​​​​定​​​​​​​了​​​​​​​标​​​​​​​签​​​​​​​。​​​​​​​
[root@roth-01 ~]# chattr +j /mnt/gfs2/gfs2_dir/newfile
[root@roth-01 ~]# lsattr /mnt/gfs2/gfs2_dir
---------j--- /mnt/gfs2/gfs2_dir/newfile
以​​​​​​​下​​​​​​​命​​​​​​​令​​​​​​​禁​​​​​​​用​​​​​​​了​​​​​​​ /mnt/gfs2/gfs2_dir/newfile 文​​​​​​​件​​​​​​​中​​​​​​​的​​​​​​​数​​​​​​​据​​​​​​​日​​​​​​​志​​​​​​​,并​​​​​​​查​​​​​​​看​​​​​​​是​​​​​​​否​​​​​​​正​​​​​​​确​​​​​​​设​​​​​​​定​​​​​​​了​​​​​​​标​​​​​​​签​​​​​​​。​​​​​​​
[root@roth-01 ~]# chattr -j /mnt/gfs2/gfs2_dir/newfile
[root@roth-01 ~]# lsattr /mnt/gfs2/gfs2_dir
------------- /mnt/gfs2/gfs2_dir/newfile
您​​​​​​​还​​​​​​​可​​​​​​​以​​​​​​​使​​​​​​​用​​​​​​​ chattr 在​​​​​​​目​​​​​​​录​​​​​​​中​​​​​​​设​​​​​​​定​​​​​​​ jdata 标​​​​​​​签​​​​​​​。​​​​​​​当​​​​​​​您​​​​​​​为​​​​​​​某​​​​​​​个​​​​​​​目​​​​​​​录​​​​​​​设​​​​​​​定​​​​​​​此​​​​​​​标​​​​​​​签​​​​​​​时​​​​​​​,之​​​​​​​后​​​​​​​在​​​​​​​那​​​​​​​个​​​​​​​目​​​​​​​录​​​​​​​中​​​​​​​创​​​​​​​建​​​​​​​的​​​​​​​所​​​​​​​有​​​​​​​文​​​​​​​件​​​​​​​和​​​​​​​目​​​​​​​录​​​​​​​也​​​​​​​都​​​​​​​会​​​​​​​进​​​​​​​行​​​​​​​日​​​​​​​志​​​​​​​操​​​​​​​作​​​​​​​。​​​​​​​以​​​​​​​下​​​​​​​一​​​​​​​组​​​​​​​命​​​​​​​令​​​​​​​可​​​​​​​在​​​​​​​ gfs2_dir 目​​​​​​​录​​​​​​​中​​​​​​​设​​​​​​​定​​​​​​​ j 标​​​​​​​签​​​​​​​,然​​​​​​​后​​​​​​​查​​​​​​​看​​​​​​​是​​​​​​​否​​​​​​​正​​​​​​​确​​​​​​​设​​​​​​​定​​​​​​​了​​​​​​​该​​​​​​​标​​​​​​​签​​​​​​​。​​​​​​​此​​​​​​​后​​​​​​​,该​​​​​​​命​​​​​​​令​​​​​​​会​​​​​​​在​​​​​​​ /mnt/gfs2/gfs2_dir 目​​​​​​​录​​​​​​​中​​​​​​​创​​​​​​​建​​​​​​​一​​​​​​​个​​​​​​​名​​​​​​​为​​​​​​​ newfile 新​​​​​​​文​​​​​​​件​​​​​​​,然​​​​​​​后​​​​​​​查​​​​​​​看​​​​​​​是​​​​​​​否​​​​​​​将​​​​​​​为​​​​​​​该​​​​​​​文​​​​​​​件​​​​​​​设​​​​​​​定​​​​​​​了​​​​​​​ j 标​​​​​​​签​​​​​​​。​​​​​​​因​​​​​​​为​​​​​​​是​​​​​​​为​​​​​​​该​​​​​​​目​​​​​​​录​​​​​​​设​​​​​​​定​​​​​​​的​​​​​​​ j 标​​​​​​​签​​​​​​​,然​​​​​​​后​​​​​​​应​​​​​​​该​​​​​​​也​​​​​​​为​​​​​​​ newfile 启​​​​​​​用​​​​​​​日​​​​​​​志​​​​​​​操​​​​​​​作​​​​​​​。​​​​​​​
[root@roth-01 ~]# chattr -j /mnt/gfs2/gfs2_dir
[root@roth-01 ~]# lsattr /mnt/gfs2
---------j--- /mnt/gfs2/gfs2_dir
[root@roth-01 ~]# touch /mnt/gfs2/gfs2_dir/newfile
[root@roth-01 ~]# lsattr /mnt/gfs2/gfs2_dir
---------j--- /mnt/gfs2/gfs2_dir/newfile
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.