search
HomeDatabaseMysql Tutorial利用XtrabBackup工具备份及恢复

Xtrabackup 是percona的一个开源项目,可以热备份innodb ,XtraDB,和MyISAM(会锁表),可以看做是InnoDB Hotbackup的免费替代品

Xtrabackup------MySQL DBA的必备工具

注意:

1)文档参照:start

2)mysql要使用5.1.50版本或以上。

一、Xtrabackup简介及安装

1、Xtrabackup  是percona的一个开源项目,可以热备份innodb ,,XtraDB,和MyISAM(会锁表),可以看做是InnoDB Hotbackup的免费替代品。

Percona Support for MySQL

BenefitSilver
(Per Server)Gold
(Unlimited)Platinum
(Unlimited)

Annual Price $1,500/server From $15,000 From $30,000

Number of Servers Covered Per-Server Unlimited Unlimited

Number of Support Incidents Unlimited Unlimited Unlimited

Response Time SLA 60 Minutes 30 Minutes 30 Minutes

Named Support Contact Persons 5 10 20

Email, Web, & Chat Support

Yes

Yes

Yes

Phone Support

Yes

Yes

Yes

Login Support

Yes

Yes

Yes

24×7 Support

Yes

Yes

Yes

Fixes For Verified Bugs  

Yes

Yes

Hot Bug Fixes    

Yes

Onsite System Audit   Option

Yes

Covers Old Server Versions    

Yes

Covers Non-Standard Platforms     Option

Covers Custom Code     Option

参考:
 
 
 
先看看如何安装Xtrabackup,最简单的安装方式是使用RPM包,不过想使用源代码方式安装的话,其安装方式有点古怪,因为它采用的在MySQL源代码上打补丁构建的方式安装的。
 
2、安装:
 
wget
 
tar zxf xtrabackup-1.4.tar.gz
 
cd xtrabackup-1.4
 
./configure
 
make
 
进行到这里时,千万别make install,那样就会接着安装MySQL了,正确方法是:
 
cd innobase/xtrabackup/
 
make
 
make install
 
安装参照::installation:from-source
 
3、如此一来,就会在/usr/bin目录里安装上两个有用的工具:xtrabackup、innobackupex
 
1)xtrabackup  只能备份InnoDB和XtraDB两种数据表,支持在线热备份,可以在不加锁的情况备份Innodb数据表,不过此工具不能操作Myisam引擎表
 
2)innobackupex  是一个脚本封装,封装了xtrabackup,能同时处理Innodb和Myisam,但在处理Myisam时需要加一个读锁。
 
 
 
按如上的介绍,由于操作Myisam时需要加读锁,这会堵塞线上服务的写操作,而Innodb没有这样的限制,所以数据库中Innodb表类型所占的比例越大,则越有利。实际应用中一般是直接使用innobackupex方法,它主要有三种操作方式,按手册中的介绍:
 

 

Usage:
 
innobackup [--sleep=MS] [--compress[=LEVEL]] [--include=REGEXP] [--user=NAME]
 
          [--password=WORD] [--port=PORT] [--socket=SOCKET] [--no-timestamp]
 
          [--ibbackup=IBBACKUP-BINARY] [--slave-info] [--stream=tar]
 
          [--defaults-file=MY.CNF]
 
          [--databases=LIST] [--remote-host=HOSTNAME] BACKUP-ROOT-DIR
 
innobackup --apply-log [--use-memory=MB] [--uncompress] [--defaults-file=MY.CNF]
 
          [--ibbackup=IBBACKUP-BINARY] BACKUP-DIR
 
innobackup --copy-back [--defaults-file=MY.CNF] BACKUP-DIR
 
——————————————————————————————————
 
第一个命令行是热备份mysql数据库。
 
带有--apply-log选项的命令是准备在一个备份上启动mysql服务。
 
带有--copy-back选项的命令从备份目录拷贝数据,索引,日志到my.cnf文件里规定的初始位置。
 
Xtrabackup还可以用来moving InnoDB tables between servers,更多的内容可以参考官方文档及例子。 

参考链接:
 
1.官方文档::xtrabackup_manual
 
2.Xtrabackup online backup for InnoDB/XTraDB(pdf):
 

 
推荐阅读:

MySQL开源备份工具Xtrabackup备份部署

MySQL Xtrabackup备份和恢复

用XtraBackup实现MySQL的主从复制快速部署【主不锁表】

安装和使用 Percona 推出的 Xtrabackup 备份 MySQL

XtraBackup 的详细介绍:请点这里
XtraBackup 的下载地址:请点这里

请继续阅读:

linux

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Reduce the use of MySQL memory in DockerReduce the use of MySQL memory in DockerMar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How to solve the problem of mysql cannot open shared libraryHow to solve the problem of mysql cannot open shared libraryMar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

How do you alter a table in MySQL using the ALTER TABLE statement?How do you alter a table in MySQL using the ALTER TABLE statement?Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Run MySQl in Linux (with/without podman container with phpmyadmin)Run MySQl in Linux (with/without podman container with phpmyadmin)Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overviewWhat is SQLite? Comprehensive overviewMar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

Running multiple MySQL versions on MacOS: A step-by-step guideRunning multiple MySQL versions on MacOS: A step-by-step guideMar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

How do I configure SSL/TLS encryption for MySQL connections?How do I configure SSL/TLS encryption for MySQL connections?Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

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.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool