Ubuntu下创建XFS文件系统的LVM
程序员文章站
2022-10-26 14:00:49
以前在Linux下面玩LVM,一般都是选择ext3、ext4格式的文件系统,最近在Ubuntu 16.04.5下安装配置一个MySQL数据库服务器,遂测试了一下XFS文件系统的LVM,其实仔细对比下来,差别不大,只是文件格式化的区别以及件系统的调整命令的不同。下面很多地方不做过多解释,只是简单的记录... ......
以前在linux下面玩lvm,一般都是选择ext3、ext4格式的文件系统,最近在ubuntu 16.04.5下安装配置一个mysql数据库服务器,遂测试了一下xfs文件系统的lvm,其实仔细对比下来,差别不大,只是文件格式化的区别以及件系统的调整命令的不同。下面很多地方不做过多解释,只是简单的记录测试过程。
在测试服务器新增一个磁盘,如下所示,新增的磁盘为/dec/sdc
root@mylnx12:~# fdisk -l
disk /dev/sdb: 605 gib, 649613803520 bytes, 1268776960 sectors
units: sectors of 1 * 512 = 512 bytes
sector size (logical/physical): 512 bytes / 512 bytes
i/o size (minimum/optimal): 512 bytes / 512 bytes
disklabel type: dos
disk identifier: 0x2c2c38b3
device boot start end sectors size id type
/dev/sdb1 2048 1268774911 1268772864 605g 7 hpfs/ntfs/exfat
disk /dev/sda: 30 gib, 32212254720 bytes, 62914560 sectors
units: sectors of 1 * 512 = 512 bytes
sector size (logical/physical): 512 bytes / 512 bytes
i/o size (minimum/optimal): 512 bytes / 512 bytes
disklabel type: dos
disk identifier: 0x6e2369f9
device boot start end sectors size id type
/dev/sda1 * 2048 62914526 62912479 30g 83 linux
disk /dev/sdc: 1023 gib, 1098437885952 bytes, 2145386496 sectors
units: sectors of 1 * 512 = 512 bytes
sector size (logical/physical): 512 bytes / 512 bytes
i/o size (minimum/optimal): 512 bytes / 512 bytes
disklabel type: dos
disk identifier: 0x030b81c8
device boot start end sectors size id type
/dev/sdc1 2048 2145386495 2145384448 1023g 83 linux
#创建pv
root@mylnx12:~# pvcreate /dev/sdc1
physical volume "/dev/sdc1" successfully created
root@mylnx12:~# pvscan
pv /dev/sdc1 lvm2 [1023.00 gib]
total: 1 [1023.00 gib] / in use: 0 [0 ] / in no vg: 1 [1023.00 gib]
#创建vg
root@mylnx12:~# vgcreate -s 32m volgroup01 /dev/sdc1
volume group "volgroup01" successfully created
#新增lv
root@mylnx12:~# lvcreate -l +400g -n logvol00 volgroup01
warning: xfs signature detected on /dev/volgroup01/logvol00 at offset 0. wipe it? [y/n]: y
wiping xfs signature on /dev/volgroup01/logvol00.
logical volume "logvol00" created.
root@mylnx12:~# lvscan
active '/dev/volgroup01/logvol00' [400.00 gib] inherit
#格式化
root@mylnx12:~# mkfs.xfs /dev/volgroup01/logvol00
meta-data=/dev/volgroup01/logvol00 isize=512 agcount=4, agsize=26214400 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0
data = bsize=4096 blocks=104857600, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=51200, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
#挂载点设置
root@mylnx12:~# mkdir /mysql_data
root@mylnx12:~# mount -t xfs /dev/volgroup01/logvol00 /mysql_data
root@mylnx12:~# vgdisplay
--- volume group ---
vg name volgroup01
system id
format lvm2
metadata areas 1
metadata sequence no 2
vg access read/write
vg status resizable
max lv 0
cur lv 1
open lv 0
max pv 0
cur pv 1
act pv 1
vg size 1022.97 gib
pe size 32.00 mib
total pe 32735
alloc pe / size 12800 / 400.00 gib
free pe / size 19935 / 622.97 gib
vg uuid 8kutic-bjid-rnwk-ucho-tu2l-xkwa-idbxcj
#创建另外一个lv
root@mylnx12:~# lvcreate -l 19935 -n logvol01 volgroup01
logical volume "logvol01" created.
root@mylnx12:~# mkfs.xfs /dev/volgroup01/logvol01
meta-data=/dev/volgroup01/logvol01 isize=512 agcount=4, agsize=40826880 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0
data = bsize=4096 blocks=163307520, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=79740, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
root@mylnx12:~# mkdir /mysql_backup
root@mylnx12:~# mount -t xfs /dev/volgroup01/logvol01 /mysql_backup/
root@mylnx12:~# df -h
filesystem size used avail use% mounted on
udev 6.9g 0 6.9g 0% /dev
tmpfs 1.4g 8.6m 1.4g 1% /run
/dev/sda1 30g 2.1g 27g 8% /
tmpfs 6.9g 0 6.9g 0% /dev/shm
tmpfs 5.0m 0 5.0m 0% /run/lock
tmpfs 6.9g 0 6.9g 0% /sys/fs/cgroup
/dev/sdb1 596g 70m 566g 1% /mnt
tmpfs 1.4g 0 1.4g 0% /run/user/1000
/dev/mapper/volgroup01-logvol00 400g 441m 400g 1% /mysql_data
/dev/mapper/volgroup01-logvol01 623g 668m 623g 1% /mysql_backup
修改配置文件/etc/fstab,在其增加下面配置信息,如下所示,以便永久保存,确保下次开机启动不丢失相关挂载点信息。
uuid="a72bd3f8-eb2d-40cb-92c3-d5e32c30d5ff" /mysql_data xfs defaults 0 2
uuid="33325d87-f3f4-4215-abf7-ee795724697e" /mysql_backup xfs defaults 0 2
另外,ext2/ext3/ext4文件系统的调整命令是resize2fs(增大和减小都支持),而xfs文件系统的调整命令是xfs_growfs(只支持增大),当然硬要减小的话,只能在减小后将逻辑分区重新通过mkfs.xfs命令重新格式化才能挂载上,这样的话这个逻辑分区上原来的数据就丢失了。其实没有什么意义。
参考资料:
上一篇: jQuery提交多个表单的小例子