zoukankan      html  css  js  c++  java
  • XFS文件系统

    XFS WIKI介绍

    XFS is a high-performance 64-bit journaling file system created by Silicon Graphics, Inc (SGI) in 1993.[6] It was the default file system in SGI's IRIX operating system starting with its version 5.3. XFS was ported to the Linux kernel in 2001; as of June 2014, XFS is supported by most Linux distributions, some of which use it as the default file system.

    XFS excels in the execution of parallel input/output (I/O) operations due to its design, which is based on allocation groups (a type of subdivision of the physical volumes in which XFS is used- also shortened to AGs). Because of this, XFS enables extreme scalability of I/O threads, file system bandwidth, and size of files and of the file system itself when spanning multiple physical storage devices. XFS ensures the consistency of data by employing metadata journaling and supporting write barriers. Space allocation is performed via extents with data structures stored in B+ trees, improving the overall performance of the file system, especially when handling large files. Delayed allocation assists in the prevention of file system fragmentation; online defragmentation is also supported. A feature unique to XFS is the pre-allocation of I/O bandwidth at a pre-determined rate; this is suitable for many real-time applications. However, this feature was supported only on IRIX, and only with specialized hardware.

    A notable XFS user, NASA Advanced Supercomputing Division, takes advantage of these capabilities deploying two 300+ terabyte XFS filesystems on two SGI Altix archival storage servers, each of which is directly attached to multiple Fibre Channel disk arrays.[7]

    XFS优缺点

    XFS是高性能文件系统,由于它的高性能,XFS成为了许多企业级系统的首选,特别是有大量数据,需要结构化伸缩性和稳定性的。例如,RHEL/CentOS 7 和Oracle Linux将XFS作为默认文件系统,SUSE/openSUSE已经为XFS做了长期支持。

    XFS有许多独特的性能提升功能使他从众多文件系统中脱颖而出,像可伸缩/并行 IO,元数据日志,热碎片整理,IO 暂停/恢复,延迟分配等。

    XFS 文件系统有一些缺陷,例如它不能压缩,删除大量文件时性能低下

    XFS工具集安装

    yum install xfsprogs
    

    Linux 7以上版本,系统将XFS作为默认文件系统。

    [root@localhost ~]# lsb_release -d
    Description:    CentOS Linux release 7.5.1804 (Core)
    

    我在虚拟层划分了一块磁盘500G,/dev/sdb给与虚拟机。

    XFS文件系统装载

    查看已经划分好的/dev/sdb磁盘

    [root@localhost ~]# lsblk
    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    fd0      2:0    1    4K  0 disk 
    sda      8:0    0   40G  0 disk 
    ├─sda1   8:1    0  200M  0 part /boot
    ├─sda2   8:2    0 29.8G  0 part /
    └─sda3   8:3    0   10G  0 part [SWAP]
    sdb      8:16   0  500G  0 disk /data
    sr0     11:0    1 1024M  0 rom
    

    xfx文件系统格式化

    [root@mylnx008 ~]# mkfs.xfs -f  /dev/sdb
    

    挂载XFS文件系统

    [root@mylnx008 ~]# mkdir /data
    [root@mylnx008 ~]# mount  -t  xfs  /dev/sdb  /data
    [root@localhost ~]# df -h
    文件系统        容量  已用  可用 已用% 挂载点
    /dev/sda2        30G  1.4G   27G    5% /
    devtmpfs        1.9G     0  1.9G    0% /dev
    tmpfs           1.9G     0  1.9G    0% /dev/shm
    tmpfs           1.9G  8.8M  1.9G    1% /run
    tmpfs           1.9G     0  1.9G    0% /sys/fs/cgroup
    /dev/sda1       190M  139M   38M   79% /boot
    tmpfs           380M     0  380M    0% /run/user/0
    /dev/sdb        500G   33M  500G    1% /data
    

    配置/etc/fstab文件

    [root@localhost ~]# cat /etc/fstab 
    
    #
    # /etc/fstab
    # Created by anaconda on Thu Jun 28 13:45:55 2018
    #
    # Accessible filesystems, by reference, are maintained under '/dev/disk'
    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
    #
    UUID=f9c28539-1313-4a49-a3ed-475f43dd6bad /                       ext4    defaults        1 1
    UUID=cabeff84-ec5d-45d0-b74b-b19499a8608f /boot                   ext4    defaults        1 2
    UUID=8a13be64-ef16-4acd-9988-38b9df9b8273 swap                    swap    defaults        0 0
    /dev/sdb                                  /data                   xfs     defaults        0 0
    

    XFS扩容

    由于XFS可以横向扩展.
    在虚拟层/dev/sdb扩展到2TB。

    查看命令

    [root@localhost ~]# xfs_info /data
    meta-data=/dev/sdb               isize=512    agcount=8, agsize=32768000 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=1        finobt=0 spinodes=0
    data     =                       bsize=4096   blocks=262144000, imaxpct=25
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
    log      =internal               bsize=4096   blocks=64000, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    

    可以看到/data目录的挂载点是/dev/sdb

    在线动态扩展

    [root@localhost ~]# xfs_growfs /data
    meta-data=/dev/sdb               isize=512    agcount=8, agsize=32768000 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=1        finobt=0 spinodes=0
    data     =                       bsize=4096   blocks=262144000, imaxpct=25
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
    log      =internal               bsize=4096   blocks=64000, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    data blocks changed from 262144000 to 536870912
    [root@localhost ~]# df -h
    文件系统        容量  已用  可用 已用% 挂载点
    /dev/sda2        30G  1.4G   27G    5% /
    devtmpfs        1.9G     0  1.9G    0% /dev
    tmpfs           1.9G     0  1.9G    0% /dev/shm
    tmpfs           1.9G  8.8M  1.9G    1% /run
    tmpfs           1.9G     0  1.9G    0% /sys/fs/cgroup
    /dev/sda1       190M  139M   38M   79% /boot
    /dev/sdb        2.0T   33M  2.0T    1% /data
    tmpfs           380M     0  380M    0% /run/user/0
    

    可以看到/data目录扩展到2TB了。

  • 相关阅读:
    ubuntu下如何卸载nvidia显卡驱动?
    如何加速编译linux内核模块?
    ubuntu下编译linux内核之前需要做哪些准备?
    ubuntu最近升级到最新的linux内核后,网络无法使用怎么办?
    ubuntu下如何高速下载?
    linux配置java环境变量(详细)
    Javascript 中 == 和 === 区别是什么?
    mybatis 根据多个id查询数据 foreach标签
    mybatis多参数查询问题:org.apache.ibatis.binding.BindingException: Parameter 'name' not found. Available par
    Java Array二维数组使用
  • 原文地址:https://www.cnblogs.com/zhangshengdong/p/12049984.html
Copyright © 2011-2022 走看看