mysql 分区 扩充_mysql分区LVM扩容

mysql 分区 扩充_mysql分区LVM扩容场景:mysql的数据库目录为/data随着数据量的增加,该分区不够用了,准备添加一块ssd硬盘,扩容该分区!下面是测试环境的整个过程:测试环境:在原有LVM卷标上添加一块50G的新硬盘对LVM进行扩容1、将添加的新硬盘进行分区:fdisk/dev/sdaWARNING:DOS-compatiblemodeisdeprecated.It’sstronglyrecommendedto…

大家好,又见面了,我是你们的朋友全栈君。

场景:mysql的数据库目录为/data随着数据量的增加,该分区不够用了,准备添加一块ssd硬盘,扩容该分区!

下面是测试环境的整个过程:

测试环境:在原有LVM卷标上添加一块50G的新硬盘对LVM进行扩容

1、将添加的新硬盘进行分区:

fdisk /dev/sda

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

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-6527, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G}

(1-6527, default 6527):

Using default value 6527

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e

(Linux LVM)

Command (m for help): p

Disk /dev/sda: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 cylinders

Units = cylinders of 16065 * 512 = 8225280

bytes

Sector size (logical/physical): 512 bytes /

512 bytes

I/O size (minimum/optimal): 512 bytes / 512

bytes

Disk identifier: 0xadc427e3

Device Boot      Start         End      Blocks

Id  System

/dev/sda1               1        6527

52428096   8e  Linux LVM

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@lvm-test /]#fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 cylinders

Units = cylinders of 16065 * 512 = 8225280

bytes

Sector size (logical/physical): 512 bytes /

512 bytes

I/O size (minimum/optimal): 512 bytes / 512

bytes

Disk identifier: 0xadc427e3

Device Boot      Start         End      Blocks   Id

System

/dev/sda1               1        6527

52428096   8e  Linux LVM

Disk /dev/sdb:

21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280

bytes

Sector size (logical/physical): 512 bytes /

512 bytes

I/O size (minimum/optimal): 512 bytes / 512

bytes

Disk identifier: 0x0000e547

Device Boot      Start         End      Blocks

Id  System

/dev/sdb1

*           1          26      204800

83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sdb2              26        2611

20765696   8e  Linux LVM

Disk /dev/sdc: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280

bytes

Sector size (logical/physical): 512 bytes /

512 bytes

I/O size (minimum/optimal): 512 bytes / 512

bytes

Disk identifier: 0x000468eb

Device Boot      Start         End      Blocks

Id  System

/dev/sdc1               1        3917

31456256   8e  Linux LVM

Disk /dev/mapper/vg_lvmtest-LogVol00: 21.0

GB, 20971520000 bytes

255 heads, 63 sectors/track, 2549 cylinders

Units = cylinders of 16065 * 512 = 8225280

bytes

Sector size (logical/physical): 512 bytes /

512 bytes

I/O size (minimum/optimal): 512 bytes / 512

bytes

Disk identifier: 0x00000000

Disk /dev/mapper/vg_lvmtest-LogVol01: 32.5

GB, 32497467392 bytes

255 heads, 63 sectors/track, 3950 cylinders

Units = cylinders of 16065 * 512 = 8225280

bytes

Sector size (logical/physical): 512 bytes /

512 bytes

I/O size (minimum/optimal): 512 bytes / 512

bytes

Disk identifier: 0x00000000

2、新建PV:

[root@lvm-test /]# pvcreate

/dev/sda1

Writing physical volume data to disk “/dev/sda1”

Physical volume “/dev/sda1” successfully created

[root@lvm-test /]# pvscan

PV

/dev/sdb2   VG vg_lvmtest      lvm2 [19.80 GiB / 0    free]

PV

/dev/sdc1   VG vg_lvmtest      lvm2 [30.00 GiB / 0    free]

PV /dev/sda1                      lvm2 [50.00 GiB]

Total: 3 [99.80 GiB] / in use: 2 [49.80 GiB] / in no VG: 1 [50.00 GiB]

3加大VG,利用vgextend功能

[root@lvm-test /]# vgextend

vg_lvmtest   /dev/sda1

Volume group “vg_lvmtest” successfully extended

[root@lvm-test /]# vgdisplay

Volume group —

VG

Name               vg_lvmtest

System ID

Format                lvm2

Metadata Areas        3

Metadata Sequence No  4

VG

Access             read/write

VG

Status             resizable

MAX

LV                0

Cur

LV                2

Open LV               2

Max

PV                0

Cur

PV                3

Act

PV                3

VG

Size               99.79 GiB

PE

Size               4.00 MiB

Total PE              25547

Alloc PE / Size       12748 /

49.80 GiB

Free  PE / Size       12799 / 50.00 GiB

VG

UUID

QJMQEA-k17Z-O8N8-wP3d-NsEu-G9fy-gUclGB

空闲的PE共有12799,容量为50G

4,利用lvresize来增加

[root@lvm-test /]#lvresize

-l +12799 /dev/vg_lvmtest/LogVol01

Extending logical volume LogVol01 to 80.26 GiB

Logical volume LogVol01 successfully resized

[root@lvm-test /]# lvdisplay

Logical volume —

LV

Path                /dev/vg_lvmtest/LogVol01

LV

Name                LogVol01

VG

Name                vg_lvmtest

LV

UUID

