PerconaXtraBackupistheworld’sonlyopen-source,freeMySQLhotbackupsoftwarethatperformsnon-blockingbackupsforInnoDBandXtraDBdatabases.WithPerconaXtraBack
Percona XtraBackup is the world’s only open-source, free MySQL hot backup software that performs non-blocking backups for InnoDB and XtraDB databases. With Percona XtraBackup, you can achieve the following benefits:
以上摘自官方文档对Xtrabackup的描述。
Xtrabackup是Percona公司的开源mysql热备软件,软件自身支持完全备份和增量备份,功能强大,使用简单,且备份结束会自动检查备份的可用性。对于InnoDB和XtraDB可以实现无阻塞的备份。
Xtrabackup会在备份目录下自动生成以当前日期和时间为名的目录,目录下包含当前备份所有数据文件和丰富的当前备份时的状态信息。
实例演示:
xtrabackup的安装,安装包可从官网下载,官方提供了二进制和源码包,根据自己需要下载
/* 下载官方的rpm包安装,xtrabackup要依赖perl-DBD-mysql包,不想手动解决依赖关系可以yum localinstall安装 */ [root@console ~]# yum localinstall --nogpgcheck percona-xtrabackup-2.1.4-656.rhel6.x86_64.rpm -y /* xtrabackup安装后生成的文件不多 */ [root@console ~]# rpm -ql percona-xtrabackup /usr/bin/innobackupex /* 备份时用的命令,会根据mysql版本自动调用xtrabackup_{55,56} */ /usr/bin/innobackupex-1.5.1 /usr/bin/xbcrypt /* 提供备份过程加密支持 */ /usr/bin/xbstream /* 支持流式备份 */ /usr/bin/xtrabackup /usr/bin/xtrabackup_55 / * 这个和下面那个才是备份过程实际调用的备份程序 */ /usr/bin/xtrabackup_56 /usr/share/doc/percona-xtrabackup-2.1.4 /usr/share/doc/percona-xtrabackup-2.1.4/COPYING /* 文档只有一个软件授权文件,没有man文档,不过--help给出的帮助信息也比较丰富 */备份过程:
/* 在库db1中准备一张表tb1,做效果比较用 */ MariaDB [(none)]> CREATE DATABASE db1; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> USE db1 Database changed MariaDB [db1]> CREATE TABLE `tb1` ( `id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(30) NOT NULL, `Gender` enum('F','M','O') NOT NULL, PRIMARY KEY (`id`) ); Query OK, 0 rows affected (0.22 sec) MariaDB [db1]> DESC tb1; +--------+-------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | Name | varchar(30) | NO | | NULL | | | Gender | enum('F','M','O') | NO | | NULL | | +--------+-------------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec) MariaDB [db1]> INSERT INTO tb1 (Name,Gender) VALUES ('Tom','M'),('Jerry','F'); Query OK, 2 rows affected (0.05 sec) Records: 2 Duplicates: 0 Warnings: 0 MariaDB [db1]> SELECT * FROM tb1; +----+-------+--------+ | id | Name | Gender | +----+-------+--------+ | 1 | Tom | M | | 2 | Jerry | F | +----+-------+--------+ 2 rows in set (0.00 sec) /* 创建一个用于备份的最小权限的用户 */ MariaDB [(none)]> CREATE USER 'bakuser'@'localhost' IDENTIFIED BY 'backupass'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> REVOKE ALL PRIVILEGES,GRANT OPTION FROM 'bakuser'@'localhost'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT RELOAD,LOCK TABLES,REPLICATION CLIENT ON *.* TO 'bakuser'@'localhost'; Query OK, 0 rows affected (0.00 sec)现在先做一次完全备份:
/* 全备只需指定用于备份的用户名、密码和备份路径即可,最后出现innobackupex: completed OK! 则代表备份成功 */ [root@node1 ~]# innobackupex --user=bakuser --password=backupass /innobackup/ innobackupex: Backup created in directory '/innobackup/2014-07-31_09-27-36' innobackupex: MySQL binlog position: filename 'mysql-bin.000001', position 1270 140731 09:27:39 innobackupex: Connection to database server closed 140731 09:27:40 innobackupex: completed OK! /* 看一下备份都生成了哪些文件,除了数据库文件外还多了一些文件,注意由于我用root登陆系统,备份后的文件属主属组都是root,恢复后要改为运行mysqld进程的用户,不然mysql起不来 */ [root@node1 ~]# cd /innobackup/2014-07-31_09-27-36/ [root@node1 2014-07-31_09-27-36]# ll total 18476 -rw-r--r--. 1 root root 260 Jul 31 09:27 backup-my.cnf /* 备份命令用到的配置选项信息 */ drwx------. 2 root root 4096 Jul 31 09:27 db1 drwx------. 2 root root 4096 Jul 31 09:27 hellodb -rw-r-----. 1 root root 18874368 Jul 31 09:27 ibdata1 drwx------. 2 root root 4096 Jul 31 09:27 mydb drwxr-xr-x. 2 root root 4096 Jul 31 09:27 mysql drwxr-xr-x. 2 root root 4096 Jul 31 09:27 performance_schema drwxr-xr-x. 2 root root 4096 Jul 31 09:27 test -rw-r--r--. 1 root root 13 Jul 31 09:27 xtrabackup_binary /* 记录备份过程实际用的备份程序 */ -rw-r--r--. 1 root root 24 Jul 31 09:27 xtrabackup_binlog_info /* 记录备份时的二进制日志文件和当前的位置 */ -rw-r-----. 1 root root 89 Jul 31 09:27 xtrabackup_checkpoints /* 记录备份类型、 状态(是否prepared)、是否压缩、备份的LSN(Log Serial Number日志序列号)范围等信息 */ -rw-r-----. 1 root root 2560 Jul 31 09:27 xtrabackup_logfile /* xtrabackup自己的日志文件,新版本中不直接可见 */ [root@node1 2014-07-31_09-27-36]# cat backup-my.cnf # This MySQL options file was generated by innobackupex. # The MySQL server [mysqld] innodb_data_file_path=ibdata1:10M:autoextend innodb_log_files_in_group=2 innodb_log_file_size=5242880 innodb_fast_checksum=0 innodb_page_size=16384 innodb_log_block_size=512 [root@node1 2014-07-31_09-27-36]# cat xtrabackup_binary xtrabackup_55[root@node1 2014-07-31_09-27-36]# [root@node1 2014-07-31_09-27-36]# cat xtrabackup_binlog_info mysql-bin.000001 1270 [root@node1 2014-07-31_09-27-36]# cat xtrabackup_checkpoints backup_type = full-backuped from_lsn = 0 to_lsn = 1660869 last_lsn = 1660869 compact = 0 [root@node1 2014-07-31_09-27-36]# file xtrabackup_logfile xtrabackup_logfile: data
MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

The MySQL learning path includes basic knowledge, core concepts, usage examples, and optimization techniques. 1) Understand basic concepts such as tables, rows, columns, and SQL queries. 2) Learn the definition, working principles and advantages of MySQL. 3) Master basic CRUD operations and advanced usage, such as indexes and stored procedures. 4) Familiar with common error debugging and performance optimization suggestions, such as rational use of indexes and optimization queries. Through these steps, you will have a full grasp of the use and optimization of MySQL.

MySQL's real-world applications include basic database design and complex query optimization. 1) Basic usage: used to store and manage user data, such as inserting, querying, updating and deleting user information. 2) Advanced usage: Handle complex business logic, such as order and inventory management of e-commerce platforms. 3) Performance optimization: Improve performance by rationally using indexes, partition tables and query caches.

SQL commands in MySQL can be divided into categories such as DDL, DML, DQL, DCL, etc., and are used to create, modify, delete databases and tables, insert, update, delete data, and perform complex query operations. 1. Basic usage includes CREATETABLE creation table, INSERTINTO insert data, and SELECT query data. 2. Advanced usage involves JOIN for table joins, subqueries and GROUPBY for data aggregation. 3. Common errors such as syntax errors, data type mismatch and permission problems can be debugged through syntax checking, data type conversion and permission management. 4. Performance optimization suggestions include using indexes, avoiding full table scanning, optimizing JOIN operations and using transactions to ensure data consistency.

InnoDB achieves atomicity through undolog, consistency and isolation through locking mechanism and MVCC, and persistence through redolog. 1) Atomicity: Use undolog to record the original data to ensure that the transaction can be rolled back. 2) Consistency: Ensure the data consistency through row-level locking and MVCC. 3) Isolation: Supports multiple isolation levels, and REPEATABLEREAD is used by default. 4) Persistence: Use redolog to record modifications to ensure that data is saved for a long time.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

InnoDB effectively prevents phantom reading through Next-KeyLocking mechanism. 1) Next-KeyLocking combines row lock and gap lock to lock records and their gaps to prevent new records from being inserted. 2) In practical applications, by optimizing query and adjusting isolation levels, lock competition can be reduced and concurrency performance can be improved.


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment