MySQL社区

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 7975|回复: 3
打印 上一主题 下一主题

[XtraBackup] XtraBackup (Open Source, Free)

[复制链接]
跳转到指定楼层
1#
发表于 2011-5-16 17:30:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1.1.1.1                      Introduce
Distinguish: Innobackupex-1.5.1 has backed up all database files Including form definition file, data file, index file Xtrabackup only backs up the data file of InnoDB form --Tablename.ibd file, so we need to back up the database structure of the form definition file or dump alone, it otherwise not appear can delete by the situations of the catalogues data by mistake on ...uh ...It uncertain to on it is newly
After install XtraBackup, you will see below tools:
/usr/bin/innobackupex-1.5.1
/usr/bin/tar4ibd
/usr/bin/xtrabackup
xtrabackup - binary, which allows to copy only InnoDB/XtraDB tablespaces
innobackupex - script, based on innobackup Perl script, distributed by Oracle/InnoDB under GPL license. Script was modified to work with xtrabackup binary and accept new parameters. Script provides functionality to backup whole MySQL database instance with MyISAM, InnoDB, XtraDB tables.
1.1.1.2                      Download1.1.1.3                      Install
rpm -Uvh MySQL-client-community-5.0.91-1.rhel4.x86_64.rpm
rpm -Uvh xtrabackup-1.2-13.rhel4.x86_64.rpm
[url=]1.1.1.4                      Backup[/url][e1]
1.
Using innobackupex-1.5.1 backup all databases.
ms@adm76:~/bakcup> innobackupex-1.5.1 --user=root --stream=tar /opt/ms/soft/xtrabackup/backup/ --slave-info --use-memory=256M --host=127.0.0.1 --port=4309 --socket=/tmp/mysqlbk.sock --defaults-file=/opt/ms/mysqlbk/my.cnf --no-lock | gzip > /opt/ms/soft/xtrabackup/backup/bak_mysql_20100628_1750.tar.gz
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy.
All Rights Reserved.
xtrabackup: Target instance is assumed as followings.
xtrabackup:
innodb_data_home_dir = /opt/ms/mysql5140/Idata
xtrabackup:
innodb_data_file_path = ibdata1:10M:autoextend
xtrabackup:
innodb_log_group_home_dir = /opt/ms/mysql5140/Idata/ilog
xtrabackup:
innodb_log_files_in_group = 3
xtrabackup:
innodb_log_file_size = 268435456
xtrabackup: Stream mode.
>> log scanned up to (26586735764)
100612 15:32:33
innobackupex-1.5.1: Continuing after ibbackup has suspended
innobackupex-1.5.1: Starting to backup InnoDB tables and indexes
innobackupex-1.5.1: from original InnoDB data directory '/opt/ms/mysql5140/Idata'
innobackupex-1.5.1: Backing up as tar stream 'ibdata1'
innobackupex-1.5.1: Backing up files '/opt/ms/mysql5140/var/adm/*.ibd' (42 files)
innobackupex-1.5.1: Backing up file '/opt/ms/mysql5140/var/test/test.ibd'
>> log scanned up to (26587796751)
... ...
100612 15:34:41
innobackupex-1.5.1: Starting to backup .frm, .MRG, .MYD, .MYI,
innobackupex-1.5.1: .TRG, .TRN, .ARM, .ARZ and .opt files in
innobackupex-1.5.1: subdirectories of '/opt/ms/mysql5140/var'
innobackupex-1.5.1: Backing up files '/opt/ms/mysql5140/var/adm/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,opt,par}' (52 files)
innobackupex-1.5.1: Backing up file '/opt/ms/mysql5140/var/test/test.frm'
innobackupex-1.5.1: Backing up file '/opt/ms/mysql5140/var/test/tt.frm'
innobackupex-1.5.1: Backing up files '/opt/ms/mysql5140/var/mysql/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,opt,par}' (65 files)
innobackupex-1.5.1: Backing up files '/opt/ms/mysql5140/var/report/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,opt,par}' (71 files)
100612 15:34:42
innobackupex-1.5.1: Finished backing up .frm, .MRG, .MYD, .MYI, .TRG, .TRN, .ARM, .ARZ and .opt files
innobackupex-1.5.1: Backup created in directory '/opt/ms/backup'
innobackupex-1.5.1: MySQL binlog position: filename 'mysql-bin.000037', position 140471897
innobackupex-1.5.1: MySQL slave binlog position: master host '10.0.9.79', filename 'mysql-bin.000040', position 162029822
innobackupex-1.5.1: You must use -i (--ignore-zeros) option for extraction of the tar stream.
100612 15:34:46
innobackupex-1.5.1: completed OK!
2.
Using xtrabackup backup InnoDB data.
1.1.1.5                      Restore
1.
Uncompress tar.gz file
tar -ixvf bak_mysql_20100628_1750.tar.gz
2.
Restore DB
innobackupex-1.5.1 --apply-log /opt/ms/soft/xtrabackup/backup
innobackupex-1.5.1 --copy-back /opt/ms/soft/xtrabackup/backup
or
innobackupex-1.5.1
--socket=/tmp/mysql9999.sock --defaults-file=/opt/mysql/my.cnf
--no-lock
--apply-log /opt/slave
innobackupex-1.5.1 --user=adm --password=adm
--host=localhost --port=3306 --socket=/tmp/mysql9999.sock --defaults-file=/opt/mysql/my.cnf
--copy-back /opt/slave
3.
Recovery DB
Using binary logs recovery DB
mysqlbinlog --start-position=3335 mysql-bin.000003 |mysql -uroot -P3309 test
1.1.1.6                      Result
1.
Backup smooth, impact DB lowest
2.
After restore DB, can use binary logs to recovery DB.
3.
Can recovery to point time.
1.1.1.7                      Positive
1.
Can compress backup file while backup, so it’s occupy fewer storage
2.
Support increment backup
3.
Need lower CPU
1.1.1.8                      Negative
1.
After backup innodb data, need to backup .frm more
2.
When encounter err need buy support or research the code.


