Dies ist die Übersetzung der Seite: http://www.howtoforge.com/how-to-back-up-mysql-databases-with-mylvmbackup-on-ubuntu-8.10
Ich gebe keine Garantie für Richtigkeit. Das Original stammt von Falko Timme.
mylvmbackup ist ein Perl Script für die schnelle erstellung von MySQL Backups. Es benutzt LVM’s snapshots um das zu erreichen. Um ein Backup zu erstellen, erstellt mylvmbackup eine Lese-sperre für alle Tabellen und leitet alle Server Caches auf die Festplatte um, erstellt einen Snapshot von dem Datenträger welcher das MySQL Datenverzeichnis beinhaltet , und entsperrt diese Tabellen wieder. Dieser Arktikel zeigt, wie man mylymbackup auf einem Ubuntu 8.10 Server benutzt.
Ich gebe keinerlei Garantie, das es bei dir Funktioniert!
1 Vorbemerkung
Ich nehme an, dass MySQL schon auf deinem System eingerichtet ist und läuft. Das System muss LVM benutzen, und das MySQL Datenverzeichnis (/var/lib/mysql) sollte eine eigene LVM partition haben (obwohl das freiwillig ist).
Wenn du Back Up (And Restore) LVM Partitions With LVM Snapshots gelesen hast, weist du das LVM snapshots einige Unbenutze LVM Partitionen für die Snapshots braucht. Mein Testsystem hat eine 2. Partition, derzeit ungenutzte Festplatte /dev/sdb welche für mylvmbackup benutzt wird um ein Temporäres Logisches Volumen für das Backup anzufertigen.
Das ist meine Ausgangssituation:
root@server1:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/server1-root
20G 808M 18G 5% /
tmpfs 252M 0 252M 0% /lib/init/rw
varrun 252M 56K 251M 1% /var/run
varlock 252M 0 252M 0% /var/lock
udev 252M 2.6M 249M 2% /dev
tmpfs 252M 0 252M 0% /dev/shm
/dev/sda1 471M 23M 425M 6% /boot
/dev/mapper/server1-mysql
8.9G 170M 8.3G 2% /var/lib/mysql
root@server1:~#
Wie du siehst, habe ich 2 LVM Partitionen, / and /var/lib/mysql (Plus eine LVM swap Partition die hier nicht gezeigt wird). Der Datenträger-Gruppenname ist server1, und die Datenträger heißen swap, root, und mysql:
root@server1:~# pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name server1
PV Size 29.52 GB / not usable 3.66 MB
Allocatable yes (but full)
PE Size (KByte) 4096
Total PE 7557
Free PE 0
Allocated PE 7557
PV UUID 0gCmpE-FGel-9ayg-E2yg-kkEu-B72X-kFvaye
root@server1:~#
root@server1:~# vgdisplay
--- Volume group ---
VG Name server1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 29.52 GB
PE Size 4.00 MB
Total PE 7557
Alloc PE / Size 7557 / 29.52 GB
Free PE / Size 0 / 0
VG UUID PH5Hpc-jqeP-BFYs-wWlA-hu03-qwuQ-0cNIu3
root@server1:~#
root@server1:~# lvdisplay
--- Logical volume ---
LV Name /dev/server1/swap
VG Name server1
LV UUID RCeLCK-MO5p-xoMq-SwTT-n2NV-GaP6-GaemDp
LV Write Access read/write
LV Status available
# open 2
LV Size 1.00 GB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Name /dev/server1/root
VG Name server1
LV UUID 5Wen7n-xYmh-MQz1-fKH5-0XXa-1y2t-V3PYbb
LV Write Access read/write
LV Status available
# open 1
LV Size 19.53 GB
Current LE 5000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
--- Logical volume ---
LV Name /dev/server1/mysql
VG Name server1
LV UUID wk8yb6-fDl8-4tg3-tneT-1dDe-wWdy-AfGZ5I
LV Write Access read/write
LV Status available
# open 1
LV Size 8.99 GB
Current LE 2301
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:2
root@server1:~#
Hier ist eine Übersicht über meine 2 Festplatten:
root@server1:~# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×0009353f
Device Boot Start End Blocks Id System
/dev/sda1 * 1 62 497983+ 83 Linux
/dev/sda2 63 3916 30957255 5 Extended
/dev/sda5 63 3916 30957223+ 8e Linux LVM
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×00000000
Disk /dev/sdb doesn’t contain a valid partition table
root@server1:~#
2 Vorbereitung /dev/sdb
Bevor wir einen Snapshot auf /dev/sdb erstellen können, wir müssen es Partitionieren (Linux LVM) und es zu unseres Datenträgergruppe hinzufügen (server1).
Ich werde nun die Partition erstellen /dev/sdb1 und es zu der Datenträgergruppe server1 hinzufügen:
fdisk /dev/sdb
server1:~# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.
The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0×0000 of partition table 4 will be corrected by w(rite)
Command (m for help): <-- n
Command action
e extended
p primary partition (1-4)
<-- p
Partition number (1-4): <-- 1
First cylinder (1-1305, default 1): <-- [ENTER]
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305): <-- [ENTER]
Using default value 1305
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): <-- w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
pvcreate /dev/sdb1
vgextend server1 /dev/sdb1
Das wars - Wir müssen keine Volumes darauf erstellen - mylvmbackup macht das automatisch.
- Wie mache ich ein Back Up einer MySQL Databases mit mylvmbackup unter Ubuntu 8.10 - Seite 1
- Wie mache ich ein Back Up einer MySQL Databases mit mylvmbackup unter Ubuntu 8.10 - Seite 2

