centos7/rhel7的与众不同系列(3)——如何配置XFS

XFS是扩展性高、高性能的文件系统。也是rhel7/centos7的默认文件系统。
XFS支持metadata journaling,这使其能从crash中更快速的恢复。
它也支持在挂载和活动的状态下进行碎片整理和扩容。
通过延迟分配,XFS 赢得了许多机会来优化写性能。
可通过工具xfsdump和xfsrestore来备份和恢复xfs文件系统,
xfsdump可使用dump级别来完成增量备份,还可通过size,subtree,inode flags来排除文件。
也支持user、group、project配额。

下面将介绍如何创建xfs文件系统,分配配额以及对其扩容:
###############################################################################
将/dev/sdb分区(2G),并启动LVM功能

[[email protected] zhongq]#parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type ‘help‘ to view a list of commands.
(parted) mkpart primary 4 2048
(parted) set 1 lvm on
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      4194kB  2048MB  2044MB               primary  lvm

###############################################################################
创建PV

[[email protected] zhongq]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created

[[email protected] zhongq]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               24.51 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              6274
  Free PE               0
  Allocated PE          6274
  PV UUID               9hp8U7-IJM6-bwbP-G9Vn-IVuJ-yvE8-AkFjcB

  "/dev/sdb1" is a new physical volume of "1.90 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name
  PV Size               1.90 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               bu7yIH-1440-BPy1-APG2-FpvX-ejLS-2MIlA8

###############################################################################
将/dev/sdb1分配到名为xfsgroup00的VG

[[email protected] zhongq]# vgcreate  xfsgroup00 /dev/sdb1
 Volume group "xfsgroup00" successfully created
[[email protected] zhongq]# vgdisplay
 --- Volume group ---
  VG Name               centos
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               24.51 GiB
  PE Size               4.00 MiB
  Total PE              6274
  Alloc PE / Size       6274 / 24.51 GiB
  Free  PE / Size       0 / 0
  VG UUID               T3Ryyg-R0rn-2i5r-7L5o-AZKG-yFkh-CDzhKm

  --- Volume group ---
  VG Name               xfsgroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1.90 GiB
  PE Size               4.00 MiB
  Total PE              487
  Alloc PE / Size       0 / 0
  Free  PE / Size       487 / 1.90 GiB
  VG UUID               ejuwcc-sVES-MWWB-3Mup-n1wB-Kd0g-u7jm0H

###############################################################################
使用命令lvcreate来创建xfsgroup00组大小为1G的名为xfsdata的LV

[[email protected] zhongq]# lvcreate -L 1024M -n xfsdata xfsgroup00
WARNING: xfs signature detected on /dev/xfsgroup00/xfsdata at offset 0. Wipe it? [y/n] y
  Wiping xfs signature on /dev/xfsgroup00/xfsdata.
  Logical volume "xfsdata" created
[[email protected] zhongq]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                EnW3at-KlFG-XGaQ-DOoH-cGPP-8pSf-teSVbh
  LV Write Access        read/write
  LV Creation host, time localhost, 2014-08-18 20:15:25 +0800
  LV Status              available
  # open                 2
  LV Size                2.03 GiB
  Current LE             520
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                zmZGkv-Ln4W-B8AY-oDnD-BEk2-6VWL-L0cZOv
  LV Write Access        read/write
  LV Creation host, time localhost, 2014-08-18 20:15:26 +0800
  LV Status              available
  # open                 1
  LV Size                22.48 GiB
  Current LE             5754
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/xfsgroup00/xfsdata
  LV Name                xfsdata
  VG Name                xfsgroup00
  LV UUID                O4yvoY-XGcD-0zPm-eilR-3JJP-updU-rRCSlJ
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2014-09-23 15:50:19 +0800
  LV Status              available
  # open                 0
  LV Size                1.00 GiB
  Current LE             256
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:3

###############################################################################
格式化分区为xfs文件系统。
注意:xfs被创建后,其size将无法缩小,但可以通过xfs_growfs来增大

[[email protected] zhongq]# mkfs.xfs /dev/xfsgroup00/xfsdata
meta-data=/dev/xfsgroup00/xfsdata isize=256    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

###############################################################################
挂载xfs系统分区到指定目录,并通过参数uquota,gquota开启文件系统配额。

