Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Lvm creates a snapshot volume

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Note: snapshot volume and logical volume must be the same volume group

Operation procedure:

1. Disk hot add

2.LVM creation

3. Install mysql

4. Mount logical volumes to / var/lib/mysql

5. Start mysql to create snapshot volumes, create file tables, etc.

6 close mysql unmount logical volume recovery snapshot volume

7. Remount and restart mysql to view the content

1. Disk hot add

Heat up a disk first.

Lsblk

Ls / sys/class/scsi_host/

Echo'---'> / sys/class/scsi_host/host0/scan

Echo'---'> / sys/class/scsi_host/host1/scan

Echo'---'> / sys/class/scsi_host/host2/scan

Lsblk

2.LVM creation

Pvcreate / dev/sdb

Pvs

Vgcreate vg0 / dev/sdb

Vgs

Lvcreate-L 2G-n lv1 vg0

Lvs

Mkfs.xfs / dev/vg0/lv1

3. Install mysql

Yum-y install mariadb mariadb-server

4. Mount logical volumes to / var/lib/mysql (mysql default data storage directory

Ls / var/lib/mysql

Ls-ld / var/lib/mysql-ld only lists directories Note: at this point, you can see that all the directories belong to mysql.

Mount / dev/vg0/lv1 / var/lib/mysql temporary mount

Chown-Rv mysql:mysql / var/lib/mysql

5. Start mysql to create snapshot volumes, create file tables, etc.

Systemctl start mariadb

Systemctl enable mariadb

Lvcreate-L 200m-s-n lv1-snap / dev/vg0/lv1 create a snapshot volume

-s to make a snapshot volume

-n specifies the name of the snapshot volume

-L specifies the size of the snapshot volume

Which logical volume is snapped by / dev/vg0/lv1

Mysql-e 'show databases;create database asd;ceate database zxc;show databases;'

6 close mysql unmount logical volume recovery snapshot volume

Systemctl stop mariadb

Umount / dev/vg0/lv1

Lvconvert-merge / dev/vg0/lv1-snap

Lvs

7. Remount and restart mysql to view the content

Mount / dev/vg0/lv1 / var/lib/mysql

Ls / var/lib/mysql

Ls-ld / var/lib/mysql

Systemctl restart mariadb

Mysql-e'show databases;'

You will find that the previously created library files are gone, indicating that the snapshot was restored successfully

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report