[e1]backup restore verify



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 分享淘帖 顶 踩
2#
 楼主| 发表于 2011-5-23 17:29:36 | 只看该作者
2.1        InnoDB Online Backup & Restore
2.1.1        InnoDB Hot Backup (Commercial)
2.1.1.1        Download
http://www.innodb.com/wp/products/hot-backup/order/
http://www.innodb.com/download/innobackup-1.5.1
2.1.1.2        Backup

innobackup-1.5.1 --user=root --port=3309 --socket=/tmp/mysql.sock --use-memory=256 --compress=9 /opt/ms/mysql5140/my.cnf /opt/ms/innodb_hot_backup/backup

InnoDB Backup Utility v1.5.1; Copyright 2003, 2009 Innobase Oy.
All Rights Reserved.

This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

IMPORTANT: Please check that the backup run completes successfully.
           At the end of a successful backup run innobackup
           prints "innobackup completed OK!".

innobackup: Using mysql  Ver 14.14 Distrib 5.1.40, for unknown-linux-gnu (x86_64) using  EditLine wrapper
innobackup: Using mysql server version 5.1.40-log
innobackup: Using InnoDB Hot Backup version 3.0.0

innobackup: Created backup directory /opt/ms/innodb_hot_backup/backup/2010-06-13_11-15-07
100613 11:15:07  innobackup: Starting mysql with options: --unbuffered --user=root --host=127.0.0.1 --port=3309 --socket=/tmp/mysql.sock
100613 11:15:07  innobackup: Connected to database with mysql child process (pid=21947)
100613 11:15:11  innobackup: Connection to database server closed

100613 11:15:11  innobackup: Starting ibbackup with command: ibbackup --suspend-at-end --compress 9 --use-memory 256 /opt/ms/mysql5140/my.cnf /opt/ms/innodb_hot_backup/backup/2010-06-13_11-15-07/backup-my.cnf
innobackup: Waiting for ibbackup (pid=21953) to suspend
innobackup: Suspend file '/opt/ms/innodb_hot_backup/backup/2010-06-13_11-15-07/ibbackup_suspended'

InnoDB Hot Backup version 3.0.0; Copyright 2002-2005 Innobase Oy
License A19611 is granted to JunHe (he001@126.com)
(--apply-log works in any computer regardless of the hostname)
Licensed for use in a computer whose hostname is 'adm76'
Expires 2010-8-1 (year-month-day) at 00:00
See http://www.innodb.com for further information
Type ibbackup --license for detailed license terms, --help for help

