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.
ext4
xfs /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
xfs	defaults  
rw
    
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.

This procedure describes how this may be achieved

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é

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

Attention : 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 ;
 # 
Scan
Scanner le 
the
bus SCSI 
bus for new devices echo
pour trouver de nouveaux périphériques é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
 # Vérifier 
Check
si 
if
le 
the
disque 
disk
a 
has
été 
been
détecté 
detected
fdisk -l /dev/sdb
 # Créer 
Create
des 
Physical
volumes 
and
physiques 
Logical
et 
Volumes
logiques 
pvcreate /dev/sdb
 vgcreate vg1_mysql /dev/sdb
 lvcreate -l100%FREE -n lv1_mysql vg1_mysql
 # Créer 
Create
le système 
the
de 
file
fichiers 
system
mkfs.
ext4
 xfs /dev/vg1_mysql/lv1_mysql
 # 
Show
Afficher 
the
l'UUID 
of
des 
the
volumes 
volumes
blkid
 # Créer 
Create
une 
an
entrée fstab 
entry
pour 
for
l'é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
xfs defaults 0
 
0" >> /etc/fstab
 # Arrêter 
Stop
le 
the
service mysql 
service
service mysqld stop
 # 
Make
Créer un 
a
répertoire 
temp
temporaire 
directory
pour 
for
le 
mounting
montage 
the
du 
new
nouveau 
drive
disque, 
and move the files to mysql2 cd
et déplacer les fichiers vers le cd mysql2 /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