bobbai 发表于 2018-5-11 11:21:09

抢先体验RedHat Enterprise Linux 7.0之XFS管理

  默认在rhel7中的文件系统格式是xfs,当然也可以创建ext3或者ext4,这里演示下xfs文件系统的简单管理。
  1.创建逻辑卷
//创建PV
# pvcreate /dev/sd{b,c,d}
Physical volume "/dev/sdb" successfully created
Physical volume "/dev/sdc" successfully created
Physical volume "/dev/sdd" successfully created
# pvs
PV         VG   FmtAttr PSizePFree
/dev/sda2rootvg lvm2 a--18.56g4.00m
/dev/sdb          lvm2 a--20.00g 20.00g
/dev/sdc          lvm2 a--20.00g 20.00g
/dev/sdd          lvm2 a--20.00g 20.00g
//创建VG
# vgcreate testvg /dev/sdb
Volume group "testvg" successfully created
# vgs
VG   #PV #LV #SN Attr   VSizeVFree
rootvg   1   2   0 wz--n- 18.56g4.00m
testvg   1   0   0 wz--n- 20.00g 20.00g
//创建LV
# lvcreate -n lv11 -L +5G testvg
Logical volume "lv11" created
# lvcreate -n lv12 -L +5G testvg
Logical volume "lv12" created  2.创建xfs文件系统
# mkfs.xfs /dev/testvg/lv11
meta-data=/dev/testvg/lv11       isize=256    agcount=4, agsize=327680 blks
=                     sectsz=512   attr=2, projid32bit=1
=                     crc=0
data   =                     bsize=4096   blocks=1310720, imaxpct=25
=                     sunit=0      swidth=0 blks
naming   =version 2            bsize=4096   ascii-ci=0
log      =internal log         bsize=4096   blocks=12800, version=2
=                     sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
# mkfs.xfs /dev/testvg/lv12
meta-data=/dev/testvg/lv12       isize=256    agcount=4, agsize=327680 blks
=                     sectsz=512   attr=2, projid32bit=1
=                     crc=0
data   =                     bsize=4096   blocks=1310720, imaxpct=25
=                     sunit=0      swidth=0 blks
naming   =version 2            bsize=4096   ascii-ci=0
log      =internal log         bsize=4096   blocks=12800, version=2
=                     sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0  3.挂在xfs文件系统
# mount /dev/testvg/lv11 /u01
# df -h
文件系统               容量已用可用 已用% 挂载点
/dev/mapper/rootvg-lv01   15G3.8G   11G   26% /
devtmpfs               927M   0927M    0% /dev
tmpfs                  934M   80K934M    1% /dev/shm
tmpfs                  934M2.6M931M    1% /run
tmpfs                  934M   0934M    0% /sys/fs/cgroup
/dev/sda1                484M106M379M   22% /boot
/dev/mapper/testvg-lv115.0G   33M5.0G    1% /u01  4.扩大xfs文件系统
# lvextend -L +1G /dev/testvg/lv11
Extending logical volume lv11 to 6.00 GiB
Logical volume lv11 successfully resized
# xfs_growfs /u01/
meta-data=/dev/mapper/testvg-lv11 isize=256    agcount=4, agsize=327680 blks
=                     sectsz=512   attr=2, projid32bit=1
=                     crc=0
data   =                     bsize=4096   blocks=1310720, imaxpct=25
=                     sunit=0      swidth=0 blks
naming   =version 2            bsize=4096   ascii-ci=0
log      =internal               bsize=4096   blocks=12800, version=2
=                     sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 1310720 to 1572864
# df -h
文件系统               容量已用可用 已用% 挂载点
/dev/mapper/rootvg-lv01   15G3.8G   11G   26% /
devtmpfs               927M   0927M    0% /dev
tmpfs                  934M   92K934M    1% /dev/shm
tmpfs                  934M2.8M931M    1% /run
tmpfs                  934M   0934M    0% /sys/fs/cgroup
/dev/sda1                484M106M379M   22% /boot
/dev/mapper/testvg-lv116.0G   33M6.0G    1% /u01  5.备份xfs文件系统

