Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

3.8. 資​​​​​​​料​​​​​​​記​​​​​​​錄​​​​​​​

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() 時​​​​​​​間​​​​​​​降​​​​​​​低​​​​​​​,尤​​​​​​​其​​​​​​​是​​​​​​​小​​​​​​​檔​​​​​​​案​​​​​​​;這​​​​​​​是​​​​​​​因​​​​​​​為​​​​​​​除​​​​​​​了​​​​​​​ metadata 之​​​​​​​外​​​​​​​,檔​​​​​​​案​​​​​​​資​​​​​​​料​​​​​​​也​​​​​​​會​​​​​​​被​​​​​​​紀​​​​​​​錄​​​​​​​到​​​​​​​日​​​​​​​誌​​​​​​​中​​​​​​​。​​​​​​​資​​​​​​​料​​​​​​​安​​​​​​​全​​​​​​​地​​​​​​​紀​​​​​​​錄​​​​​​​到​​​​​​​日​​​​​​​誌​​​​​​​後​​​​​​​, fsync() 會​​​​​​​回​​​​​​​傳​​​​​​​,這​​​​​​​樣​​​​​​​會​​​​​​​比​​​​​​​把​​​​​​​檔​​​​​​​案​​​​​​​資​​​​​​​料​​​​​​​寫​​​​​​​入​​​​​​​主​​​​​​​檔​​​​​​​案​​​​​​​系​​​​​​​統​​​​​​​要​​​​​​​來​​​​​​​得​​​​​​​快​​​​​​​。​​​​​​​
依​​​​​​​賴​​​​​​​ fsync() 來​​​​​​​同​​​​​​​步​​​​​​​檔​​​​​​​案​​​​​​​資​​​​​​​料​​​​​​​的​​​​​​​應​​​​​​​用​​​​​​​程​​​​​​​式​​​​​​​,會​​​​​​​因​​​​​​​為​​​​​​​使​​​​​​​用​​​​​​​資​​​​​​​料​​​​​​​日​​​​​​​誌​​​​​​​功​​​​​​​能​​​​​​​,而​​​​​​​改​​​​​​​善​​​​​​​效​​​​​​​能​​​​​​​。​​​​​​​資​​​​​​​料​​​​​​​日​​​​​​​誌​​​​​​​可​​​​​​​以​​​​​​​在​​​​​​​任​​​​​​​何​​​​​​​已​​​​​​​標​​​​​​​示​​​​​​​旗​​​​​​​標​​​​​​​的​​​​​​​目​​​​​​​錄​​​​​​​(及​​​​​​​其​​​​​​​子​​​​​​​目​​​​​​​錄​​​​​​​)中​​​​​​​,自​​​​​​​動​​​​​​​啟​​​​​​​用​​​​​​​。​​​​​​​長​​​​​​​度​​​​​​​為​​​​​​​零​​​​​​​的​​​​​​​現​​​​​​​有​​​​​​​檔​​​​​​​案​​​​​​​,也​​​​​​​可​​​​​​​以​​​​​​​啟​​​​​​​用​​​​​​​或​​​​​​​停​​​​​​​用​​​​​​​資​​​​​​​料​​​​​​​日​​​​​​​誌​​​​​​​功​​​​​​​能​​​​​​​。​​​​​​​
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.8.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 指​​​​​​​令​​​​​​​來​​​​​​​設​​​​​​​定​​​​​​​目​​​​​​​錄​​​​​​​的​​​​​​​ j 旗​​​​​​​標​​​​​​​。​​​​​​​當​​​​​​​您​​​​​​​為​​​​​​​目​​​​​​​錄​​​​​​​設​​​​​​​定​​​​​​​這​​​​​​​個​​​​​​​旗​​​​​​​標​​​​​​​時​​​​​​​,所​​​​​​​有​​​​​​​在​​​​​​​這​​​​​​​目​​​​​​​錄​​​​​​​中​​​​​​​建​​​​​​​立​​​​​​​的​​​​​​​檔​​​​​​​案​​​​​​​與​​​​​​​目​​​​​​​錄​​​​​​​都​​​​​​​會​​​​​​​啟​​​​​​​用​​​​​​​日​​​​​​​誌​​​​​​​功​​​​​​​能​​​​​​​。​​​​​​​以​​​​​​​下​​​​​​​指​​​​​​​令​​​​​​​集​​​​​​​會​​​​​​​設​​​​​​​定​​​​​​​ 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