ibxmqZ-1HPY-NpXz-KS1n-OzT0-XVa4-hNtvRS

LV

Write Access        read/write

LV

Creation host, time lvm-test, 2013-08-15 16:12:22 +0800

LV

Status              available

#

open                 1

LV

Size                80.26 GiB

Current LE             20547

Segments               3

Allocation             inherit

Read ahead sectors     auto

currently set to     256

Block device           253:1

Logical volume —

LV

Path

/dev/vg_lvmtest/LogVol00

LV

Name                LogVol00

VG

Name                vg_lvmtest

LV

UUID

0h6qFC-Jqzf-7wnP-MAu3-jrMm-Da6D-YuaG8N

LV

Write Access        read/write

LV

Creation host, time lvm-test, 2013-08-15 16:12:40 +0800

LV

Status              available

#

open                 1

LV

Size                19.53 GiB

Current LE             5000

Segments               1

Allocation             inherit

Read ahead sectors     auto

currently set to     256

Block device           253:0

上面执行完之后df -h并没有查看到增加的容量如下所示:

[root@lvm-test /]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/vg_lvmtest-LogVol00

20G  975M

18G   6% /

tmpfs                 939M     0

939M   0% /dev/shm

/dev/sdb1             194M   27M

158M  15% /boot

/dev/mapper/vg_lvmtest-LogVol01

30G  193M

29G   1% /data

5、执行最后一步操作:

[root@lvm-test /]# resize2fs

/dev/vg_lvmtest/LogVol01

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/vg_lvmtest/LogVol01 is

mounted on /data; on-line resizing required

old desc_blocks = 2, new_desc_blocks = 6

Performing an on-line resize of

/dev/vg_lvmtest/LogVol01 to 21040128 (4k) blocks.

The filesystem on /dev/vg_lvmtest/LogVol01

is now 21040128 blocks long.

[root@lvm-test var]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/vg_lvmtest-LogVol00

20G  992M

18G   6% /

tmpfs                 939M     0

939M   0% /dev/shm

/dev/sdb1             194M   27M

158M  15% /boot

/dev/mapper/vg_lvmtest-LogVol01

80G  205M

75G   1% /data

该工具可以实现在线的扩容,不影响用户的使用!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/151538.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 展示组件(Presentational component)和容器组件(Container component)之间有何不同

    展示组件(Presentational component)和容器组件(Container component)之间有何不同展示组件(Presentational component)和容器组件(Container component)之间有何不同

    2022年4月22日
    53
  • cubieboard2 android,在cubieboard2双卡版上从零构建Android4.2.2系统「建议收藏」

    cubieboard2 android,在cubieboard2双卡版上从零构建Android4.2.2系统「建议收藏」板子买了一段时间,终于有时间可以玩玩了,论坛上找浪费了很多时间。把虚拟机环境搭建起来,编译好镜像就可以直接使用烧写工具烧写到TF卡上了。由于买的是双TF卡插槽,没有nand,所以只能在TF卡上制作镜像了。制作过程参考官方文档,好好总结一下,一来以后自己再做时图懒图方便,二来可以方便后来人。主要可以分为一下几个步骤:一、搭建编译环境可以在XP或win7系统上安装虚拟机,在虚拟机中安装交叉编译工具来编…

    2022年7月22日
    9
  • 安全关机程序[通俗易懂]

    安全关机程序[通俗易懂]安全关机程序最近在实验室用ftp下点东西,但是由于实验室晚上12点就会断电。于是需要在此之前关掉机器,图省事就用WindowsXP自带的计划任务每次设置成11:50就调用“shutdown-s”命令自动关机。但是好几次都发现没法正常关机,第二天早上起来就会检测磁盘。于是就做了个实验,发现确实当使用flashfxp下载东西时,关机会不能正常关机,等待确定终止flashfxp程序。发现原因后,很简单

    2022年7月22日
    7
  • java 应用监控_java监控服务器运行状态

    java 应用监控_java监控服务器运行状态每天记录学习,每天会有好心情。*^_^*每天都要认真学习,才能更加进步。└(^o^)┘在工作和学习的过程中要善于思考,勤于学习。并做出适当的记录,才能最快速的学习并掌握一项知识。希望在这个平台和大家一起共同成长,和大家分享一个SSM(MYECLIPSE)项目,该项目名称为基于web的java舆情监测系统。采用当前非常流行的B/S体系结构,以JAVA作为开发技术,主要依赖SSM技术框架,mysql数…

    2022年9月2日
    3
  • APP开发防套路秘籍!

    APP开发防套路秘籍!在互联网软件开发行业混迹多年,深知这个行业的水有多深。就拿APP开发来说,市场上APP开发外包公司实在太多了,大中小都应有尽有,稍不留神,就很容易被“不正规”的公司给套路了。为此,整理了一份“三要一不”防套路秘籍,一起来学习下吧!1.要整体外包大多数企业,想要开发一款APP,都会首选外包这种方式。而外包又有两种形式,即整体外包和半外包。顾名思义,整体外包就是将UI、前端、后台都交给一个外包公司…

    2022年5月18日
    28
  • 150套JSP源码–免费下载

    150套JSP源码–免费下载150套JSP源码免费下载适用于学习百度云下载地址:链接:https://pan.baidu.com/s/1J7-O9k6o8f5dFh71VzCpuA提取码:zb7p如下载地址失效请私信作者

    2022年6月16日
    31

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号