# xfsdump -l 0 -f /u02/u01.dmp /dev/testvg/lv11
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.3 (dump format 3.0) - type ^C for status and control
============================= dump label dialog ==============================
please enter label for this dump session (timeout in 300 sec)
-> Full_bkp
session label entered: "Full_bkp"
--------------------------------- end dialog ---------------------------------
xfsdump: level 0 dump of rhel7-xzxj-edu-cn:/u01
xfsdump: dump date: Fri Jan3 22:21:05 2014
xfsdump: session id: a389be53-fc2c-4a22-92d0-cd0c1fdbb06e
xfsdump: session label: "Full_bkp"
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: 196928 bytes
xfsdump: /var/lib/xfsdump/inventory created
============================= media label dialog =============================
please enter label for media in drive 0 (timeout in 300 sec)
-> Test
media label entered: "Test"
--------------------------------- 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 182304 bytes
xfsdump: dump size (non-dir files) : 145888 bytes
xfsdump: dump complete: 15 seconds elapsed
xfsdump: Dump Summary:
xfsdump:   stream 0 /u02/u01.dmp OK (success)
xfsdump: Dump Status: SUCCESS  6.恢复xfs文件系统备份
# cd /u01/
# ls
asound.conf            e2fsck.conf   krb5.conf       man_db.conf    oddjobd.conf      resolv.conf   sysctl.conf
autofs_ldap_auth.conffprintd.confksmtuned.conf   mke2fs.conf    opensc.conf       rsyncd.conf   updatedb.conf
brltty.conf            fuse.conf   ld.so.conf      mtools.conf    pbm2ppa.conf      rsyslog.conf    usb_modeswitch.conf
chrony.conf            hba.conf      libaudit.conf   nfsmount.confpnm2ppa.conf      sestatus.conf   vconsole.conf
colord.conf            host.conf   libuser.conf    nsswitch.confprelink.conf      sos.conf      wvdial.conf
dnsmasq.conf         idmapd.conf   locale.conf   ntp.conf       radvd.conf      sudo.conf       yum.conf
dracut.conf            kdump.conf    logrotate.confnumad.conf   request-key.confsudo-ldap.conf
# rm -rf *
# ls
#
# xfsrestore -f /u02/u01.dmp /u01
xfsrestore: using file dump (drive_simple) strategy
xfsrestore: version 3.1.3 (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: rhel7-xzxj-edu-cn
xfsrestore: mount point: /u01
xfsrestore: volume: /dev/mapper/testvg-lv11
xfsrestore: session time: Fri Jan3 22:21:05 2014
xfsrestore: level: 0
xfsrestore: session label: "Full_bkp"
xfsrestore: media label: "Test"
xfsrestore: file system id: cc858c9e-d5fb-4812-b99a-38f2779e047f
xfsrestore: session id: a389be53-fc2c-4a22-92d0-cd0c1fdbb06e
xfsrestore: media id: b62663cd-386c-485c-bb76-5acdbe98fc81
xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: 1 directories and 48 entries processed
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: restore complete: 0 seconds elapsed
xfsrestore: Restore Summary:
xfsrestore:   stream 0 /u02/u01.dmp OK (success)
xfsrestore: Restore Status: SUCCESS
# ls /u01
asound.conf            e2fsck.conf   krb5.conf       man_db.conf    oddjobd.conf      resolv.conf   sysctl.conf
autofs_ldap_auth.conffprintd.confksmtuned.conf   mke2fs.conf    opensc.conf       rsyncd.conf   updatedb.conf
brltty.conf            fuse.conf   ld.so.conf      mtools.conf    pbm2ppa.conf      rsyslog.conf    usb_modeswitch.conf
chrony.conf            hba.conf      libaudit.conf   nfsmount.confpnm2ppa.conf      sestatus.conf   vconsole.conf
colord.conf            host.conf   libuser.conf    nsswitch.confprelink.conf      sos.conf      wvdial.conf
dnsmasq.conf         idmapd.conf   locale.conf   ntp.conf       radvd.conf      sudo.conf       yum.conf
dracut.conf            kdump.conf    logrotate.confnumad.conf   request-key.confsudo-ldap.conf  参考文献:

  1.Storage Administration Guide
  2.XFS User Guide
  
页: [1]
查看完整版本: 抢先体验RedHat Enterprise Linux 7.0之XFS管理