上QQ阅读APP看书,第一时间看更新
4.3 XFS文件系统管理
XFS文件系统是硅谷图形公司(Silicon Graphics Inc.,SGI)开发的用于IRIX(一个UNIX操作系统)的文件系统,后将XFS移植到Linux操作系统上。XFS是高级日志文件系统,其特点极具伸缩性,同时也很健壮。
2000年5月XFS通过GNU通用公共许可证移植到Linux系统上,通过十多年的不断修改已经成为一款非常成熟的文件系统。在多项针对XFS的性能测试上,XFS都取得了不俗的成绩,高并发环境下甚至已经超过ext4。
4.3.1 XFS文件系统备份和恢复
XFS文件系统提供了整个分区备份的工具xfsdump供用户使用。用户可以在不借助第三方软件的情况下对XFS文件系统上的数据实施备份,备份过程如示例4-7所示。
【示例4-7】
#利用xfsdump备份挂载点/sdc2对应的分区 [root@localhost ~]# xfsdump -f /backup/dump_sdc2 /sdc2 xfsdump: using file dump (drive_simple) strategy xfsdump: version 3.1.4 (dump format 3.0) - type ^C for status and control ============================= dump label dialog ============================== #输入dump会话标签 please enter label for this dump session (timeout in 300 sec) -> dump_sdc2 session label entered: "dump_sdc2" --------------------------------- end dialog --------------------------------- xfsdump: level 0 dump of localhost.localdomain:/sdc2 xfsdump: dump date: Sun Mar 12 20:14:40 2019 xfsdump: session id: 7315a7da-4bbe-4745-b3db-119371e22a40 xfsdump: session label: "dump_sdc2" xfsdump: ino map phase 1: constructing initial dump list xfsdump: ino map phase 2: skipping (no pruning necessary) xfsdump: ino map phase 3: skipping (only one dump stream) xfsdump: ino map construction complete xfsdump: estimated dump size: 23680 bytes ============================= media label dialog ============================= #输入媒体标签 please enter label for media in drive 0 (timeout in 300 sec) -> sdc2 media label entered: "sdc2" --------------------------------- end dialog --------------------------------- xfsdump: creating dump session media file 0 (media 0, file 0) xfsdump: dumping ino map xfsdump: dumping directories xfsdump: dumping non-directory files xfsdump: ending media file xfsdump: media file size 27064 bytes xfsdump: dump size (non-dir files) : 0 bytes xfsdump: dump complete: 39 seconds elapsed xfsdump: Dump Summary: xfsdump: stream 0 /backup/dump_sdc2 OK (success) xfsdump: Dump Status: SUCCESS #恢复过程 [root@localhost ~]# rm -rf /sdc/* [root@localhost ~]# xfsrestore -f /backup/dump_sdc2 /sdc2 xfsrestore: using file dump (drive_simple) strategy xfsrestore: version 3.1.4 (dump format 3.0) - type ^C for status and control xfsrestore: searching media for dump xfsrestore: examining media file 0 xfsrestore: dump description: xfsrestore: hostname: localhost.localdomain xfsrestore: mount point: /sdc2 xfsrestore: volume: /dev/sdc2 xfsrestore: session time: Sun Mar 12 20:14:40 2019 xfsrestore: level: 0 xfsrestore: session label: "dump_sdc2" xfsrestore: media label: "sdc2" xfsrestore: file system id: 711cbbbe-223b-4622-b13a-41e61acaa9db #部分显示省略 …… xfsrestore: restore complete: 0 seconds elapsed xfsrestore: Restore Summary: xfsrestore: stream 0 /backup/dump_sdc2 OK (success) xfsrestore: Restore Status: SUCCESS [root@localhost ~]# ls /sdc2 #结果省略
在示例4-7中展示了如何使用xfsdump备份整个分区,除此之外,xfsdump还可以备份目录,此处不再介绍,读者可以阅读相关文档。
4.3.2 检查XFS文件系统
同Linux系统中的其他文件系统一样,为确保文件系统能正常使用,XFS也提供了用于检查和修复文件系统的工具。RHEL 8中检查和修复文件系统的工具主要是xfs_repair,其使用方法如示例4-8所示。
【示例4-8】