Contents of /opt/ms/mysql5140/my.cnf:
innodb_data_home_dir got value /opt/ms/mysql5140/Idata
innodb_data_file_path got value ibdata1:10M:autoextend
datadir got value /opt/ms/mysql5140/var
innodb_log_group_home_dir got value /opt/ms/mysql5140/Idata/ilog
innodb_log_files_in_group got value 3
innodb_log_file_size got value 268435456

Contents of /opt/ms/innodb_hot_backup/backup/2010-06-13_11-15-07/backup-my.cnf:
innodb_data_home_dir got value /opt/ms/innodb_hot_backup/backup/2010-06-13_11-15-07
innodb_data_file_path got value ibdata1:10M:autoextend
datadir got value /opt/ms/innodb_hot_backup/backup/2010-06-13_11-15-07
innodb_log_group_home_dir got value /opt/ms/innodb_hot_backup/backup/2010-06-13_11-15-07
innodb_log_files_in_group got value 3
innodb_log_file_size got value 268435456

ibbackup: Found checkpoint at lsn 10 1927124053
ibbackup: Starting log scan from lsn 10 1927123968
100613 11:15:11  ibbackup: Copying log...

100613 11:15:26  ibbackup: Switching to log file 0, lsn 10 2147147776
100613 11:15:44  ibbackup: Log copied, lsn 10 2406256592
ibbackup: We wait 1 second before starting copying the data files...
100613 11:15:45  ibbackup: Copying /opt/ms/mysql5140/Idata/ibdata1

100613 11:15:50  ibbackup: Switching to log file 1, lsn 10 2415581184
100613 11:15:53  ibbackup: Copying /opt/ms/mysql5140/var/adm/t_camp_camp_ext_attribute.ibd
... ...
100613 11:15:57  ibbackup: Copying /opt/ms/mysql5140/var/test/test.ibd
ibbackup: Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300
100613 11:19:06  ibbackup: Switching to log file 2, lsn 10 2684014592
1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700
100613 11:22:18  ibbackup: Switching to log file 0, lsn 10 2952448000
2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 4100
100613 11:25:28  ibbackup: Switching to log file 1, lsn 10 3220881408
4200 4300 4400 4500 4600 4700 4800 4900 5000 5100 5200 5300 5400 5500 5600 5700
100613 11:28:34  ibbackup: Switching to log file 2, lsn 10 3489314816
5800 5900 6000 6100 6200 6300 6400 6500 6600 6700 6800
100613 11:30:05  ibbackup: Copying /opt/ms/mysql5140/var/test/tt.ibd
100613 11:30:05  ibbackup: Copying /opt/ms/mysql5140/var/test/test2.ibd
ibbackup: Progress in MB: 100 200 300 400 500 600 700 800
100613 11:31:30  ibbackup: Copying /opt/ms/mysql5140/var/report/t_rept_user_report.ibd
100613 11:31:30  ibbackup: Copying /opt/ms/mysql5140/var/report/t_rept_report_log.ibd
100613 11:31:30  ibbackup: Copying /opt/ms/mysql5140/var/report/t_sys_dict_code.ibd
100613 11:31:31  ibbackup: Copying /opt/ms/mysql5140/var/report/t_sys_dict_code_i18.ibd

ibbackup: You had specified the option --suspend-at-end
100613 11:31:31  ibbackup: Suspending the backup procedure to wait
ibbackup: until you delete the marker file /opt/ms/innodb_hot_backup/backup/2010-06-13_11-15-07/ibbackup_suspended

100613 11:31:31  innobackup: Continuing after ibbackup has suspended
100613 11:31:31  innobackup: Starting mysql with options: --unbuffered --user=root --host=127.0.0.1 --port=3309 --socket=/tmp/mysql.sock
100613 11:31:31  innobackup: Connected to database with mysql child process (pid=22019)
100613 11:31:35  innobackup: Starting to lock all tables...

100613 11:31:40  ibbackup: Switching to log file 0, lsn 10 3757748224
100613 11:31:51  innobackup: All tables locked and flushed to disk

