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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners because it is easy to use and powerful. 1.MySQL is a relational database, and uses SQL for CRUD operations. 2. It is simple to install and requires the root user password to be configured. 3. Use INSERT, UPDATE, DELETE, and SELECT to perform data operations. 4. ORDERBY, WHERE and JOIN can be used for complex queries. 5. Debugging requires checking the syntax and use EXPLAIN to analyze the query. 6. Optimization suggestions include using indexes, choosing the right data type and good programming habits.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.
