阅读 398

linux服务器磁盘空间扩充方法

大家好,本篇文章主要讲的是linux服务器磁盘空间扩充方法,感兴趣的同学赶快来看一看吧,对你有帮助的话记得收藏一下哦,方便下次浏览

目录
  • 前言

  • 步骤

前言

今天发现es日志未记录,检查了filebeat、elasticsearch、logstash之后发现es的索引都变成了只读状态,手动修改索引模式之后,过几分钟又变成了只读状态。

进一步翻阅资料,才知道原因是一旦在存储超过95%的磁盘中的节点上分配了一个或多个分片的任何索引,该索引将被强制进入只读模式。所以只能扩充磁盘空间了。下面简单描述下磁盘扩充的步骤。

步骤

磁盘原来已经有两个分区了,但是分配的空间都不大。

fdisk -l查看磁盘挂载情况

增加磁盘,通过管理端挂载新的磁盘sdc;

增加sdc磁盘分区

使用fdisk /dev/sdc,创建新分区;

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
[root@localhost indices]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x5799aeba.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
 
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 
WARNING: The size of this disk is 2.2 TB (2199023255552 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).
 
 
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').
 
Command (m for help): n #new 新分区
Command action
   e   extended
   p   primary partition (1-4)
p #选择主扇区
Partition number (1-4): 1 #起始扇区
First cylinder (1-267349, default 1):  #这里直接回车表示取默认值1
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-267349, default 267349):   #这里由于es需要的存储空间比较大,所以2个T的空间我都加上了,正常可以按照需求修改扇区大小
Using default value 267349
 
Command (m for help): w #保存退出
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.

然后创建物理卷,使用pvcreate /dev/sdc1命令;注意:这里很多文章里要求重启系统,这里其实可以不用重启,可直接操作,不影响服务器的正常运行;

1
2
[root@localhost indices]# pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created

使用vgscan查看 物理卷组 名称;

1
2
3
4
[root@localhost indices]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup" using metadata type lvm2
  #这里物理卷组名称为VolGroup

将刚才增加的物理扇区加载到卷组中,这里使用 vgextend VolGroup /dev/sdc1;

1
2
[root@localhost indices]# vgextend VolGroup /dev/sdc1
  Volume group "VolGroup" successfully extended

增加卷组的大小,这里使用lvextend -L +2048G /dev/mapper/VolGroup-lv_root;

1
2
3
[root@localhost indices]# lvextend -L +2048G /dev/mapper/VolGroup-lv_root
  Size of logical volume VolGroup/lv_root changed from 135.47 GiB (34681 extents) to 2.13 TiB (558848 extents).
  Logical volume lv_root successfully resized.

使用df -h查看空间扩充情况,发现空间并未扩充,这是因为文件系统还未同步;

1
2
3
4
5
6
[root@localhost indices]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      134G  119G  8.4G  94% /
tmpfs                  32G   72K   32G   1% /dev/shm
/dev/sda1             477M   41M  411M  10% /boot

同步文件系统,使用xfs_growfs或者resize2fs同步文件系统,如下操作;

1
2
3
4
5
6
[root@localhost indices]# resize2fs -f /dev/mapper/VolGroup-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
old desc_blocks = 9, new_desc_blocks = 137
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 572260352 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 572260352 blocks long.

再使用df -h 查看空间扩容情况

1
2
3
4
5
6
[root@localhost indices]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      2.1T  125G  1.9T   7% /
tmpfs                  32G   72K   32G   1% /dev/shm
/dev/sda1             477M   41M  411M  10% /boot

由于CentOS6和CentOS7在默认根文件系统的文件系统格式存在差异,需要判断是否为xfs,如果是xfs则应该使用xfs_growfs而不是一味的使用resize2fs。

到此这篇关于linux服务器磁盘空间扩充方法的文章就介绍到这了

原文链接:https://blog.csdn.net/zhangxu51241/article/details/121658809


文章分类
百科问答
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