100613 11:31:51  innobackup: Starting to backup .frm, .MRG, .MYD, .MYI,
innobackup: .TRG, .TRN, and .opt files in
innobackup: subdirectories of '/opt/ms/mysql5140/var'
innobackup: Backing up files '/opt/ms/mysql5140/var/adm/*.{frm,MYD,MYI,MRG,TRG,TRN,opt}' (52 files)
innobackup: Backing up file '/opt/ms/mysql5140/var/test/test.frm'
innobackup: Backing up file '/opt/ms/mysql5140/var/test/test2.frm'
innobackup: Backing up file '/opt/ms/mysql5140/var/test/tt.frm'
innobackup: Backing up files '/opt/ms/mysql5140/var/mysql/*.{frm,MYD,MYI,MRG,TRG,TRN,opt}' (66 files)
innobackup: Backing up files '/opt/ms/mysql5140/var/report/*.{frm,MYD,MYI,MRG,TRG,TRN,opt}' (71 files)
100613 11:31:52  innobackup: Finished backing up .frm, .MRG, .MYD, .MYI, .TRG, .TRN, and .opt files

innobackup: Resuming ibbackup

100613 11:31:53  ibbackup: Suspension ends. Continuing the backup procedure.

100613 11:31:53  ibbackup: Copying of the last data file is close to ending...
ibbackup: We still once copy the latest flushed log to ibbackup_logfile.
100613 11:31:53  ibbackup: Copying /opt/ms/mysql5140/var/mysql/ibbackup_binlog_marker.ibd
ibbackup: A copied database page was modified at 10 3701860788
ibbackup: Scanned log up to lsn 10 3765951701
ibbackup: Was able to parse the log up to lsn 10 3765951701
ibbackup: Maximum page number for a log record 436416

ibbackup: Compressed 7795 MB of data files to 644 MB (compression 91%).

100613 11:31:53  ibbackup: Full backup completed!
100613 11:31:57  innobackup: All tables unlocked
100613 11:31:57  innobackup: Connection to database server closed

innobackup: Backup created in directory '/opt/ms/innodb_hot_backup/backup/2010-06-13_11-15-07'
innobackup: MySQL binlog position: filename 'mysql-bin.000067', position 96968309
100613 11:31:57  innobackup: innobackup completed OK!

2.1.1.3        Restore
1.        Restore DB
innobackup-1.5.1 --apply-log /opt/ms/innodb_hot_backup/backup
innobackup-1.5.1 --copy-back /opt/ms/innodb_hot_backup/backup
2.        Recovery DB
Using binary logs to recovery DB
mysqlbinlog --start-position=3335 mysql-bin.000003 |mysql -uroot -P3309 test

2.1.1.4        Result
1.        Backup smooth, impact DB lowest
2.        After restore DB, can use binary logs to recovery DB.
3.        Can recovery to point time.
2.1.1.5        Positive
1.        Commercial edition, can get support when encounter err
2.1.1.6        Negative
4.        The backup data need manual compress, occupy more storage
5.        Need more CPU, will impact DB load while backup
6.        After backup innodb data, need to backup .frm more

2.1.2        XtraBackup (Open Source, Free)
2.1.2.1        Introduce
After install XtraBackup, you will see below tools:
/usr/bin/innobackupex-1.5.1
/usr/bin/tar4ibd
/usr/bin/xtrabackup

xtrabackup - binary, which allows to copy only InnoDB/XtraDB tablespaces
innobackupex - script, based on innobackup Perl script, distributed by Oracle/InnoDB under GPL license. Script was modified to work with xtrabackup binary and accept new parameters. Script provides functionality to backup whole MySQL database instance with MyISAM, InnoDB, XtraDB tables.
2.1.2.2        Download
http://downloads.mysql.com/archi ... -1.rhel4.x86_64.rpm
http://www.percona.com/downloads ... 13.rhel4.x86_64.rpm
2.1.2.3        Install
rpm -Uvh MySQL-client-community-5.0.91-1.rhel4.x86_64.rpm
rpm -Uvh xtrabackup-1.2-13.rhel4.x86_64.rpm
2.1.2.4        Backup
1.        Using innobackupex-1.5.1 backup all databases.

