MySQL备份恢复之Xtrabackup
###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
- 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的更多相关文章
- mysql 备份软件 Xtrabackup 的 xtrabackup_binlog_pos_innodb和xtrabackup_binlog_info 文件区别
今天在操作 innobackupex 的时候,执行 change master to 的时候发现 xtrabackup_binlog_pos_innodb xtrabackup_binlog_i ...
- MySQL备份利器-xtrabackup的介绍和原理(附脑图)
标签(linux): mysql-xtrabackup 笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 xtrabackup是Percona公司针对mysql数据 ...
- MySQL备份恢复工具Xtrabackup
参考文档https://www.cnblogs.com/youkanyouxiao/p/8335173.html Xtrabackup介绍 Xtrabackup是由percona开源的免费数据库热备 ...
- Mysql备份工具Xtrabackup
Xtrabackup是一个开源的免费的热备工具,在Xtrabackup包中主要有Xtrabackup和innobackupex两个工具.其中Xtrabackup只能备份InnoDB和XtraDB两种引 ...
- Mysql 备份恢复之 Mysqldump 工具
目前正在学习中,看到mysqldump工具导出的数据都是文本形式的,如果是blob或text大对象类型导出的是什么格式的?这个需要后续研究.下面只先总结下简单的. 一.备份1.备份Mysql一个数据库 ...
- MySQL备份恢复之mysqldump
Preface The day before yesterday,there's a motif about the lock procedure when backing up My ...
- MySQL备份之XtraBackup工具使用
数据库的完整备份 [root@vhost1 ~]# innobackupex --defaults-file=/mysqldata/3306/my.cnf --user=root --passw ...
- MySQL备份恢复之mydumper
Preface In my previous two blogs,we have known about the tool of backing up MySQL db.I'm gon ...
- centos shell编程6一些工作中实践脚本 nagios监控脚本 自定义zabbix脚本 mysql备份脚本 zabbix错误日志 直接送给bc做计算 gzip innobackupex/Xtrabackup 第四十节课
centos shell编程6一些工作中实践脚本 nagios监控脚本 自定义zabbix脚本 mysql备份脚本 zabbix错误日志 直接送给bc做计算 gzip innobacku ...
随机推荐
- Linux 套接字编程 - TCP连接基础
第五章的内容,实现一个echo服务器和对应的客户端,主要收获: 0. TCP socket编程主要基本步骤 1. SIGCHLD信号含义(子进程退出时向父进程发送,提醒父进程对其状态信息进行一个获取) ...
- Android 自定义AlertDialog的写法和弹出软键盘和覆盖状态栏
private void showMyDialog(int layoutId){ AlertDialog myDialog = new AlertDialog.Builder(context).cre ...
- C++之不带指针类的设计——Boolean
经典的类设计分类 带指针类 不带指针类 Header文件的布局 #ifndef __COMPLEX__ #define __COMPLEX__ #include <iostream.h> ...
- java maven项目 导入jar包注意
1.将jar 包放到lib目录下 2.build path 3.点击maven主项目右键选择properties 4.选择myeclipse 下的第一个选项 5.点击add 选择archives ...
- 路由 vue-router
vue-router官方文档 1.router跳转页面 编程式的导航 this.$router.push('/index'); 2.mode Router构造配置 const router = new ...
- day3-基础 列表,元组,字典,模块
1.列表 列表是我们最以后最常用的数据类型之一,通过列表可以对数据实现最方便的存储.修改等操作 定义列表 Country = ['China','England','America'] 通过下标访问列 ...
- ZooKeeper 典型应用场景-Master选举
master选举 1.使用场景及结构 现在很多时候我们的服务需要7*24小时工作,假如一台机器挂了,我们希望能有其它机器顶替它继续工作.此类问题现在多采用master-salve模式,也就是常说的主从 ...
- OA环境搭建及卸载操作帮助文档
目 录 项目介绍 JDK的安装与验证 1.安装JDK 2.添加环境变量 3.验证JDK MySql的安装与验 1.安装MySql 2.登录Mysql帐号 3.导入数据库 Tomcat的安装与验证 ...
- 让免费版MarkdownPad2使用Pro版本的功能
让免费版MarkdownPad2使用Pro版本的功能 找到配置文件 启用Markdown扩展模式 Markdown处理器:Github风格 语法检查设置 自动保存设置 找到配置文件 一般在用户的数据目 ...
- Android(java)学习笔记58:Android 英文朗诵
1. 首先,我先把代码放到下面: package com.himi.speaker; import java.util.Locale; import android.app.Activity; imp ...