0608MySQL备份与恢复之percona-xtrabackup软件的使用【基础】
转自http://blog.csdn.net/justdb/article/details/17054579
一 使用percona-xtrabackup的原因
在前面,我们讲到MySQL冷备、热备、mysqldump、热拷贝、保证数据的一致性。因为mysql冷备、mysqldump、mysql热拷贝均不能实现增量备份,在实际环境中增量备份是使用较多的,percona-xtrabackup就是为实现增量备份而生,因此我们需要使用percona-xtrabackup。
本文讲解percona-xtrabackup软件的使用,下一篇文章讲解percona-xtrabackup实现增量备份及恢复。
二 什么是percona-xtrabackup
Percona XtraBackup is an open-source hot backup utility for MySQL -based servers that doesn’t lock your database during the backup.
It can back up data from InnoDB, XtraDB,and MyISAM tableson MySQL 5.1 [1], 5.5 and5.6 servers, as well as Percona Server with XtraDB.For a high-level overview of many of its advanced features, including a featurecomparison, please see AboutPercona Xtrabackup.
Whether it is a 24x7 highly loaded server or alow-transaction-volume environment, Percona XtraBackup isdesigned to make backups a seamless procedure without disrupting theperformance of the server in a production environment.Commercial support contracts areavailable.
Percona XtraBackup is a combination of the xtrabackup C program,and the innobackupex Perl script. The xtrabackupprogramcopies and manipulates InnoDB and XtraDB datafiles, and the Perl script enables enhanced functionality,such as interacting with a running MySQL server and backing up MyISAM tables.
三 软件及文档获取
软件获取
http://www.percona.com/software/percona-xtrabackup/downloads
http://download.csdn.net/detail/wentasy/6638171
文档获取
http://www.percona.com/doc/percona-xtrabackup/2.1/
http://download.csdn.net/detail/wentasy/6638029
四 软件使用讲解
注:本文采用的percona-xtrabackup版本为2.0.2,操作系统版本为RHEL 6.1 Server,MySQL版本为5.1
第一步,准备文件并拷贝文件
[root@larrywen ule-mysql]# ll percona-xtrabackup-2.0.2-461.rhel6.x86_64.rpm
-rwxr-xr-x. 1 root root 3786628 Sep 10 13:45 percona-xtrabackup-2.0.2-461.rhel6.x86_64.rpm [root@larrywen ule-mysql]# scp percona-xtrabackup-2.0.2-461.rhel6.x86_64.rpm 192.168.1.11:/opt
第二步,该软件需要依赖MySQL客户端,所以使用yum安装。注意,此处安装的只是MySQL的客户端,和本身使用源码安装的MySQL不冲突
[root@serv01 opt]# yum install percona-xtrabackup-2.0.2-461.rhel6.x86_64.rpm -y
Installed:
percona-xtrabackup.x86_64 0:2.0.2-461.rhel6 Dependency Installed:
mysql.x86_64 0:5.1.52-1.el6_0.1
第三步,初始化备份
[root@serv01 databackup]# innobackupex --user=root --password=123456 /databackup/
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012. All Rights Reserved. ……
innobackupex: Backup created in directory '/databackup/2013-09-10_21-49-44'
innobackupex: MySQL binlog position: filename 'mysql-bin.000001', position 7312
130910 21:50:03 innobackupex: completed OK!
第四步,这样的备份文件无法使用,我们需要做统一检查
[root@serv01 databackup]# ll
total 4
drwxr-xr-x. 9 root root 4096 Sep 10 21:50 2013-09-10_21-49-44 #做统一检查
[root@serv01 databackup]# innobackupex --apply-log /databackup/2013-09-10_21-49-44/ InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012. All Rights Reserved.
……
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
130910 21:51:52 InnoDB: Starting shutdown...
130910 21:51:56 InnoDB: Shutdown completed; log sequence number 2098188
130910 21:51:56 innobackupex: completed OK!
第五步,模拟数据丢失
[root@serv01 databackup]# rm -rf /usr/local/mysql/data/*
[root@serv01 databackup]# ll /usr/local/mysql/data/
total 0
第六步,恢复数据
[root@serv01 databackup]# innobackupex --copy-back /databackup/2013-09-10_21-49-44/ InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012. All Rights Reserved.
……
innobackupex: Starting to copy InnoDB system tablespace
innobackupex: in '/databackup/2013-09-10_21-49-44'
innobackupex: back to original InnoDB data directory '/usr/local/mysql/data'
innobackupex: Copying file '/databackup/2013-09-10_21-49-44/ibdata1' innobackupex: Starting to copy InnoDB log files
innobackupex: in '/databackup/2013-09-10_21-49-44'
innobackupex: back to original InnoDB log directory '/usr/local/mysql/data'
innobackupex: Finished copying back files. 130910 22:02:29 innobackupex: completed OK!
第七步,重启mysql服务,发现报错,pkill掉,然后启动一切正常
[root@serv01 databackup]# /etc/init.d/mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/serv01.host.com.pid). #查看恢复的数据目录,拥有者和所属组不是mysql用户,我们更改拥有者和所属组
[root@serv01 databackup]# ll /usr/local/mysql/data/
total 18468
drwxr-xr-x. 2 root root 4096 Sep 10 22:02 game
drwxr-xr-x. 2 root root 4096 Sep 10 22:02 hello
-rw-r-----. 1 root root 18874368 Sep 10 21:51 ibdata1
drwxr-xr-x. 2 root root 4096 Sep 10 22:02 larrydb
drwxr-xr-x. 2 root root 4096 Sep 10 22:02 mnt
drwxr-xr-x. 2 root root 4096 Sep 10 22:02 mysql
-rw-rw----. 1 mysql mysql 0 Sep 10 22:02 mysql-bin.index
drwxr-xr-x. 2 root root 4096 Sep 10 22:02 performance_schema
-rw-r-----. 1 mysql root 771 Sep 10 22:02 serv01.host.com.err
drwxr-xr-x. 2 root root 4096 Sep 10 22:02 test
-rw-r--r--. 1 root root 24 Sep 10 22:02 xtrabackup_binlog_pos_innodb [root@serv01 databackup]# chown mysql.mysql /usr/local/mysql/data/ -R #再次启动,仍然失败,我们杀掉进程,再次启动mysql,正常
[root@serv01 databackup]# /etc/init.d/mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.. ERROR! The server quit without updating PID file (/usr/local/mysql/data/serv01.host.com.pid). [root@serv01 databackup]# ps -ef | grep mysql
root 2386 1 0 18:36 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/serv01.host.com.pid
mysql 2664 2386 0 18:36 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/serv01.host.com.err --pid-file=/usr/local/mysql/data/serv01.host.com.pid --socket=/tmp/mysql.sock --port=3306
root 3022 1490 0 19:39 pts/0 00:00:00 mysql -uroot -px xxxx
root 5021 3040 0 22:05 pts/2 00:00:00 grep mysql
[root@serv01 databackup]# pkill -9 mysql
[root@serv01 databackup]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS! [root@serv01 databackup]# mysql -uroot -p123456
Server version: 5.5.29-log Source distribution
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| game |
| hello |
| larrydb |
| mnt |
| mysql |
| performance_schema |
| test |
+--------------------+
8 rows in set (0.00 sec)
五 参考资料
http://www.percona.com/doc/percona-xtrabackup/2.1/
0608MySQL备份与恢复之percona-xtrabackup软件的使用【基础】的更多相关文章
- MySQL 大数据备份方案之Percona XtraBackup
Xtrabackup介绍 1.Xtrabackup是什么 Xtrabackup是一个对InnoDB做数据备份的工具,支持在线热备份(备份时不影响数据读写),是商业备份工具InnoDB Hotbacku ...
- mysql数据库-备份与还原-Percona XtraBackup 2.4备份工具使用
目录 xtrabackup 特点 备份生成的相关文件 xtrabackup 安装 xtrabackup 用法 1 备份 2 预备份 3 还原 4 其他 还原注意事项 xtrabackup实现完全备份及 ...
- Percona xtrabackup
关于percona xtrabackup percona xtrabackup是世界上唯一开源的.免费的MySQL热备份软件,可以为InnoDB存储引擎和XtraDB存储引擎进行不间断的备份, ...
- Percona Xtrabackup备份mysql(转)
add by zhj:另外,参考了Xtrabackup之innobackupex备份恢复详解,我用的是Xtrabackup2.2.6版本, 可以成功备份和恢复指定的数据库. 原文:http://www ...
- Percona Xtrabackup备份mysql全库及指定数据库(完整备份与增量备份)
原文地址:http://www.tuicool.com/articles/RZRnq2 Xtrabackup简介 Percona XtraBackup是开源免费的MySQL数据库热备份软件,它能对In ...
- 小型网站MYSQL问题二:Percona Xtrabackup实现数据库备份和恢复
1.安装软件仓库(不要问我为什么不用源码安装,好吧,其实我懒.) 1 2 3 4 5 6 7 8 wget https://www.percona.com/downloads/percona-rele ...
- Percona Xtrabackup备份mysql大数据库(完整备份与增量备份)
Percona Xtrabackup备份mysql大数据库(完整备份与增量备份) 文章目录 [隐藏] Xtrabackup简介 Xtrabackup安装 Xtrabackup工具介绍 inno ...
- Percona XtraBackup 备份原理说明【转】
本文来自:http://mysql.taobao.org/monthly/2016/03/07/ 前言 Percona XtraBackup(简称PXB)是 Percona 公司开发的一个用于 MyS ...
- MariaDB之基于Percona Xtrabackup备份大数据库[完整备份与增量备份]
MariaDB之基于Percona Xtrabackup备份大数据库[完整备份与增量备份] 1.Xtrabackup的安装 percona-xtrabackup-2.2.3-4982.el6.x86_ ...
随机推荐
- CodeForces--626C--Block Towers (二分)
Block Towers Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- Anagram Groups(字符串)
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2316 理解错一点题意就能WA到死...题中对于 ...
- 8.19noip模拟题
2017 8.19 NOIP模拟赛 by coolyangzc 共3道题目,时间3小时 题目名 高级打字机 不等数列 经营与开发 源文件 type.cpp/c/pas num.cpp/c/pas ...
- Python 31 TCP协议 、socket套接字
1.TCP协议 可靠传输,TCP数据包没有长度限制,理论上可以无限长,但是为了保证网络的效率,通常TCP数据包的长度不会超过IP数据包的长度,以确保单个TCP数据包不必再分割. (1)三次握手建链接( ...
- P1401 城市(30分,正解网络流)
题目描述 N(2<=n<=200)个城市,M(1<=m<=40000)条无向边,你要找T(1<=T<=200)条从城市1到城市N的路,使得最长的边的长度最小,边不能 ...
- Android App 开机启动画面和开机自动启动APP程序设置
1.当前比较成熟一点的应用基本上都会在进入应用之显示一个启动界面 如腾讯微博 2.准备元素 需要开机启动的图片一张 3.新建Activity AlphaAnimation动画:控制对象alpha水平 ...
- for 循环练习题
X3 * 6528 = 3X * 8256X为一个数字 填入一个数字 使等式成立 for (var x=1;x<=9&&x>0;x++) { if ((x*10+3)*65 ...
- Emmet(Zen Coding)语法规则简介
———Emmet(Zen Coding)语法规则简介——— [Zen Coding可谓快速开发HTML和CSS的利器,主要采用仿css类选择器方式编写代码,以下是该利器的基本语法规则和代码示例] 基础 ...
- AI:恐怖谷理论的陷阱
科学人的小品:恐怖谷:娃娃为什么很可怕? 一.恐怖的来源 恐怖的来源:美学概念.思想对安全的认识,映射到美学领域,转化为美和丑.恐怖,是一种精心掩饰的丑陋. 二.桑尼与C3PO 桑尼更接近于人,为什么 ...
- YTBro Video 2016-07-30 Sat
明日天气:多云转阴,32~24度 运动向 健身 20中极致疯狂的俯卧撑,新手请勿尝试 跑酷 大神放大招,招招见血,不信你看 赛事 2016年世界室内田径锦标赛 男子4×400接力决赛 台球 RP集中爆 ...