mysql备份工具之Xtrabackup
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.全备份时压缩以节省资源

热AI工具

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

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

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

MySQL在Web应用中的主要作用是存储和管理数据。1.MySQL高效处理用户信息、产品目录和交易记录等数据。2.通过SQL查询,开发者能从数据库提取信息生成动态内容。3.MySQL基于客户端-服务器模型工作,确保查询速度可接受。

InnoDB使用redologs和undologs确保数据一致性和可靠性。1.redologs记录数据页修改,确保崩溃恢复和事务持久性。2.undologs记录数据原始值,支持事务回滚和MVCC。

MySQL与其他编程语言相比,主要用于存储和管理数据,而其他语言如Python、Java、C 则用于逻辑处理和应用开发。 MySQL以其高性能、可扩展性和跨平台支持着称,适合数据管理需求,而其他语言在各自领域如数据分析、企业应用和系统编程中各有优势。

MySQL适合Web应用和内容管理系统,因其开源、高性能和易用性而受欢迎。1)与PostgreSQL相比,MySQL在简单查询和高并发读操作上表现更好。2)相较Oracle,MySQL因开源和低成本更受中小企业青睐。3)对比MicrosoftSQLServer,MySQL更适合跨平台应用。4)与MongoDB不同,MySQL更适用于结构化数据和事务处理。

MySQL的基本操作包括创建数据库、表格,及使用SQL进行数据的CRUD操作。1.创建数据库:CREATEDATABASEmy_first_db;2.创建表格:CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY,titleVARCHAR(100)NOTNULL,authorVARCHAR(100)NOTNULL,published_yearINT);3.插入数据:INSERTINTObooks(title,author,published_year)VA

InnoDBBufferPool通过缓存数据和索引页来减少磁盘I/O,提升数据库性能。其工作原理包括:1.数据读取:从BufferPool中读取数据;2.数据写入:修改数据后写入BufferPool并定期刷新到磁盘;3.缓存管理:使用LRU算法管理缓存页;4.预读机制:提前加载相邻数据页。通过调整BufferPool大小和使用多个实例,可以优化数据库性能。

MySQL通过表结构和SQL查询高效管理结构化数据,并通过外键实现表间关系。1.创建表时定义数据格式和类型。2.使用外键建立表间关系。3.通过索引和查询优化提高性能。4.定期备份和监控数据库确保数据安全和性能优化。

MySQL值得学习,因为它是强大的开源数据库管理系统,适用于数据存储、管理和分析。1)MySQL是关系型数据库,使用SQL操作数据,适合结构化数据管理。2)SQL语言是与MySQL交互的关键,支持CRUD操作。3)MySQL的工作原理包括客户端/服务器架构、存储引擎和查询优化器。4)基本用法包括创建数据库和表,高级用法涉及使用JOIN连接表。5)常见错误包括语法错误和权限问题,调试技巧包括检查语法和使用EXPLAIN命令。6)性能优化涉及使用索引、优化SQL语句和定期维护数据库。
