标签:-o parse cts intern extent sed 开机自动挂载 数据盘 uid
将MySQL主机的2块18T的数据盘空间全部“合并”后挂载到/mysql_data目录下,要求文件系统格式化为xfs;已有关键信息梳理如下:
要想实现此需求,可使用LVM逻辑卷管理来做到。
在将磁盘或者磁盘分区用作物理卷(PV)之前,需要对其进行初始化工作,即进行磁盘分区操作;因磁盘分区需求大于2T,所以fdisk无法实现管理,需要使用parted命令来做磁盘分区管理;parted的详细使用方法请参考博主之前的博客:使用parted命令对磁盘进行分区
# 新建/dev/sdb的磁盘标签类型为GPT
[root@MYSQL-SERVER ~]# parted /dev/sdb mklabel gpt
# 将/dev/sdb整个空间分给同一个分区
[root@MYSQL-SERVER ~]# parted /dev/sdb mkpart primary 0 100%
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I
Information: You may need to update /etc/fstab.
# 新建/dev/sdc的磁盘标签类型为GPT
[root@MYSQL-SERVER ~]# parted /dev/sdc mklabel gpt
# 将/dev/sdc整个空间分给同一个分区
[root@MYSQL-SERVER ~]# parted /dev/sdc mkpart primary 0 100%
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I
Information: You may need to update /etc/fstab.
创建物理卷的命令为pvcreate;利用该命令将希望添加到卷组的所有分区或磁盘创建为物理卷;
将分区/dev/sdb1和/dev/sdc1分区创建为物理卷:
[root@MYSQL-SERVER ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[root@MYSQL-SERVER ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created.
创建卷组的命令为vgcreate;用此命令将使用pvcreate建立的物理卷创建为一个完整的卷组;
将物理卷/dev/sdb1创建为一个名为vgmysql的卷组:
[root@MYSQL-SERVER ~]# vgcreate vgmysql /dev/sdb1
Volume group "vgmysql" successfully created
此步即为将2块磁盘空间合二为一的关键步骤;当系统中新增了磁盘或新建了物理卷,而要将其添加到已有卷组时,就可使用vgextend命令;
将物理卷/dev/sdc1添加到vgmysql卷组中:
[root@MYSQL-SERVER ~]# vgextend vgmysql /dev/sdc1
Volume group "vgmysql" successfully extended
查看卷组用vgs:
[root@MYSQL-SERVER ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vgmysql 2 0 0 wz--n- 32.74t 32.74t
vgroot 1 4 0 wz--n- 264.00g 4.00m
从vgs命令的回显结果来看,卷组vgmysql成功添加,并且其总空间为两块物理磁盘的总大小(因换算单位不同,所以不是精确的38T)。
创建逻辑卷的命令为lvcreate;用此命令将在使用vgcreate建立的卷组上创建逻辑卷;
在卷组vgmysql上创建一个名为lvmysql的逻辑卷,起大小为32.7T;
[root@MYSQL-SERVER ~]# lvcreate -L 32.7T -n lvmysql vgmysql
Rounding up size to full physical extent 32.70 TiB
Logical volume "lvmysql" created.
将创建的lvmysql逻辑卷格式化为xfs
[root@MYSQL-SERVER ~]# mkfs -t xfs /dev/vgmysql/lvmysql
meta-data=/dev/vgmysql/lvmysql isize=512 agcount=33, agsize=268435328 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0, rmapbt=0, reflink=0
data = bsize=4096 blocks=8777839616, imaxpct=5
= sunit=64 swidth=64 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=521728, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@MYSQL-SERVER ~]# mkdir /mysql_data
[root@MYSQL-SERVER ~]# mount /dev/vgmysql/lvmysql /mysql_data/
echo '
/dev/mapper/vgmysql-lvmysql /mysql_data xfs defaults 0 0' >/etc/fstab
[root@MYSQL-SERVER ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vgroot-lv_root 40G 1.8G 36G 5% /
devtmpfs 126G 0 126G 0% /dev
tmpfs 126G 0 126G 0% /dev/shm
tmpfs 126G 1.1M 126G 1% /run
tmpfs 126G 0 126G 0% /sys/fs/cgroup
/dev/sda1 976M 197M 713M 22% /boot
/dev/mapper/vgroot-lv_var 59G 197M 56G 1% /var
/dev/mapper/vgroot-lv_home 99G 5.6G 88G 6% /home
tmpfs 26G 0 26G 0% /run/user/0
/dev/mapper/vgmysql-lvmysql 33T 34M 33T 1% /mysql_data
[root@MYSQL-SERVER ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 446.1G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 264G 0 part
│ ├─vgroot-lv_root 253:0 0 40G 0 lvm /
│ ├─vgroot-lv_swap 253:1 0 64G 0 lvm [SWAP]
│ ├─vgroot-lv_var 253:2 0 60G 0 lvm /var
│ └─vgroot-lv_home 253:3 0 100G 0 lvm /home
└─sda3 8:3 0 64M 0 part
sdb 8:16 0 16.4T 0 disk
└─sdb1 8:17 0 16.4T 0 part
└─vgmysql-lvmysql 253:4 0 32.7T 0 lvm /mysql_data
sdc 8:32 0 16.4T 0 disk
└─sdc1 8:33 0 16.4T 0 part
└─vgmysql-lvmysql 253:4 0 32.7T 0 lvm /mysql_data
nvme0n1 259:0 0 1.5T 0 disk
[root@MYSQL-SERVER ~]# blkid
/dev/sda1: UUID="5a350fc9-d3d2-44c7-9574-30bf9a9dd0d3" TYPE="ext4"
/dev/sda2: UUID="Sum0Mm-6ShR-6ajh-cYQO-091c-r7QI-zfbDpm" TYPE="LVM2_member"
/dev/sda3: UUID="2019-05-24-11-39-22-00" LABEL="config-2" TYPE="iso9660"
/dev/mapper/vgroot-lv_root: UUID="df07731a-5e56-4cc3-95ab-b723b5979332" TYPE="ext4"
/dev/mapper/vgroot-lv_swap: UUID="7b5cd64d-d316-430d-8a83-aca89c4708d2" TYPE="swap"
/dev/mapper/vgroot-lv_var: UUID="025cb128-de8f-4bca-8206-5c1601e79715" TYPE="ext4"
/dev/mapper/vgroot-lv_home: UUID="7bd155b6-9200-442a-a61a-32076c0e4b7e" TYPE="ext4"
/dev/sdc1: UUID="rWbWuV-nt59-ba72-VJrL-RTM2-EJJt-VVkhZF" TYPE="LVM2_member" PARTLABEL="sdc1" PARTUUID="355eb343-f2c9-4f13-9477-52b0fb267d5f"
/dev/sdb1: UUID="yfQk1G-nlN8-OOYu-nptl-cg2d-rD0L-uBFnhW" TYPE="LVM2_member" PARTLABEL="sdb1" PARTUUID="19db36ba-ec9c-4f35-9b29-b7bd2155f0dd"
/dev/mapper/vgmysql-lvmysql: UUID="67cda45d-4282-4346-8be1-e4ec375c2892" TYPE="xfs"
[root@MYSQL-SERVER ~]# tail -1 /etc/fstab
/dev/mapper/vgmysql-lvmysql /mysql_data xfs defaults 0 0
标签:-o parse cts intern extent sed 开机自动挂载 数据盘 uid
原文地址:https://www.cnblogs.com/wholj/p/10961705.html