首页 数据库 mysql教程 mysql备份工具之Xtrabackup

mysql备份工具之Xtrabackup

Jun 07, 2016 pm 04:42 PM

Xtrabackup是一个对InnoDB存储引擎做数据备份的工具,支持在线热备份(备份时不影响数据读写),是商业备份工具InnoDBHotbackup的一个很好的替代品.Xtrabackup有两个

    Xtrabackup是一个对InnoDB存储引擎做数据备份的工具,支持在线热备份(备份时不影响数据读写),是商业备份工具InnoDB Hotbackup的一个很好的替代品.Xtrabackup有两个主要工具:xtrabackup,innobackupex,且只能备份InnoDB和XtraDB两种存储引擎的表,而不能备份MyISAM数据表

 

1.下载安装xtrabackup工具

[root@tong2 ~]# wget

[root@tong2 ~]# tar xvf Percona-XtraBackup-2.2.7-r5050-el6-x86_64-bundle.tar

[root@tong2 ~]# ll percona-xtrabackup-*
-rw-rw-r--. 1 root root 4863276 Dec  4 22:18 percona-xtrabackup-2.2.7-5050.el6.x86_64.rpm
-rw-rw-r--. 1 root root  648012 Dec  4 22:18 percona-xtrabackup-debuginfo-2.2.7-5050.el6.x86_64.rpm
-rw-rw-r--. 1 root root  961432 Dec  4 22:18 percona-xtrabackup-test-2.2.7-5050.el6.x86_64.rpm[root@tong2 ~]# yum localinstall percona-xtrabackup-*  -y

[root@tong2 ~]# rpm -ql percona-xtrabackup-2.2.7-5050.el6.x86_64
/usr/bin/innobackupex
/usr/bin/xbcrypt
/usr/bin/xbstream
/usr/bin/xtrabackup
/usr/share/doc/percona-xtrabackup-2.2.7
/usr/share/doc/percona-xtrabackup-2.2.7/COPYING
[root@tong2 ~]#

 

 2.创建数据库和innodb表

[root@tong2 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.6.21-log MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \u tong
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> create table t (a int) engine=innodb;
Query OK, 0 rows affected (0.27 sec)

mysql> insert into t values(1),(2),(3),(4),(5);
Query OK, 5 rows affected (0.03 sec)
Records: 5  Duplicates: 0  Warnings: 0

mysql> select * from t;
+------+
| a    |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
|    5 |
+------+
5 rows in set (0.00 sec)

mysql> exit
Bye
[root@tong2 ~]#

 

3.完整备份innodb存储引擎的表

[root@tong2 ~]# innobackupex --help |more     --查看帮助信息

[root@tong2 ~]# innobackupex --user=root --password=system /opt/tong 2> /opt/tong/backup.log

[root@tong2 ~]# ll /opt/tong/2015-01-04_16-00-37/
total 12324
-rw-r--r--. 1 root root      295 Jan  4 16:00 backup-my.cnf
-rw-r-----. 1 root root 12582912 Jan  4 16:00 ibdata1
drwx------. 2 root root     4096 Jan  4 16:00 mysql
drwxr-xr-x. 2 root root     4096 Jan  4 16:00 performance_schema
drwxr-xr-x. 2 root root     4096 Jan  4 16:00 test
drwx------. 2 root root     4096 Jan  4 16:00 tong
-rw-r--r--. 1 root root       22 Jan  4 16:00 xtrabackup_binlog_info           --二进制日志信息
-rw-r-----. 1 root root       89 Jan  4 16:00 xtrabackup_checkpoints         --备份数据的检查点
-rw-r--r--. 1 root root      553 Jan  4 16:00 xtrabackup_info                    --备份信息
-rw-r-----. 1 root root     2560 Jan  4 16:00 xtrabackup_logfile                --日志文件

[root@tong2 ~]# innobackupex --user=root --password=system --databases=tong /opt/tong     --备份指定的数据库2> /opt/tong/backup.log
[root@tong2 ~]# ll /opt/tong/2015-01-04_16-02-36/
total 12312
-rw-r--r--. 1 root root      295 Jan  4 16:02 backup-my.cnf
-rw-r-----. 1 root root 12582912 Jan  4 16:02 ibdata1
drwx------. 2 root root     4096 Jan  4 16:02 tong
-rw-r--r--. 1 root root       22 Jan  4 16:02 xtrabackup_binlog_info
-rw-r-----. 1 root root       89 Jan  4 16:02 xtrabackup_checkpoints
-rw-r--r--. 1 root root      570 Jan  4 16:02 xtrabackup_info
-rw-r-----. 1 root root     2560 Jan  4 16:02 xtrabackup_logfile
[root@tong2 ~]#

 

4.在完整备份中添加增量备份

[root@tong2 ~]# innobackupex --user=root --password=system --incremental --incremental-basedir=/opt/tong/2015-01-04_17-34-25/ /opt/tong    

--incremental     --增量备份

--incremental-basedir    --完整备份文件的路径

/opt/tong                     --增量备份文件存放处

 

5.全备份时压缩以节省资源

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 个月前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
1 个月前 By 尊渡假赌尊渡假赌尊渡假赌
威尔R.E.P.O.有交叉游戏吗?
1 个月前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

说明InnoDB全文搜索功能。 说明InnoDB全文搜索功能。 Apr 02, 2025 pm 06:09 PM

InnoDB的全文搜索功能非常强大,能够显着提高数据库查询效率和处理大量文本数据的能力。 1)InnoDB通过倒排索引实现全文搜索,支持基本和高级搜索查询。 2)使用MATCH和AGAINST关键字进行搜索,支持布尔模式和短语搜索。 3)优化方法包括使用分词技术、定期重建索引和调整缓存大小,以提升性能和准确性。

如何使用Alter Table语句在MySQL中更改表? 如何使用Alter Table语句在MySQL中更改表? Mar 19, 2025 pm 03:51 PM

本文讨论了使用MySQL的Alter Table语句修改表,包括添加/删除列,重命名表/列以及更改列数据类型。

与MySQL中使用索引相比,全表扫描何时可以更快? 与MySQL中使用索引相比,全表扫描何时可以更快? Apr 09, 2025 am 12:05 AM

全表扫描在MySQL中可能比使用索引更快,具体情况包括:1)数据量较小时;2)查询返回大量数据时;3)索引列不具备高选择性时;4)复杂查询时。通过分析查询计划、优化索引、避免过度索引和定期维护表,可以在实际应用中做出最优选择。

可以在 Windows 7 上安装 mysql 吗 可以在 Windows 7 上安装 mysql 吗 Apr 08, 2025 pm 03:21 PM

是的,可以在 Windows 7 上安装 MySQL,虽然微软已停止支持 Windows 7,但 MySQL 仍兼容它。不过,安装过程中需要注意以下几点:下载适用于 Windows 的 MySQL 安装程序。选择合适的 MySQL 版本(社区版或企业版)。安装过程中选择适当的安装目录和字符集。设置 root 用户密码,并妥善保管。连接数据库进行测试。注意 Windows 7 上的兼容性问题和安全性问题,建议升级到受支持的操作系统。

如何为MySQL连接配置SSL/TLS加密? 如何为MySQL连接配置SSL/TLS加密? Mar 18, 2025 pm 12:01 PM

文章讨论了为MySQL配置SSL/TLS加密,包括证书生成和验证。主要问题是使用自签名证书的安全含义。[角色计数:159]

哪些流行的MySQL GUI工具(例如MySQL Workbench,PhpMyAdmin)是什么? 哪些流行的MySQL GUI工具(例如MySQL Workbench,PhpMyAdmin)是什么? Mar 21, 2025 pm 06:28 PM

文章讨论了流行的MySQL GUI工具,例如MySQL Workbench和PhpMyAdmin,比较了它们对初学者和高级用户的功能和适合性。[159个字符]

InnoDB中的聚类索引和非簇索引(次级索引)之间的差异。 InnoDB中的聚类索引和非簇索引(次级索引)之间的差异。 Apr 02, 2025 pm 06:25 PM

聚集索引和非聚集索引的区别在于:1.聚集索引将数据行存储在索引结构中,适合按主键查询和范围查询。2.非聚集索引存储索引键值和数据行的指针,适用于非主键列查询。

您如何处理MySQL中的大型数据集? 您如何处理MySQL中的大型数据集? Mar 21, 2025 pm 12:15 PM

文章讨论了处理MySQL中大型数据集的策略,包括分区,碎片,索引和查询优化。

See all articles