[[email protected] zhongq]# mkdir /xfsdata
[[email protected] zhongq]# mount -o uquota,gquota /dev/xfsgroup00/xfsdata /xfsdata
[[email protected] zhongq]# chmod 777 /xfsdata
[[email protected] zhongq]# mount|grep xfsdata
/dev/mapper/xfsgroup00-xfsdata on /xfsdata type xfs (rw,relatime,attr2,inode64,usrquota,grpquota)

###############################################################################
使用xfs_quota命令来查看配额信息以及为用户和目录分配配额,并验证配额限制是否生效。

[[email protected] zhongq]# xfs_quota -x -c ‘report‘ /xfsdata
User quota on /xfsdata (/dev/mapper/xfsgroup00-xfsdata)
                               Blocks
User ID          Used       Soft       Hard    Warn/Grace
---------- --------------------------------------------------
root                0          0          0     00 [--------]

Group quota on /xfsdata (/dev/mapper/xfsgroup00-xfsdata)
                               Blocks
Group ID         Used       Soft       Hard    Warn/Grace
---------- --------------------------------------------------
root                0          0          0     00 [--------]

[[email protected] zhongq]# xfs_quota -x -c ‘limit bsoft=100M bhard=120M zhongq‘ /xfsdata
[[email protected] zhongq]#xfs_quota -x -c ‘report‘ /xfsdata
User quota on /xfsdata (/dev/mapper/xfsgroup00-xfsdata)
                               Blocks
User ID          Used       Soft       Hard    Warn/Grace
---------- --------------------------------------------------
root                0          0          0     00 [--------]
zhongq              0     102400     122880     00 [--------]

Group quota on /xfsdata (/dev/mapper/xfsgroup00-xfsdata)
                               Blocks
Group ID         Used       Soft       Hard    Warn/Grace
---------- --------------------------------------------------
root                0          0          0     00 [--------]

[[email protected] zhongq]# su zhongq
[[email protected] ~]$ dd if=/dev/zero of=/xfsdata/zq00 bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 28.9833 s, 3.6 MB/s
[[email protected] ~]$ dd if=/dev/zero of=/xfsdata/zq01 bs=1M count=100
dd: error writing ‘/xfsdata/zq01’: Disk quota exceeded
21+0 records in
20+0 records out
20971520 bytes (21 MB) copied, 4.18921 s, 5.0 MB/s

[[email protected] ~]$ exit

[[email protected] zhongq]# xfs_quota
xfs_quota> help
df [-bir] [-hn] [-f file] -- show free and used counts for blocks and inodes
help [command] -- help for one or all commands
print -- list known mount points and projects
quit -- exit the program
quota [-bir] [-gpu] [-hnNv] [-f file] [id|name]... -- show usage and limits

Use ‘help commandname‘ for extended help.
xfs_quota> print
Filesystem          Pathname
/                   /dev/mapper/centos-root
/boot               /dev/sda1
/var/lib/docker     /dev/mapper/centos-root
/xfsdata            /dev/mapper/xfsgroup00-xfsdata (uquota, gquota)
xfs_quota> quota -u zhongq
Disk quotas for User zhongq (1000)
Filesystem                        Blocks      Quota      Limit  Warn/Time      Mounted on
/dev/mapper/xfsgroup00-xfsdata    122880     102400     122880   00  [6 days]   /xfsdata

###############################################################################
先使用命令lvextend将LV扩展为1.5G(初始容量是1G),然后使用命令xfs_growfs来对xfs文件系统扩容(这里以block计数)

[[email protected] zhongq]# lvextend -L 1.5G /dev/xfsgroup00/xfsdata
  Extending logical volume xfsdata to 1.50 GiB
  Logical volume xfsdata successfully resized

[[email protected] zhongq]# xfs_growfs /dev/xfsgroup00/xfsdata -D 393216
meta-data=/dev/mapper/xfsgroup00-xfsdata isize=256    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 262144 to 393216

[[email protected] zhongq]# df -h|grep xfsdata
/dev/mapper/xfsgroup00-xfsdata  1.5G  153M  1.4G  10% /xfsdata
时间: 2024-10-17 15:30:03

centos7/rhel7的与众不同系列(3)——如何配置XFS的相关文章

centos7/rhel7的与众不同系列(2)——如何配置vncserver

1. 以root角色运行以下命令来安装TigerVNC server     yum install tigervnc-server     也可以同时安装vnc client     yum install vnc 2. 配置VNC Server  2.1 创建一个新的配置文件,我这里是开启3号窗口,方法如下:     cp /lib/systemd/system/[email protected] /lib/systemd/system/[email protected]:3.service

CentOS7/RHEL7 systemd详解

CentOS7/RHEL7 systemd详解 目录1. 为什么是systemd(1) 关于Linux服务管理(2) SysV init的优缺点(3) UpStart的改进(4) systemd的诞生(5)为什么systemd能做到启动很快2. SysV init介绍(1) 什么是SystemV(2)SysV init的运行级别(3)SysV init运行顺序(4)SysV init和系统关闭(5)SysV init的管理和控制功能3. systemd的特性(1)systemd解决了那些问题?(

Linux CentOS7/RHEL7关闭ctrl+alt+delete功能键

        这是本人测试的经过,纯粹记录来看看,最终解决方法在最后面,中间讲的是遇到的一些坑,可以略过不看!!        本人操作经验,转载请表明出处:http://www.cnblogs.com/huangjc/p/4536620.html Linux默认允许任何人按下Ctrl+Alt+Del来重启系统.但是在生产环境中,应该停用按下Ctrl-Alt-Del 重启系统的功能. 会linux的技术牛们都知道前面的centos版本都是在/etc/inittab中配置,而centos7/RH

CentOS7/RHEL7 pacemaker+corosync高可用集群搭建

目录 一.集群信息... 4 二.集群搭建... 4 1.制作软件源... 4 2.主机基础配置... 5 3.集群基础环境准备... 7 4.集群资源准备... 9 5.资源配置... 11 6.constraint配置... 12 7.stonith配置... 13 8.集群功能验证... 14 三.集群常用命令及作用... 17 1.验证群集安装... 17 2.查看群集资源... 17 3.使用群集脚本... 17 4.STONITH 设备操作... 17 5.查看群集配置... 17

centos7/rhel7下安装redis4.0集群

Redis从3.0版本开始支持集群! 集群一般由多个节点组成,节点数量至少6个才能保证组成完整高可用的集群. 每个节点需要开启配置文件中的cluster-enabled yes,让Redis运行在集群模式下. 测试环境: 资源有限,这里使用3台虚拟机模拟6个节点(用端口区分),每台虚机2个节点,如下图: 注:Redis默认端口:6379,这里方便起见,设定从7001~7006来区分6个节点. 操作步骤: Redis下载官网:https://redis.io/ 1. 节点准备 每台机器都先编译安装

centos7的selinux的原理及相关配置

centos7的selinux的原理及相关配置 SELinux的全称是Security Enhanced Linux, 就是安全加强的Linux.在SELinux之前,root账号能够任意的访问所有文档和服务:如果某个文件设为777,那么任何用户都可以访问甚至删除:这种方式称为DAC(主动访问机制),很不安全. DAC 自主访问控制: 用户根据自己的文件权限来决定对文件的操作,也就是依据文件的own,group,other/r,w,x权限进行限制.Root有最高权限无法限制.r,w,x权限划分太

Spartan6系列之芯片配置模式详解

1.   配置概述 Spartan6系列FPGA通过把应用程序数据导入芯片内部存储器完成芯片的配置.Spart-6 FPGA可以自己从外部非易失性存储器导入编程数据,或者通过外界的微处理器.DSP等对其进行编程.对以上任何一种情况,都有串行配置和并行配置之分,串行配置可以减少芯片对引脚的要求,并行配置对8bit/16bit Flash或者微处理器来说更合适. 因为Xilinx的FPGA器件的配置数据存储在CMOS 配置锁存器内(CCL),因此Spartan6 FPGA器件上电后必须重新配置.Sp

[Java系列1]Eclipse配置,常用插件

java可视化编程-eclipse安装windowbuilder插件 http://blog.csdn.net/jason0539/article/details/21219043 [Java系列1]Eclipse配置,常用插件,码迷,mamicode.com

Centos7+Nginx通过windows CA颁发及配置SSL服务

近期在学习Linux的相关知识,作为一个运维工程师所必备的知识点,一个web服务尤其运行在互联网上的很容易攻击,所以为了保证安全最起码的需要对web服务配置SSL,这样能提高一定的安全性,所以我们今天介绍,Centos7+Nginx通过windows CA颁发及配置SSL服务,当然如果是生成环境的话,一般都会申请第三方证书,比如沃通等第三方证书颁发机构,今天我们主要使用的是内部的windows CA服务为nginx颁发证书,当然也可以使用Nginx的自签名证书,但是那样每次访问都会有相关的警告