您好,登錄后才能下訂單哦!
mysql xtrabackup在windows平臺的備份測試是怎么樣的,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。
Xtrabackup有2款主要工具:xtrabackup和innobackupex
xtrabackup只能備份和恢復innodb,而且只備份.ibd文件,.frm文件它不管,恢復時DBA要自己提供
innobackupex能備份和恢復MyISAM文件及.frm文件,并且對xtrabackup作了友好的封裝,所以可用它進行全庫備份
下載完解壓縮到C盤xtrabackup目錄下,發現共有4個文件,xtrabackup.exe是可執行文件:
C:\xtrabackup>dir
驅動器 C 中的卷是 Windows8_OS
卷的序列號是 0E54-579B
C:\xtrabackup 的目錄
2016/06/03 09:42
.
2016/06/03 09:42
..
2009/12/08 14:37 6,656 cat.exe
2003/10/23 17:35 135,680 grep.exe
2011/04/21 15:23 90,876 innobackupex.pl
2011/04/20 11:39 4,863,488 xtrabackup.exe
這里我們用xtrabackup命令進行innodb全庫備份測試:
xtrabackup命令的用法:
Usage: [C:\xtrabackup\xtrabackup [--defaults-file=#] --backup | C:\xtrabackup\xtrabackup [--defaults-file=#] --prepare] [OPTIONS]
建立innodb測試庫:
mysql> create database duansf;
Query OK, 1 row affected (0.17 sec)
mysql> use duansf
Database changed
mysql>
mysql>
mysql>
mysql>
mysql> create table dsf(id int);
Query OK, 0 rows affected (0.37 sec)
mysql> insert into dsf values(1);
Query OK, 1 row affected (0.11 sec)
mysql> insert into dsf values(2);
Query OK, 1 row affected (0.14 sec)
mysql> insert into dsf values(3);
Query OK, 1 row affected (0.06 sec)
mysql> insert into dsf values(4);
Query OK, 1 row affected (0.17 sec)
mysql> insert into dsf values(5);
Query OK, 1 row affected (0.09 sec)
mysql> select * from dsf;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+------+
5 rows in set (0.03 sec)
mysql>
查看數據文件所在目錄:
mysql> show variables like 'datadir';
+---------------+---------------------------------------------+
| Variable_name | Value |
+---------------+---------------------------------------------+
| datadir | C:\ProgramData\MySQL\MySQL Server 5.5\Data\ |
+---------------+---------------------------------------------+
1 row in set (0.00 sec)
mysql>
完全備份:
C:\xtrabackup\xtrabackup --target-dir=C:\xtrabackup\full --backup --datadir="C:\ProgramData\MySQL\MySQL Server 5.5\Data\"
c:\xtrabackup>C:\xtrabackup\xtrabackup --target-dir=C:\xtrabackup\full --backup
--datadir="C:\ProgramData\MySQL\MySQL Server 5.5\Data\duansf"
C:\xtrabackup\xtrabackup Ver undefined Rev undefined for 5.5.9 Win64 (x86)
xtrabackup: cd to C:\ProgramData\MySQL\MySQL Server 5.5\Data\duansf
xtrabackup: Target instance is assumed as followings.
xtrabackup: innodb_data_home_dir = .\
xtrabackup: innodb_data_file_path = ibdata1:10M:autoextend
xtrabackup: innodb_log_group_home_dir = .\
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 5242880
InnoDB: The first specified data file .\ibdata1 did not exist:
InnoDB: a new database to be created!
160603 10:32:56 InnoDB: Setting file .\ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
xtrabackup: Something wrong with source files...
發現有報錯,后來研究了一下,把C:\Program Files (x86)\MySQL\MySQL Server 5.5\my.ini拷貝到c:\xtrabackup目錄下再執行以下命令后測試通過:
c:\xtrabackup>xtrabackup.exe --defaults-file=C:\xtrabackup\my.ini --backup --target-dir=C:\xtrabackup\full
xtrabackup.exe Ver undefined Rev undefined for 5.5.9 Win64 (x86)
xtrabackup: cd to C:/ProgramData/MySQL/MySQL Server 5.5/Data/
xtrabackup: Target instance is assumed as followings.
xtrabackup: innodb_data_home_dir = .\
xtrabackup: innodb_data_file_path = ibdata1:10M:autoextend
xtrabackup: innodb_log_group_home_dir = .\
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 118489088
>> log scanned up to (1625547)
[01] Copying .\ibdata1
to C:\xtrabackup\full/ibdata1
[01] ...done
xtrabackup: The latest check point (for incremental): '1625547'
xtrabackup: Stopping log copying thread..>> log scanned up to (1625547)
xtrabackup: Transaction log of lsn (1625547) to (1625547) was copied.
注意:如果重復執行xtrabackup命令執行備份就會報錯,我猜測這可能是由于xtrabackup在windows平臺只是個測試版,沒有發布正式版,因此
生產環境還是慎用windows平臺版本。
看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注億速云行業資訊頻道,感謝您對億速云的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。