首頁 資料庫 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 尊渡假赌尊渡假赌尊渡假赌
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