• Linux6


    1.为主机增加80G SCSI 接口硬盘
    [root@localhost ~]# fdisk -l /dev/sdd
    磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    2.划分三个各20G的主分区
    [root@localhost ~]# fdisk -l /dev/sdd
    磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    磁盘标签类型:dos
    磁盘标识符:0x7c41f75b
       设备 Boot      Start         End      Blocks   Id  System
    /dev/sdd1            2048    41945087    20971520   83  Linux
    /dev/sdd2        41945088    83888127    20971520   83  Linux
    /dev/sdd3        83888128   125831167    20971520   83  Linux
    3.将三个主分区转换为物理卷(pvcreate),扫描系统中的物理卷
    [root@localhost ~]# pvcreate /dev/sdd[123]
      Physical volume "/dev/sdd1" successfully created.
      Physical volume "/dev/sdd2" successfully created.
      Physical volume "/dev/sdd3" successfully created.
    [root@localhost ~]# pvscan
      PV /dev/sda2   VG centos          lvm2 [<39.00 GiB / 4.00 MiB free]
      PV /dev/sdd1                      lvm2 [20.00 GiB]
      PV /dev/sdd2                      lvm2 [20.00 GiB]
      PV /dev/sdd3                      lvm2 [20.00 GiB]
      Total: 4 [<99.00 GiB] / in use: 1 [<39.00 GiB] / in no VG: 3 [60.00 GiB]
    4.使用两个物理卷创建卷组,名字为myvg,查看卷组大小
    [root@localhost ~]# vgcreate myvg /dev/sdd[12]
      Volume group "myvg" successfully created
    5.创建逻辑卷mylv,大小为30G
    [root@localhost ~]# lvcreate -L 30G -n mylv myvg
      Logical volume "mylv" created.
    6.将逻辑卷格式化成xfs文件系统,并挂载到/data目录上,创建文件测试
    [root@localhost ~]# mkfs.xfs /dev/myvg/mylv
    meta-data=/dev/myvg/mylv         isize=512    agcount=4, agsize=1966080 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=1        finobt=0, sparse=0
    data     =                       bsize=4096   blocks=7864320, imaxpct=25
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
    log      =internal log           bsize=4096   blocks=3840, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    [root@localhost ~]# mkdir /data
    [root@localhost ~]# mount /dev/myvg/mylv /data/
    [root@localhost ~]# cd /data/
    [root@localhost data]# echo "myshiluojijuan" > test1.txt
    [root@localhost data]# ls -a
    .  ..  test1.txt
    7.增大逻辑卷到35G
    [root@localhost ~]# lvextend -L 35G /dev/myvg/mylv
      Size of logical volume myvg/mylv changed from 30.00 GiB (7680 extents) to 35.00 GiB (8960 extents).
      Logical volume myvg/mylv successfully resized.
    [root@localhost ~]# lvdisplay
      --- Logical volume ---
      LV Path                /dev/myvg/mylv
      LV Name                mylv
      VG Name                myvg
      LV UUID                2eyyFz-kYdm-ncle-3QMF-o9Il-w2bz-ImffYJ
      LV Write Access        read/write
      LV Creation host, time localhost.localdomain, 2019-08-02 15:23:19 +0800
      LV Status              available
      # open                 1
      LV Size                35.00 GiB
      Current LE             8960
      Segments               2
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     8192
      Block device           253:2
    8.编辑/etc/fstab文件挂载逻辑卷,并支持磁盘配额选项
    [root@localhost ~]# vi /etc/fstab
    /dev/myvg/mylv      /data                       xfs     defaults,usrquota,grpquota        0 0
    9.创建磁盘配额,crushlinux用户在/data目录下文件大小软限制为80M,硬限制为100M,
    crushlinux用户在/data目录下文件数量软限制为80个,硬限制为100个。
    [root@localhost ~]# umount /dev/myvg/mylv
    [root@localhost ~]# mkfs.ext4 /dev/myvg/mylv
    mke2fs 1.42.9 (28-Dec-2013)
    文件系统标签=
    OS type: Linux
    块大小=4096 (log=2)
    分块大小=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    2293760 inodes, 9175040 blocks
    458752 blocks (5.00%) reserved for the super user
    第一个数据块=0
    Maximum filesystem blocks=2157969408
    280 block groups
    32768 blocks per group, 32768 fragments per group
    8192 inodes per group
    Superblock backups stored on blocks:
     32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
     4096000, 7962624
    Allocating group tables: 完成                           
    正在写入inode表: 完成                           
    Creating journal (32768 blocks): 完成
    Writing superblocks and filesystem accounting information: 完成  
    [root@localhost ~]# mount /dev/myvg/mylv /data
    [root@localhost ~]# mount -o remount,usrquota,grpquota /data
    [root@localhost ~]# mount |grep /data/
    [root@localhost ~]# mount |grep /data
    /dev/mapper/myvg-mylv on /data type ext4 (rw,relatime,quota,usrquota,grpquota,data=ordered)
    [root@localhost ~]# quotacheck -avug
    quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown.
    quotacheck: Scanning /dev/mapper/myvg-mylv [/data] done
    quotacheck: Cannot stat old user quota file /data/aquota.user: 没有那个文件或目录. Usage will not be subtracted.
    quotacheck: Cannot stat old group quota file /data/aquota.group: 没有那个文件或目录. Usage will not be subtracted.
    quotacheck: Cannot stat old user quota file /data/aquota.user: 没有那个文件或目录. Usage will not be subtracted.
    quotacheck: Cannot stat old group quota file /data/aquota.group: 没有那个文件或目录. Usage will not be subtracted.
    quotacheck: Checked 2 directories and 0 files
    quotacheck: Old file not found.
    quotacheck: Old file not found.
    [root@localhost ~]# quotaon -avug
    /dev/mapper/myvg-mylv [/data]: group quotas turned on
    /dev/mapper/myvg-mylv [/data]: user quotas turned on
    [root@localhost ~]# useradd crushlinux
    [root@localhost ~]# edquota -u crushlinux
    Disk quotas for user crushlinux (uid 1001):
      Filesystem                   blocks       soft       hard     inodes     soft     hard
      /dev/mapper/myvg-mylv             0      80M         100M          0       80      100
    [root@localhost ~]# ll /data
    总用量 32
    -rw------- 1 root root  6144 8月   5 11:41 aquota.group
    -rw------- 1 root root  7168 8月   5 11:41 aquota.user
    drwx------ 2 root root 16384 8月   5 11:38 lost+found
    [root@localhost ~]# chmod -R 777
    chmod: "777" 后缺少操作数
    Try 'chmod --help' for more information.
    [root@localhost ~]# chmod -R 777 /data
    chmod: 更改"/data/aquota.group" 的权限: 不允许的操作
    chmod: 更改"/data/aquota.user" 的权限: 不允许的操作
    [root@localhost ~]# su crushlinux
    [crushlinux@localhost root]$ cd ~
     
     
    10.使用touch dd 命令在/data目录下测试
    [crushlinux@localhost ~]$ dd if=/dev/zero of=/data/ceshi bs=1M count=90M
    dm-2: warning, user block quota exceeded.
    dm-2: write failed, user block limit reached.
    dd: 写入"/data/ceshi" 出错: 超出磁盘限额
    记录了101+0 的读入
    记录了100+0 的写出
    104857600字节(105 MB)已复制,0.425959 秒,246 MB/秒
    [crushlinux@localhost data]$ touch  a{1..79}.txt
    [crushlinux@localhost data]$ ls
    a10.txt  a19.txt  a27.txt  a35.txt  a43.txt  a51.txt  a5.txt   a68.txt  a76.txt       lost+found
    a11.txt  a1.txt   a28.txt  a36.txt  a44.txt  a52.txt  a60.txt  a69.txt  a77.txt
    a12.txt  a20.txt  a29.txt  a37.txt  a45.txt  a53.txt  a61.txt  a6.txt   a78.txt
    a13.txt  a21.txt  a2.txt   a38.txt  a46.txt  a54.txt  a62.txt  a70.txt  a79.txt
    a14.txt  a22.txt  a30.txt  a39.txt  a47.txt  a55.txt  a63.txt  a71.txt  a7.txt
    a15.txt  a23.txt  a31.txt  a3.txt   a48.txt  a56.txt  a64.txt  a72.txt  a8.txt
    a16.txt  a24.txt  a32.txt  a40.txt  a49.txt  a57.txt  a65.txt  a73.txt  a9.txt
    a17.txt  a25.txt  a33.txt  a41.txt  a4.txt   a58.txt  a66.txt  a74.txt  aquota.group
    a18.txt  a26.txt  a34.txt  a42.txt  a50.txt  a59.txt  a67.txt  a75.txt  aquota.user
    [crushlinux@localhost data]$ touch  b{1..5}.txt
    dm-2: warning, user file quota exceeded.
    [crushlinux@localhost data]$ ls
    a10.txt  a19.txt  a27.txt  a35.txt  a43.txt  a51.txt  a5.txt   a68.txt  a76.txt       b1.txt
    a11.txt  a1.txt   a28.txt  a36.txt  a44.txt  a52.txt  a60.txt  a69.txt  a77.txt       b2.txt
    a12.txt  a20.txt  a29.txt  a37.txt  a45.txt  a53.txt  a61.txt  a6.txt   a78.txt       b3.txt
    a13.txt  a21.txt  a2.txt   a38.txt  a46.txt  a54.txt  a62.txt  a70.txt  a79.txt       b4.txt
    a14.txt  a22.txt  a30.txt  a39.txt  a47.txt  a55.txt  a63.txt  a71.txt  a7.txt        b5.txt
    a15.txt  a23.txt  a31.txt  a3.txt   a48.txt  a56.txt  a64.txt  a72.txt  a8.txt        lost+found
    a16.txt  a24.txt  a32.txt  a40.txt  a49.txt  a57.txt  a65.txt  a73.txt  a9.txt
    a17.txt  a25.txt  a33.txt  a41.txt  a4.txt   a58.txt  a66.txt  a74.txt  aquota.group
    a18.txt  a26.txt  a34.txt  a42.txt  a50.txt  a59.txt  a67.txt  a75.txt  aquota.user
    [crushlinux@localhost data]$ touch  c{1..20}.txt
    dm-2: write failed, user file limit reached.
    touch: 无法创建"c17.txt": 超出磁盘限额
    touch: 无法创建"c18.txt": 超出磁盘限额
    touch: 无法创建"c19.txt": 超出磁盘限额
    touch: 无法创建"c20.txt": 超出磁盘限额
    11.查看配额的使用情况:用户角度
    [root@localhost ~]# quota -uvs crushlinux
    Disk quotas for user crushlinux (uid 1001):
         Filesystem   space   quota   limit   grace   files   quota   limit   grace
    /dev/mapper/myvg-mylv
                         0K  81920K    100M             100*     80     100   6days
    12.查看配额的使用情况:文件系统角度
    [root@localhost ~]# repquota -auvs
    *** Report for user quotas on device /dev/mapper/myvg-mylv
    Block grace time: 7days; Inode grace time: 7days
                            Space limits                File limits
    User            used    soft    hard  grace    used  soft  hard  grace
    ----------------------------------------------------------------------
    root      --     20K      0K      0K              2     0     0      
    crushlinux -+      0K  81920K    100M            100    80   100  6days
    Statistics:
    Total blocks: 7
    Data blocks: 1
    Entries: 2
    Used average: 2.000000
  • 相关阅读:
    存储数据的大小端模式
    双链表插入 删除详解
    php_match/preg_match_all 默认有字符串长度限制
    百度编辑器:获取编辑器的内容
    phalcon: update修改数据却变成了insert插入数据
    MySQL按照汉字的拼音排序,mysql汉字排序
    [转载]Eclipse提示No java virtual machine
    lhgdialog: iframe页面里面的,确定,关闭、取消按钮的操作
    js树目录结构
    mysql:恢复mysql表结构
  • 原文地址:https://www.cnblogs.com/elin989898/p/11289065.html
Copyright © 2020-2023  润新知