Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Content imported from a Scroll Translations translation file.
Sv translation
languageen

Status
colourYellow
titleStatus: Beta

Sometimes, it might be desirable to move the MySQL Database to a completely new disk which is provisioned in the OS. This can be particularly valuable, if the MySQL database was installed on the root OS disk, and it is desired to have a dedicated disk for this purpose mounted by LVM which can be easily resized.

This procedure describes how this may be achieved. 

Warning
titleAdvanced Topic

Warning: this is an advanced topic. Always back up your data / take snapshots of your virtual machines before applying this procedure.


Translations Ignore


Code Block
# Stop the slave databases which are replicating from the database machine we want to add the new disk to.
mysql -u root -p
mysql> stop slave;

# Scan the SCSI bus for new devices
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
echo 1 > /sys/block/sdb/device/rescan

# Check if the disk has been detected
fdisk -l /dev/sdb

# Create Physical and Logical Volumes 
pvcreate /dev/sdb
vgcreate vg1_mysql /dev/sdb
lvcreate -l100%FREE -n lv1_mysql vg1_mysql

# Create the file system
mkfs.ext4xfs /dev/vg1_mysql/lv1_mysql

# Show the UUID of the volumes
blkid

# Create an fstab entry for the mount
# rw is for best performance
echo "$(blkid /dev/mapper/vg1_mysql-lv1_mysql | cut -d' ' -f2 | tr -d '"') /var/lib/mysql  ext4        rwxfs	defaults      0       0" >> /etc/fstab

# Stop the mysql service
service mysqld stop

# Make a temp directory for mounting the new drive, and move the files to mysql2
cd /var/lib
mkdir mysql2
mount /dev/vg1_mysql/lv1_mysql mysql2/
cd mysql2/
mv ../mysql/* .
cd ..

# Possible se-linux warning here
mount -av

# fix mysql se-linux and ownership
restorecon /var/lib/mysql
chown mysql:mysql mysql

# Check se-linux warning is gone
umount mysql/
mount -av

# When gone, unmount mysql2 
umount mysql2/

# Remove temp directory
rmdir mysql2

# Remove lost and found directory
rmdir /var/lib/mysql/lost+found

# start service
service mysqld start


# Start slaves
mysql> start slave;
mysql> show slave status\G




Sv translation
languagede

Status
colourRed
titleThis page is only available in English

Sv translation
languagefr

Status
colourYellow
title

Status

Statut: Beta

Sometimes, it might be desirable to move the MySQL Database to a completely new disk which is provisioned in the OS. This can be particularly valuable, if the MySQL database was installed on the root OS disk, and it is desired to have a dedicated disk for this purpose mounted by LVM which can be easily resized.

Parfois, il peut être souhaitable de déplacer la base de données MySQL sur un tout nouveau disque qui est fourni dans le système d'exploitation. Cela peut être particulièrement utile si la base de données MySQL a été installée sur le disque racine du système d'exploitation et qu'il est souhaitable d'avoir un disque dédié à cet effet, monté par LVM, qui peut être facilement redimensionné.

Cette procédure décrit comment cela peut être réaliséThis procedure describes how this may be achieved

Warning
titleAdvanced TopicSujet avancé

Warning: this is an advanced topic. Always back up your data / take snapshots of your virtual machines before applying this procedureAttention : il s'agit d'un sujet avancé. Sauvegardez toujours vos données / prenez des clichés de vos machines virtuelles avant d'appliquer cette procédure.


Translations Ignore


Code Block
# Stop the slave databases which are replicating from the database machine we want to add the new disk to.
Arrêter les bases de données esclaves qui se répliquent à partir de la machine de base de données à laquelle nous voulons ajouter le nouveau disque. mysql -u root -p
 mysql> stop slave ;

 # Scanner Scanle thebus SCSI pour trouver busde fornouveaux newpériphériques devices
echoécho "- - -" > /sys/class/scsi_host/host0/scan
 echo "- - -" > /sys/class/scsi_host/host1/scan
 echo "- - -" > /sys/class/scsi_host/host2/scan
 echo 1 > /sys/block/sdb/device/rescan

 # CheckVérifier si ifle thedisque diska hasété beendétecté detected
fdisk -l /dev/sdb

 # Créer Createdes Physicalvolumes andphysiques Logicalet Volumeslogiques 
pvcreate /dev/sdb
 vgcreate vg1_mysql /dev/sdb
 lvcreate -l100%FREE -n lv1_mysql vg1_mysql

# Create the file system
mkfs.ext4 # Créer le système de fichiers mkfs. xfs /dev/vg1_mysql/lv1_mysql

 # ShowAfficher the l'UUID ofdes thevolumes volumes
blkid

 # CreateCréer une anentrée fstab entrypour forl'écho the mount
# rw is for best performance
echo du montage "$(blkid /dev/mapper/vg1_mysql-lv1_mysql | cut -d' ' - f2 | tr -d '"') /var/lib/mysql  ext4        rw      0       xfs defaults 0 0" >> /etc/fstab

 # Arrêter Stople theservice mysql service
service mysqld stop

 # Créer Makeun arépertoire temptemporaire directorypour forle mountingmontage thedu newnouveau drivedisque, et déplacer andles movefichiers thevers filesle tocd mysql2
cd /var/lib
 mkdir mysql2
 mount /dev/vg1_mysql/lv1_mysql mysql2/
 cd mysql2/
 mv . ./mysql/* .
 cd ..

 # Possible se-linux warning here
 mount -av

 # fix mysql se-linux and ownership
 restorecon /var/lib/mysql
 chown mysql : mysql mysql

 # Check se-linux warning is gone
 umount mysql/
 mount -av

 # When gone, unmount mysql2 
umount mysql2/

 # Remove temp directory
 rmdir mysql2

 # Remove lost and found directory
 rmdir /var/lib/mysql/lost+found

 # start service
 service mysqld start


 # Start slaves
 mysql> start slave ;
 mysql> show slave status\G