ms@adm76:~/bakcup> innobackupex-1.5.1 --user=root --stream=tar /opt/ms/soft/xtrabackup/backup/ --slave-info --use-memory=256M --host=127.0.0.1 --port=4309 --socket=/tmp/mysqlbk.sock --defaults-file=/opt/ms/mysqlbk/my.cnf --no-lock | gzip > /opt/ms/soft/xtrabackup/backup/bak_mysql_20100628_1750.tar.gz

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy.
All Rights Reserved.

xtrabackup: Target instance is assumed as followings.
xtrabackup:   innodb_data_home_dir = /opt/ms/mysql5140/Idata
xtrabackup:   innodb_data_file_path = ibdata1:10M:autoextend
xtrabackup:   innodb_log_group_home_dir = /opt/ms/mysql5140/Idata/ilog
xtrabackup:   innodb_log_files_in_group = 3
xtrabackup:   innodb_log_file_size = 268435456
xtrabackup: Stream mode.
>> log scanned up to (26586735764)

100612 15:32:33  innobackupex-1.5.1: Continuing after ibbackup has suspended

innobackupex-1.5.1: Starting to backup InnoDB tables and indexes
innobackupex-1.5.1: from original InnoDB data directory '/opt/ms/mysql5140/Idata'
innobackupex-1.5.1: Backing up as tar stream 'ibdata1'
innobackupex-1.5.1: Backing up files '/opt/ms/mysql5140/var/adm/*.ibd' (42 files)
innobackupex-1.5.1: Backing up file '/opt/ms/mysql5140/var/test/test.ibd'
>> log scanned up to (26587796751)
... ...


100612 15:34:41  innobackupex-1.5.1: Starting to backup .frm, .MRG, .MYD, .MYI,
innobackupex-1.5.1: .TRG, .TRN, .ARM, .ARZ and .opt files in
innobackupex-1.5.1: subdirectories of '/opt/ms/mysql5140/var'
innobackupex-1.5.1: Backing up files '/opt/ms/mysql5140/var/adm/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,opt,par}' (52 files)
innobackupex-1.5.1: Backing up file '/opt/ms/mysql5140/var/test/test.frm'
innobackupex-1.5.1: Backing up file '/opt/ms/mysql5140/var/test/tt.frm'
innobackupex-1.5.1: Backing up files '/opt/ms/mysql5140/var/mysql/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,opt,par}' (65 files)
innobackupex-1.5.1: Backing up files '/opt/ms/mysql5140/var/report/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,opt,par}' (71 files)
100612 15:34:42  innobackupex-1.5.1: Finished backing up .frm, .MRG, .MYD, .MYI, .TRG, .TRN, .ARM, .ARZ and .opt files


innobackupex-1.5.1: Backup created in directory '/opt/ms/backup'
innobackupex-1.5.1: MySQL binlog position: filename 'mysql-bin.000037', position 140471897
innobackupex-1.5.1: MySQL slave binlog position: master host '10.0.9.79', filename 'mysql-bin.000040', position 162029822
innobackupex-1.5.1: You must use -i (--ignore-zeros) option for extraction of the tar stream.
100612 15:34:46  innobackupex-1.5.1: completed OK!
2.        Using xtrabackup backup InnoDB data.

2.1.2.5        Restore
1.        Uncompress tar.gz file
tar -ixvf bak_mysql_20100628_1750.tar.gz
2.        Restore DB
innobackupex-1.5.1 --apply-log /opt/ms/soft/xtrabackup/backup
innobackupex-1.5.1 --copy-back /opt/ms/soft/xtrabackup/backup
3.        Recovery DB
Using binary logs recovery DB
mysqlbinlog --start-position=3335 mysql-bin.000003 |mysql -uroot -P3309 test

2.1.2.6        Result
1.        Backup smooth, impact DB lowest
2.        After restore DB, can use binary logs to recovery DB.
3.        Can recovery to point time.
2.1.2.7        Positive
1.        Can compress backup file while backup, so it’s occupy fewer storage
2.        Support increment backup
3.        Need lower CPU
2.1.2.8        Negative
1.        After backup innodb data, need to backup .frm more
2.        When encounter err need buy support or research the code.
3#
发表于 2013-5-15 15:01:24 | 只看该作者
你是想发手册吧
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|申请友链|小黑屋|Archiver|手机版|MySQL社区 ( 京ICP备07012489号   
联系人:周生; 联系电话:13911732319

GMT+8, 2024-4-24 16:38 , Processed in 0.085123 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表