Preface
 
    Today,I'm gonna use the Xtrabackup tool to demonstrate the procedure of backing up MySQL db server.The lastest version of Xtrabackup is 2.4.11 nowadays,but i'd rather choose the 2.4.4 version which is more popular now.Here we go.
 
Procedure
 
 ###Download the Xtrabackup tool.###
#wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.4/\
> binary/redhat//x86_64/percona-xtrabackup--2.4.-.el7.x86_64.rpm
---- ::-- https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.4/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpm
Resolving www.percona.com (www.percona.com)... 74.121.199.234
Connecting to www.percona.com (www.percona.com)|74.121.199.234|:... connected.
HTTP request sent, awaiting response... OK
Length: (7.5M) [application/x-redhat-package-manager]
Saving to: ‘percona-xtrabackup--2.4.-.el7.x86_64.rpm’ %[===========================================================================================================>] ,, .4KB/s in 5m 14s -- :: (24.4 KB/s) - ‘percona-xtrabackup--2.4.-.el7.x86_64.rpm’ saved [/] ###Install the Xtrabackup tool.###
[root@zlm1 :: ~]
#yum localinstall percona-xtrabackup--2.4.-.el7.x86_64.rpm
Loaded plugins: fastestmirror
Repodata is over weeks old. Install yum-cron? Or run: yum makecache fast
Examining percona-xtrabackup--2.4.-.el7.x86_64.rpm: percona-xtrabackup--2.4.-.el7.x86_64
Marking percona-xtrabackup--2.4.-.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package percona-xtrabackup-.x86_64 :2.4.-.el7 will be installed
--> Processing Dependency: rsync for package: percona-xtrabackup--2.4.-.el7.x86_64
base | 3.6 kB ::
epel/x86_64/metalink | 6.8 kB ::
epel | 3.2 kB ::
extras | 3.4 kB ::
updates | 3.4 kB ::
(/): base//x86_64/group_gz | kB ::
(/): extras//x86_64/primary_db | kB ::
(/): epel/x86_64/group_gz | kB ::
(/): base//x86_64/primary_db | 5.9 MB ::
(/): updates//x86_64/primary_db | 2.7 MB ::
(/): epel/x86_64/updateinfo | kB ::
(/): epel/x86_64/primary | 3.5 MB ::
Determining fastest mirrors
* base: mirrors.cn99.com
* epel: mirrors.tongji.edu.cn
* extras: ftp.sjtu.edu.cn
* updates: ftp.sjtu.edu.cn
epel /
--> Processing Dependency: libev.so.()(64bit) for package: percona-xtrabackup--2.4.-.el7.x86_64
--> Running transaction check
---> Package libev.x86_64 :4.15-.el7 will be installed
---> Package rsync.x86_64 :3.1.-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =====================================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================================
Installing:
percona-xtrabackup- x86_64 2.4.-.el7 /percona-xtrabackup--2.4.-.el7.x86_64 M
Installing for dependencies:
libev x86_64 4.15-.el7 extras k
rsync x86_64 3.1.-.el7 base k Transaction Summary
=====================================================================================================================================================
Install Package (+ Dependent packages) Total size: M
Total download size: k
Installed size: M
Is this ok [y/d/N]: y
Downloading packages:
(/): libev-4.15-.el7.x86_64.rpm | kB ::
(/): rsync-3.1.-.el7.x86_64.rpm | kB ::
-----------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.0 MB/s | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : rsync-3.1.-.el7.x86_64 /
Installing : libev-4.15-.el7.x86_64 /
Installing : percona-xtrabackup--2.4.-.el7.x86_64 /
Verifying : percona-xtrabackup--2.4.-.el7.x86_64 /
Verifying : libev-4.15-.el7.x86_64 /
Verifying : rsync-3.1.-.el7.x86_64 / Installed:
percona-xtrabackup-.x86_64 :2.4.-.el7 Dependency Installed:
libev.x86_64 :4.15-.el7 rsync.x86_64 :3.1.-.el7 Complete! ###Create a backup user with mixium privileges.###
root@localhost:mysql3306.sock [(none)]::>create user 'bkuser'@'localhost' identified by 'bkuser';
Query OK, rows affected (0.00 sec) root@localhost:mysql3306.sock [(none)]::>grant reload,lock tables,process,replication client on *.* to 'bkuser'@'localhost';
Query OK, rows affected (0.00 sec) root@localhost:mysql3306.sock [(none)]::>flush privileges;
Query OK, rows affected (0.00 sec) root@localhost:mysql3306.sock [(none)]::>select user,host from mysql.user;
+---------------+--------------+
| user | host |
+---------------+--------------+
| repl | 192.168..% |
| bkuser | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+--------------+
rows in set (0.00 sec)

    After install the Xtrabackup,you'll get two programs:xtrabackup & innobackupex.Acturally,both of them can be used to backup or restore the database independently.The innobackupex is a symlink to the xtrabackup C program but in the old version of Xtrabackup it is Perl script.

 ###Generate a backup by innobackex.###
[root@zlm1 :: ~]
#innobackupex --user=bkuser --password=bkuser --defaults-file=/data/mysql/mysql3306/my3306.cnf /data/backup
xtrabackup: Error: --defaults-file must be specified first on the command line -- Error shows that it should be put at first place. [root@zlm1 :: ~]
#innobackupex --defaults-file=/data/mysql/mysql3306/my3306.cnf --user=bkuser --password=bkuser /data/backup
:: innobackupex: Starting the backup operation IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!". Can't locate Digest/MD5.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at - line 693.
BEGIN failed--compilation aborted at - line .
:: Connecting to MySQL server host: localhost, user: bkuser, password: set, port: , socket: /tmp/mysql3306.sock
Using server version 5.7.-log
innobackupex version 2.4. based on MySQL server 5.7. Linux (x86_64) (revision id: df58cf2)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /data/mysql/mysql3306/data
xtrabackup: open files limit requested , set to
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = .
xtrabackup: innodb_data_file_path = ibdata1:100M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group =
xtrabackup: innodb_log_file_size =
xtrabackup: using O_DIRECT
InnoDB: Number of pools:
:: >> log scanned up to ()
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID for mysql/plugin, old maximum was
:: >> log scanned up to ()
:: [] Copying ./ibdata1 to /data/backup/--16_11--/ibdata1
:: >> log scanned up to ()
:: >> log scanned up to ()
:: >> log scanned up to ()
:: [] ...done
:: >> log scanned up to ()
:: [] Copying ./mysql/plugin.ibd to /data/backup/--16_11--/mysql/plugin.ibd
:: [] ...done
:: [] Copying ./mysql/servers.ibd to /data/backup/--16_11--/mysql/servers.ibd
:: [] ...done
-- To simplify the output,I omitt the other innodb *.ibd file copy contents.
:: [] Copying ./zlm/t1.ibd to /data/backup/--16_11--/zlm/t1.ibd
:: [] ...done
:: [] Copying ./zlm/t2.ibd to /data/backup/--16_11--/zlm/t2.ibd
:: [] ...done
:: [] Copying ./zlm/t3.ibd to /data/backup/--16_11--/zlm/t3.ibd
:: [] ...done
:: [] Copying ./zlm/test_flashbk.ibd to /data/backup/--16_11--/zlm/test_flashbk.ibd
:: >> log scanned up to ()
:: [] ...done
:: >> log scanned up to ()
:: [] Copying ./zlm/test.ibd to /data/backup/--16_11--/zlm/test.ibd
:: [] ...done
:: >> log scanned up to ()
:: [] Copying ./zlm/semi_sync_test.ibd to /data/backup/--16_11--/zlm/semi_sync_test.ibd
:: [] ...done
:: >> log scanned up to ()
:: Executing FLUSH NO_WRITE_TO_BINLOG TABLES...
:: Executing FLUSH TABLES WITH READ LOCK... -- Add whole instance read-only lock on tables(but not table locks.)
:: Starting to backup non-InnoDB tables and files
:: [] Copying ./mysql/db.opt to /data/backup/--16_11--/mysql/db.opt
:: [] ...done
:: [] Copying ./mysql/db.frm to /data/backup/--16_11--/mysql/db.frm
:: [] ...done
:: [] Copying ./mysql/db.MYI to /data/backup/--16_11--/mysql/db.MYI
:: [] ...done
:: [] Copying ./mysql/db.MYD to /data/backup/--16_11--/mysql/db.MYD
-- Omitt portion of the contents.
:: [] Copying ./performance_schema/file_summary_by_event_name.frm to /data/backup/--16_11--/performance_schema/file_summary_by_event_name.frm
:: >> log scanned up to ()
:: [] ...done
:: [] Copying ./performance_schema/file_summary_by_instance.frm to /data/backup/--16_11--/performance_schema/file_summary_by_instance.frm
:: [] ...done
-- Omitt portion of the contents.
:: [] Copying ./sys/waits_by_user_by_latency.frm to /data/backup/--16_11--/sys/waits_by_user_by_latency.frm
:: [] ...done
:: >> log scanned up to ()
:: [] Copying ./sys/x@0024innodb_lock_waits.frm to /data/backup/--16_11--/sys/x@0024innodb_lock_waits.frm
:: [] ...done
-- Omitt portion of the contents.
:: [] Copying ./zlm/db.opt to /data/backup/--16_11--/zlm/db.opt
:: [] ...done
:: [] Copying ./zlm/t1.frm to /data/backup/--16_11--/zlm/t1.frm
:: [] ...done
:: [] Copying ./zlm/t2.frm to /data/backup/--16_11--/zlm/t2.frm
:: [] ...done
:: [] Copying ./zlm/t3.frm to /data/backup/--16_11--/zlm/t3.frm
:: [] ...done
:: [] Copying ./zlm/test_flashbk.frm to /data/backup/--16_11--/zlm/test_flashbk.frm
:: [] ...done
:: [] Copying ./zlm/test.frm to /data/backup/--16_11--/zlm/test.frm
:: [] ...done
:: [] Copying ./zlm/semi_sync_test.frm to /data/backup/--16_11--/zlm/semi_sync_test.frm
:: [] ...done
:: [] Writing -help/db.opt
:: [] ...done
:: Finished backing up non-InnoDB tables and files
:: >> log scanned up to ()
:: [] Writing xtrabackup_binlog_info
:: [] ...done
:: Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): ''
xtrabackup: Stopping log copying thread.
. :: >> log scanned up to () :: Executing UNLOCK TABLES -- Release the locks.
:: All tables unlocked
:: [] Copying ib_buffer_pool to /data/backup/--16_11--/ib_buffer_pool
:: [] ...done
:: Backup created in directory '/data/backup/2018-06-16_11-28-59'
MySQL binlog position: filename 'mysql-bin.000046', position '', GTID of the last change '2a4b3562-2ab6-11e8-be7a-080027de0e0e:1-2700058'
:: [] Writing backup-my.cnf
:: [] ...done
:: [] Writing xtrabackup_info
:: [] ...done
xtrabackup: Transaction log of lsn () to () was copied. -- Point the incremental lsn.
:: completed OK! There's an error at the beginning of the backup output below: Can't locate Digest/MD5.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at - line 693.
BEGIN failed--compilation aborted at - line . This is caused by lack of package of perl-Digest-MD5,as the innobackex is coded by perl,but I'm afraid it can be ignored,because I've got "completed OK!" message in the end of screen output. The backup is normally generated,too.see details below. [root@zlm1 :: ~]
#ls -l /data/backup
total
drwxr-x--- root root Jun : --16_11-- -- All the backup data and informations stored in this directory. [root@zlm1 :: /data/backup]
#cd /data/backup/--16_11--/ [root@zlm1 :: /data/backup/--16_11--]
#ls -l
total
-rw-r----- root root Jun : backup-my.cnf
drwxr-x--- root root Jun : -help
-rw-r----- root root Jun : ib_buffer_pool
-rw-r----- root root Jun : ibdata1
drwxr-x--- root root Jun : mysql
drwxr-x--- root root Jun : performance_schema
drwxr-x--- root root Jun : sys
-rw-r----- root root Jun : xtrabackup_binlog_info -- Contains the binlog position info.
-rw-r----- root root Jun : xtrabackup_checkpoints -- Contains teh checkpoint info.
-rw-r----- root root Jun : xtrabackup_info -- Contains the Whole info.
-rw-r----- root root Jun : xtrabackup_logfile -- It's a binary file which contains logfile info.
drwxr-x--- root root Jun : zlm [root@zlm1 :: /data/backup/--16_11--]
#cat xtrabackup_binlog_info
mysql-bin. 2a4b3562-2ab6-11e8-be7a-080027de0e0e:- [root@zlm1 :: /data/backup/--16_11--]
#cat xtrabackup_checkpoints
backup_type = full-backuped
from_lsn =
to_lsn =
last_lsn =
compact =
recover_binlog_info = [root@zlm1 :: /data/backup/--16_11--]
#cat xtrabackup_info
uuid = bad60a4a--11e8-978f-080027de0e0e
name =
tool_name = innobackupex
tool_command = --defaults-file=/data/mysql/mysql3306/my3306.cnf --user=bkuser --password=... /data/backup
tool_version = 2.4.
ibbackup_version = 2.4.
server_version = 5.7.-log
start_time = -- ::
end_time = -- ::
lock_time =
binlog_pos = filename 'mysql-bin.000046', position '', GTID of the last change '2a4b3562-2ab6-11e8-be7a-080027de0e0e:1-2700058'
innodb_from_lsn =
innodb_to_lsn =
partial = N
incremental = N
format = file
compact = N
compressed = N
encrypted = N [root@zlm1 :: /data/backup/--16_11--]
#strings xtrabackup_logfile
xtrabkup ::
:/mysql/gtid_executed.ibd
F^<.
$2a4b3562-2ab6-11e8-be7a-080027de0e0e
./mysql/gtid_executed.ibd
./mysql/gtid_executed.ibd
F^=K8
F^=s8
F^=|
size

    Let's see the detail in the general.log file below.It seems very short and simple.Obviously,xtrabckup will also hold lock when backing up like mysqldump does.The time period depents on the amounts of  non-innodb tables.

 [root@zlm1 :: /data/mysql/mysql3306/data]
#cat zlm1.log --16T09::.361317Z Connect bkuser@localhost on using Socket
--16T09::.361444Z Query SET SESSION wait_timeout=
--16T09::.361590Z Query SHOW VARIABLES
--16T09::.364391Z Query SHOW ENGINE INNODB STATUS
--16T09::.442559Z Query SET SESSION lock_wait_timeout=
--16T09::.442693Z Query FLUSH NO_WRITE_TO_BINLOG TABLES -- Finish *.idb file copy operation.
--16T09::.444503Z Query FLUSH TABLES WITH READ LOCK -- There is also FTWRL lock here.
--16T09::.361073Z Query SHOW MASTER STATUS
--16T09::.361330Z Query SHOW VARIABLES
--16T09::.384043Z Query FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS -- Finish redo copy operation.
--16T09::.587336Z Query UNLOCK TABLES -- Release the locks on table.It has spent three seconds in all to hold FTWRL.
--16T09::.600570Z Query SELECT UUID()
--16T09::.600794Z Query SELECT VERSION()
--16T09::.804252Z Quit
Summary
  • Xtrabackup is more like a physical backup tool compared with mysqldump,which is usually used to backup whole database.
  • FTWRL is inevitable when backing up by Xtrabackup.The holding time depends on the amount of non-innodb tables.
  • Furthermore,Xtrabackup supports parallel and incremental backup which mysqldump doesn't support.

MySQL备份恢复之Xtrabackup的更多相关文章

  1. mysql 备份软件 Xtrabackup 的 xtrabackup_binlog_pos_innodb和xtrabackup_binlog_info 文件区别

    今天在操作 innobackupex 的时候,执行 change master to 的时候发现  xtrabackup_binlog_pos_innodb   xtrabackup_binlog_i ...

  2. MySQL备份利器-xtrabackup的介绍和原理(附脑图)

    标签(linux): mysql-xtrabackup 笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 xtrabackup是Percona公司针对mysql数据 ...

  3. MySQL备份恢复工具Xtrabackup

    参考文档https://www.cnblogs.com/youkanyouxiao/p/8335173.html Xtrabackup介绍  Xtrabackup是由percona开源的免费数据库热备 ...

  4. Mysql备份工具Xtrabackup

    Xtrabackup是一个开源的免费的热备工具,在Xtrabackup包中主要有Xtrabackup和innobackupex两个工具.其中Xtrabackup只能备份InnoDB和XtraDB两种引 ...

  5. Mysql 备份恢复之 Mysqldump 工具

    目前正在学习中,看到mysqldump工具导出的数据都是文本形式的,如果是blob或text大对象类型导出的是什么格式的?这个需要后续研究.下面只先总结下简单的. 一.备份1.备份Mysql一个数据库 ...

  6. MySQL备份恢复之mysqldump

      Preface       The day before yesterday,there's a motif about the lock procedure when backing up My ...

  7. MySQL备份之XtraBackup工具使用

    数据库的完整备份 [root@vhost1 ~]# innobackupex --defaults-file=/mysqldata/3306/my.cnf  --user=root   --passw ...

  8. MySQL备份恢复之mydumper

      Preface       In my previous two blogs,we have known about the tool of backing up MySQL db.I'm gon ...

  9. centos shell编程6一些工作中实践脚本 nagios监控脚本 自定义zabbix脚本 mysql备份脚本 zabbix错误日志 直接送给bc做计算 gzip innobackupex/Xtrabackup 第四十节课

    centos   shell编程6一些工作中实践脚本   nagios监控脚本 自定义zabbix脚本 mysql备份脚本 zabbix错误日志  直接送给bc做计算  gzip  innobacku ...

随机推荐

  1. 从零开始的全栈工程师——JS面向对象(复习)

    作用域 栈内存:js执行的环境堆内存:存放代码块的空间 存放方式 键值对形式存放 字符串的形式存放js在执行之前 浏览器会给他一个全局作用域叫window 每个作用域下都分为两个模块 一个是内存模块一 ...

  2. 【转载】win7mysql5.7.18免安装配置教程

    闲着没事,装个mysql试试,小编以前都是用的linux,感觉mysql安装就是傻瓜式操作啊,第一次在windows系统上装,感觉出了很多问题,现在将整个过程分享给大家,希望大家在安装的时候少走弯路. ...

  3. CSS3 常用新特性总结

    更新于(2017.07.07)会总结项目中比较常用的有些CSS属性 伪类选择器 E:first-of-type: 匹配同类型中的第一个同级兄弟元素E E:last-of-type: 匹配同类型中的最后 ...

  4. ECMAscript 变量作用域

    使用var操作符声明的变量与未使用var操作符声明的变量区别 未使用var操作符声明 function test() { message='hi'; console.log(message); } c ...

  5. Git回退到指定节点的版本

    1.获取某个历史版本的id(即change-id,每个版本唯一) 方法1:使用git log命令查看所有的历史版本,输入q便可退出. git log 方法2:使用gitk图形化界面查看节点信息.(在安 ...

  6. ASP.NET MVC 音乐商店 - 5 通过支架创建编辑表单 续

    查看 StoreManager 控制器的代码 现在,Store Manager 控制器中已经包含了一定数量的代码,我们从头到尾重新过一下. 首先,在控制器中包含了标准的 MVC 控制器的代码,为了使用 ...

  7. 【起航计划 037】2015 起航计划 Android APIDemo的魔鬼步伐 36 App->Service->Remote Service Binding AIDL实现不同进程间调用服务接口 kill 进程

    本例和下个例子Remote Service Controller 涉及到的文件有RemoteService.java ,IRemoteService.aidl, IRemoteServiceCallb ...

  8. Filter学习总结,顺便提及点servlet3.0异步filter和异步监听

      Filter介绍:     Filter在项目中经常可以用到,通常配置在web.xml中.是服务器端的一个组件,对于用户的请求和响应数据进行过滤操作,控制是否让用户访问到对应的web资源.常用于编 ...

  9. 基于CAS的SSO单点登录-实现ajax跨域访问的自动登录(也相当于超时重连)

    先补课,以下网址可以把CAS环境搭起来. [JA-SIG CAS服务环境搭建]http://linliangyi2007.iteye.com/blog/165307 [JA-SIG CAS业务架构介绍 ...

  10. JAVA利用jxl读取Excel内容

    JAVA可以利用jxl简单快速的读取文件的内容,但是由于版本限制,只能读取97-03  xls格式的Excel. import java.io.File; import java.io.FileInp ...