作为一名大数据SRE工程师,基本上很少涉及到服务器相关的挂盘操作,所以有问题都是找服务器的同事处理。可是最近服务器太忙,流程太慢,那我自己本身也有权限,那就自己干,丰衣足食。接下来进入正题。文章来源:https://www.toymoban.com/news/detail-448302.html
1、/metadata 目录单独划分磁盘分区
1.1、vgs先查看有哪些卷组
如下,系统有1个卷组,已经在systemvg上创建了多个systemvg卷组,目前systemvg卷组还有空间
# vgs
VG #PV #LV #SN Attr VSize VFree
systemvg 1 7 0 wz--n- 558.01g 454.01g
1.2、创建100G的metadatalv逻辑卷
在systemvg卷组上创建一个名称叫metadatalv的100G的逻辑卷(metadatalv是为了区分挂载目录和逻辑卷)
# lvcreate -L 100G -n metadatalv systemvg
Logical volume "metadatalv" created.
1.3、创建/metadata目录
# mkdir /metadata
1.4、格式化磁盘分区为ext4文件系统
# mkfs.ext4 /dev/mapper/systemvg-metadatalv
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=16 blocks, Stripe width=16 blocks
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 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, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
1.5、分区挂载添加到开机启动挂载
# echo "/dev/mapper/systemvg-metadatalv /metadata ext4 defaults 0 0" >> /etc/fstab
1.6、重新挂载所有分区
mount -a
1.7、检查磁盘是否挂载成功
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/systemvg-metadatalv 99G 61M 94G 1% /metadata
2、/log 目录单独划分磁盘分区
2.1、vgs先查看有哪些卷组
如下,系统有1个卷组,已经在systemvg上创建了多个systemvg卷组,目前systemvg卷组还有空间。相比/metadata挂载前已经减少了100G。
# vgs
VG #PV #LV #SN Attr VSize VFree
systemvg 1 8 0 wz--n- 558.01g 354.01g
2.2、创建100G的loglv逻辑卷
在systemvg卷组上创建一个名称叫loglv的100G的逻辑卷(loglv是为了区分挂载目录和逻辑卷)
# lvcreate -L 100G -n loglv systemvg
Logical volume "loglv" created.
2.3、创建/log目录
# mkdir /log
2.4、格式化磁盘分区为ext4文件系统
# mkfs.ext4 /dev/mapper/systemvg-loglv
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=16 blocks, Stripe width=16 blocks
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 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, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
2.5、分区挂载添加到开机启动挂载
# echo "/dev/mapper/systemvg-loglv /log ext4 defaults 0 0" >> /etc/fstab
2.6、重新挂载所有分区
mount -a
2.7、检查磁盘是否挂载成功
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/systemvg-rootlv 7.8G 196M 7.2G 3% /
/dev/mapper/systemvg-usrlv 9.8G 2.9G 6.4G 32% /usr
/dev/mapper/systemvg-tmplv 976M 3.6M 906M 1% /tmp
/dev/mapper/systemvg-varlv 4.8G 510M 4.1G 11% /var
/dev/mapper/systemvg-homelv 50G 2.5G 45G 6% /home
/dev/mapper/systemvg-optlv 20G 682M 18G 4% /opt
/dev/mapper/systemvg-metadatalv 99G 61M 94G 1% /metadata
/dev/mapper/systemvg-loglv 99G 61M 94G 1% /log
3、lvremove释放lvcreate创建占用的空间
如果想释放在systemvg卷组上释放metadatalv的空间,可以使用lvremove命令
lvremove /dev/mapper/systemvg-metadatalv
lvremove /dev/mapper/systemvg-loglv
文章来源地址https://www.toymoban.com/news/detail-448302.html
到了这里,关于如何在系统盘上格式化一部分空间单独挂载/metadata和/log的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!