mylvmback backup MySQL database

MySQL database backup, you need to take into account the data engine, data size, whether the lock table, whether online, time-consuming backup and other factors. For different data engine back up differently, some backup methods are not compatible with other engines. Recommended Percona xtrabackup tool to back up MySQL database. Percona xtrabackup related content can be found in: http: //www.ttlsa.com/ s = xtrabackup? . Here to tell you at mylvmbackup backup tool, as the name implies, can be seen from the name is for the use of LVM disk backup tool mysql database. The basic principle is to first flush tables with read lock, established lvm snapshots, unlock table, copy files, delete lvm snapshot. One. Prerequisites perl-5 perl-DBD perl- DBI perl-Config-IniFiles // reads the program global configuration file perl-TimeDate perl-DBD-MySQL II. Download and install
# wget http://lenzg.net/mylvmbackup/mylvmbackup-0.13.tar.gz
# tar zxvf mylvmbackup-0.13.tar.gz 
# cd mylvmbackup-0.13/
# make prefix=/usr/local/mylvmbackup install
# make uninstall (删除安装)
three. Configuration [Mysql] // user defined database connection = root password = password host = localhost port = 3306 socket = / tmp / mysql.sock mycnf = / etc / my.cnf # [lvm] // lvm defined parameters, refer to the actual environmental vgname = VolGroup00 lvname = lvmydata backuplv = // define the snapshot volume name, the default is _sanpshot # lvsize must be able to cope with differences lvsize = 5G // define snapshot size # [fs] xfs = 0 mountdir = / var / tmp / mylvmbackup / mnt / // mount directory. The default backupdir = / var / tmp / mylvmbackup / backup / // backup directory can be backed up to a remote host. The default relpath = // logical volume associated with the mysql data directory. Default is null # [tools] // use the command definition lvcreate = / usr / sbin / lvcreate lvremove = / usr / sbin / lvremove lvs = / usr / sbin / lvs mount = / bin / mount tar = / bin / tar compress = / bin / gzip # alternative tar backup compression tools # compress = lzma # compress = bzip2 # or (for no compression): four. practice
# mylvmbackup
20101103 11:05:13 Info: Connecting to database... 20101103 11:05:13 Info: Flushing tables with read lock... 20101103 11:05:13 Info: Taking position record into /tmp/mylvmbackup-backup-20101103_110513_mysql-bTF6zV.pos... 20101103 11:05:13 Info: Running: /usr/sbin/lvcreate -s --size=20G --name=lvmydata_snapshot /dev/VolGroup00/lvmydata File descriptor 4 (socket:[2407170]) leaked on lvcreate invocation. Parent PID 1909: /usr/bin/perl Logical volume "lvmydata_snapshot" created 20101103 11:05:13 Info: DONE: taking LVM snapshot 20101103 11:05:13 Info: Unlocking tables... 20101103 11:05:13 Info: Disconnecting from database... 20101103 11:05:13 Info: Mounting snapshot... 20101103 11:05:13 Info: Running: /bin/mount -o rw /dev/VolGroup00/lvmydata_snapshot /var/tmp/mylvmbackup/mnt/backup 20101103 11:05:13 Info: DONE: mount snapshot 20101103 11:05:13 Info: Copying /tmp/mylvmbackup-backup-20101103_110513_mysql-bTF6zV.pos to /var/tmp/mylvmbackup/mnt/backup-pos/backup-20101103_110513_mysql.pos... 20101103 11:05:13 Info: Copying /etc/my.cnf to /var/tmp/mylvmbackup/mnt/backup-pos/backup-20101103_110513_mysql_my.cnf... 20101103 11:05:13 Info: Taking actual backup... 20101103 11:05:13 Info: Creating tar archive /var/tmp/mylvmbackup/backup/backup-20101103_110513_mysql.tar.gz 20101103 11:05:13 Info: Running: cd '/var/tmp/mylvmbackup/mnt' ;'/bin/tar' cvfp - backup/ backup-pos/backup-20101103_110513_mysql.pos backup-pos/backup-20101103_110513_mysql_my.cnf| /bin/gzip --stdout --verbose --best -> /var/tmp/mylvmbackup/backup/backup-20101103_110513_mysql.tar.gz.INCOMPLETE-1dnZuce backup/ (压缩包的过程,省略) 20101103 11:46:39 Info: DONE: create tar archive 20101103 11:46:39 Info: Cleaning up... 20101103 11:46:39 Info: Running: /bin/umount /var/tmp/mylvmbackup/mnt/backup 20101103 11:46:39 Info: DONE: Unmounting /var/tmp/mylvmbackup/mnt/backup 20101103 11:46:39 Info: LVM Usage stats: 20101103 11:46:39 Info: LV VG Attr LSize Origin Snap% Move Log Copy% Convert 20101103 11:46:39 Info: lvmydata_snapshot VolGroup00 swi-a- 20.00G lvmydata 0.03 20101103 11:46:39 Info: Running: /usr/sbin/lvremove -f /dev/VolGroup00/lvmydata_snapshot Logical volume "lvmydata_snapshot" successfully removed 20101103 11:46:39 Info: DONE: Removing snapshot Five explanation under 1. backup-pos directory will have two files: backup-timestamp_mysql_my.cnf my.cnf configuration file backup-timestamp_mysql.pos 2. The main useful from the environment, the recorded contents are: Master: File = Master: Position = Master: Binlog_Do_DB = Master: Binlog_Ignore_DB = contents of the above is what I wrote in 2010, when concluded here, who want to use mylvmback help. Reproduced please specify from time to live operation and maintenance : http://www.ttlsa.com/html/3666.html

Reproduced in: https: //my.oschina.net/766/blog/210878

Guess you like

Origin blog.csdn.net/weixin_33725515/article/details/91546113
Recommended