|
默认在rhel7中的文件系统格式是xfs,当然也可以创建ext3或者ext4,这里演示下xfs文件系统的简单管理。1.创建逻辑卷
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| //创建PV
[iyunv@rhel7 ~]# pvcreate /dev/sd{b,c,d}
Physical volume "/dev/sdb" successfully created
Physical volume "/dev/sdc" successfully created
Physical volume "/dev/sdd" successfully created
[iyunv@rhel7 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 rootvg lvm2 a-- 18.56g 4.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
[iyunv@rhel7-xzxj-edu-cn ~]# vgcreate testvg /dev/sdb
Volume group "testvg" successfully created
[iyunv@rhel7-xzxj-edu-cn ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rootvg 1 2 0 wz--n- 18.56g 4.00m
testvg 1 0 0 wz--n- 20.00g 20.00g
//创建LV
[iyunv@rhel7-xzxj-edu-cn ~]# lvcreate -n lv11 -L +5G testvg
Logical volume "lv11" created
[iyunv@rhel7-xzxj-edu-cn ~]# lvcreate -n lv12 -L +5G testvg
Logical volume "lv12" created
|
2.创建xfs文件系统
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| [iyunv@rhel7-xzxj-edu-cn ~]# 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
[iyunv@rhel7-xzxj-edu-cn ~]# 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文件系统
1
2
3
4
5
6
7
8
9
10
| [iyunv@rhel7-xzxj-edu-cn ~]# mount /dev/testvg/lv11 /u01
[iyunv@rhel7-xzxj-edu-cn ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/rootvg-lv01 15G 3.8G 11G 26% /
devtmpfs 927M 0 927M 0% /dev
tmpfs 934M 80K 934M 1% /dev/shm
tmpfs 934M 2.6M 931M 1% /run
tmpfs 934M 0 934M 0% /sys/fs/cgroup
/dev/sda1 484M 106M 379M 22% /boot
/dev/mapper/testvg-lv11 5.0G 33M 5.0G 1% /u01
|
4.扩大xfs文件系统
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [iyunv@rhel7 ~]# lvextend -L +1G /dev/testvg/lv11
Extending logical volume lv11 to 6.00 GiB
Logical volume lv11 successfully resized
[iyunv@rhel7 ~]# 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
[iyunv@rhel7 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/rootvg-lv01 15G 3.8G 11G 26% /
devtmpfs 927M 0 927M 0% /dev
tmpfs 934M 92K 934M 1% /dev/shm
tmpfs 934M 2.8M 931M 1% /run
tmpfs 934M 0 934M 0% /sys/fs/cgroup
/dev/sda1 484M 106M 379M 22% /boot
/dev/mapper/testvg-lv11 6.0G 33M 6.0G 1% /u01
|
5.备份xfs文件系统
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| [iyunv@rhel7 ~]# 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 Jan 3 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文件系统备份
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
| [iyunv@rhel7-xzxj-edu-cn ~]# cd /u01/
[iyunv@rhel7-xzxj-edu-cn u01]# ls
asound.conf e2fsck.conf krb5.conf man_db.conf oddjobd.conf resolv.conf sysctl.conf
autofs_ldap_auth.conf fprintd.conf ksmtuned.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.conf pnm2ppa.conf sestatus.conf vconsole.conf
colord.conf host.conf libuser.conf nsswitch.conf prelink.conf sos.conf wvdial.conf
dnsmasq.conf idmapd.conf locale.conf ntp.conf radvd.conf sudo.conf yum.conf
dracut.conf kdump.conf logrotate.conf numad.conf request-key.conf sudo-ldap.conf
[iyunv@rhel7-xzxj-edu-cn u01]# rm -rf *
[iyunv@rhel7-xzxj-edu-cn u01]# ls
[iyunv@rhel7-xzxj-edu-cn u01]#
[iyunv@rhel7-xzxj-edu-cn ~]# 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 Jan 3 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
[iyunv@rhel7-xzxj-edu-cn ~]# ls /u01
asound.conf e2fsck.conf krb5.conf man_db.conf oddjobd.conf resolv.conf sysctl.conf
autofs_ldap_auth.conf fprintd.conf ksmtuned.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.conf pnm2ppa.conf sestatus.conf vconsole.conf
colord.conf host.conf libuser.conf nsswitch.conf prelink.conf sos.conf wvdial.conf
dnsmasq.conf idmapd.conf locale.conf ntp.conf radvd.conf sudo.conf yum.conf
dracut.conf kdump.conf logrotate.conf numad.conf request-key.conf sudo-ldap.conf
|
参考文献:
1.Storage Administration Guide
2.XFS User Guide
|
|