MySQL系列詳解五: xtrabackup實現徹底備份及增量備份詳解-技術流ken

 

xtrabackup簡介

 

xtrabackup是一個用來對mysql作備份的工具,它能夠對innodb引擎的數據庫作熱備。xtrabackup備份和還原速度快,備份操做不會中斷正在執行的事務,備份完成以後能夠自動作校驗,備份結果能夠壓縮(節省磁盤和帶寬)。實際工做中能夠用來作mysql的徹底備份,增量備份,以及差別備份等。mysql

xtrabackup有兩個主要的工具:innobackupex和xtrabackup,xtrabackup只能備份InnoDB和XtraDB數據表,innobackupex封裝了xtrabackup,能夠備份MyISAM數據表。sql

MySQL數據庫自己提供的工具並不支持真正的增量備份,二進制日誌恢復是point-in-time(時間點)的恢復而不是增量備份。Xtrabackup工具支持對InnoDB存儲引擎的增量備份,工做原理以下:數據庫

1.首先完成一個徹底備份,並記錄下此時檢查點的LSN(LogSequence Number)。app

2.在進程增量備份時,比較表空間中每一個頁的LSN是否大於上次備份時的LSN,若是是,則備份該頁,同時記錄當前檢查點的LSN。工具

 

xtrabackup經常使用選項

 

2 --incremental-basedir=name <<僅適用於backup,增量備份目錄 3 --incremental-dir=name <<僅適用於prepare,恢復指定目錄下的.delta文件和日誌文件 4 --apply-log <<從備份恢復。 5 --redo-only                          <<該選項強制跳過rollback階段,只進行redo。這是有必要使用的,若是備份後,要使用增量改變的。

 

安裝xtrabackup

 

1 下載xtrabackup(下載二進制版本免安裝) 2 # wget http://www.percona.com/redir/downloads/XtraBackup/XtraBackup-1.5/Linux/binary/x86_64/xtrabackup-1.5.tar.gz
3 # tar zxvfxtrabackup-1.5.tar.gz -C /usr/local/
4 源碼安裝過程具體參見源碼目錄下BUILD.txt文件。

 

演示:基於innobackupex作備份和恢復(完整備份)

 

第一步:徹底備份到/ken下spa

[root@ken ~]# innobackupex -uroot -pxx /ken <<xx表示密碼,輸入你的數據庫密碼 xtrabackup: recognized server arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit=65535 --server-id=1003306 --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit=2 --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group=3 --innodb_max_dirty_pages_pct=50 --innodb_file_per_table=1 --innodb_io_capacity=100 --innodb_flush_method=O_DIRECT xtrabackup: recognized client arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit=65535 --server-id=1003306 --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit=2 --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group=3 --innodb_max_dirty_pages_pct=50 --innodb_file_per_table=1 --innodb_io_capacity=100 --innodb_flush_method=O_DIRECT 181023 04:51:51 innobackupex: Starting the backup operation IMPORTANT: Please check that the backup run completes successfully. At the end of a successful backup run innobackupex prints "completed OK!". ... ... 181023 04:51:55 Executing UNLOCK TABLES 181023 04:51:55 All tables unlocked 181023 04:51:55 [00] Copying ib_buffer_pool to /ken/2018-10-23_04-51-51/ib_buffer_pool 181023 04:51:55 [00] ...done 181023 04:51:55 Backup created in directory '/ken/2018-10-23_04-51-51/' MySQL binlog position: filename 'mysql-bin.000004', position '154'
181023 04:51:55 [00] Writing /ken/2018-10-23_04-51-51/backup-my.cnf 181023 04:51:55 [00] ...done 181023 04:51:55 [00] Writing /ken/2018-10-23_04-51-51/xtrabackup_info 181023 04:51:55 [00] ...done xtrabackup: Transaction log of lsn (3366440) to (3366449) was copied. 181023 04:51:55 completed OK!                   <<最後出現comleted ok表示備份成功

 

第二步:刪除mysql數據庫(模擬故障)日誌

[root@ken ~]# mysql -uroot -p <<登陸數據庫 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.23-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, 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> show databases; <<查看現有數據庫 +--------------------+
| Database           |
+--------------------+
| information_schema |
| jobs               |
| ke                 |
| mysql              |
| performance_schema |
| sys                |
| test               |
| test5              |
+--------------------+
8 rows in set (0.06 sec) mysql> drop database mysql; <<刪除mysql數據庫 Query OK, 33 rows affected, 2 warnings (0.24 sec)

 

第三步:退出mysql並關閉mysqlcode

[root@ken ~]# mysqladmin -uroot -p shutdown <<關閉mysql [root@ken ~]# ss -tnl | grep 3306 <<查看mysql進程是否關閉

 

第四步:整理備份數據(將備份整理就緒)orm

[root@ken ~]# innobackupex --apply-log /ken/2018-10-23_04-51-51/ xtrabackup: recognized server arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksum_algorithm=strict_crc32 --innodb_data_file_path=ibdata1:100M:autoextend --innodb_log_files_in_group=3 --innodb_log_file_size=104857600 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=./ --innodb_undo_tablespaces=0 --server-id=1003306 --redo-log-version=1 xtrabackup: recognized client arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksum_algorithm=strict_crc32 --innodb_data_file_path=ibdata1:100M:autoextend --innodb_log_files_in_group=3 --innodb_log_file_size=104857600 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=./ --innodb_undo_tablespaces=0 --server-id=1003306 --redo-log-version=1 
181023 04:59:15 innobackupex: Starting the apply-log operation IMPORTANT: Please check that the apply-log run completes successfully. At the end of a successful apply-log run innobackupex prints "completed OK!". ... ... InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 InnoDB: New log files created, LSN=3366546 InnoDB: Highest supported file format is Barracuda. InnoDB: Log scan progressed past the checkpoint lsn 3366924 InnoDB: Doing recovery: scanned up to log sequence number 3366933 (0%) InnoDB: Database was not shutdown normally! InnoDB: Starting crash recovery. InnoDB: xtrabackup: Last MySQL binlog file position 817, file name mysql-bin.000003 InnoDB: Removed temporary tablespace data file: "ibtmp1" InnoDB: Creating shared tablespace for temporary tables InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... InnoDB: File './ibtmp1' size is now 12 MB. InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active. InnoDB: 32 non-redo rollback segment(s) are active. InnoDB: Waiting for purge to start InnoDB: 5.7.19 started; log sequence number 3366933 xtrabackup: starting shutdown with innodb_fast_shutdown = 1 InnoDB: FTS optimize thread exiting. InnoDB: Starting shutdown... InnoDB: Shutdown completed; log sequence number 3366952
181023 04:59:20 completed OK!

 

第五步:確認是否能夠進行恢復server

[root@ken ~]# ss -tnl <<確保數據庫已經關閉 State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0      128                                  *:111                                              *:* LISTEN 0      128                                  *:22                                               *:* LISTEN 0      128                                 :::111                                             :::* LISTEN 0      128                                 :::22                                              :::* [root@ken ~]# rm -rf /data/mysql/mysql3306/data/* <<刪除保存數據的目錄下的所有文件(找到你本身的數據保存位置)

 

第六步:進行恢復

[root@ken ~]# innobackupex --copy-back /ken/2018-10-23_04-51-51/ xtrabackup: recognized server arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit=65535 --server-id=1003306 --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit=2 --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group=3 --innodb_max_dirty_pages_pct=50 --innodb_file_per_table=1 --innodb_io_capacity=100 --innodb_flush_method=O_DIRECT xtrabackup: recognized client arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit=65535 --server-id=1003306 --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit=2 --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group=3 --innodb_max_dirty_pages_pct=50 --innodb_file_per_table=1 --innodb_io_capacity=100 --innodb_flush_method=O_DIRECT 181023 05:03:30 innobackupex: Starting the copy-back operation IMPORTANT: Please check that the copy-back run completes successfully. At the end of a successful copy-back run innobackupex prints "completed OK!". ... ... 181023 05:03:35 [01] ...done 181023 05:03:35 [01] Copying ./test5/db.opt to /data/mysql/mysql3306/data/test5/db.opt 181023 05:03:35 [01] ...done 181023 05:03:35 [01] Copying ./test5/ken.frm to /data/mysql/mysql3306/data/test5/ken.frm 181023 05:03:35 [01] ...done 181023 05:03:35 [01] Copying ./test5/ken.MYI to /data/mysql/mysql3306/data/test5/ken.MYI 181023 05:03:35 [01] ...done 181023 05:03:35 [01] Copying ./test5/ken.MYD to /data/mysql/mysql3306/data/test5/ken.MYD 181023 05:03:35 [01] ...done 181023 05:03:35 [01] Copying ./ib_buffer_pool to /data/mysql/mysql3306/data/ib_buffer_pool 181023 05:03:35 [01] ...done 181023 05:03:35 [01] Copying ./xtrabackup_info to /data/mysql/mysql3306/data/xtrabackup_info 181023 05:03:35 [01] ...done 181023 05:03:35 [01] Copying ./xtrabackup_binlog_pos_innodb to /data/mysql/mysql3306/data/xtrabackup_binlog_pos_innodb 181023 05:03:35 [01] ...done 181023 05:03:35 [01] Copying ./xtrabackup_master_key_id to /data/mysql/mysql3306/data/xtrabackup_master_key_id 181023 05:03:35 [01] ...done 181023 05:03:35 [01] Copying ./ibtmp1 to /data/mysql/mysql3306/data/ibtmp1 181023 05:03:35 [01] ...done 181023 05:03:35 completed OK!

 

第七步:更改數據權限

[root@ken ~]# ls -l /data/mysql/mysql3306/data/ total 421936
-rw-r----- 1 root root       519 Oct 23 05:03 ib_buffer_pool -rw-r----- 1 root root 104857600 Oct 23 05:03 ibdata1 -rw-r----- 1 root root 104857600 Oct 23 05:03 ib_logfile0 -rw-r----- 1 root root 104857600 Oct 23 05:03 ib_logfile1 -rw-r----- 1 root root 104857600 Oct 23 05:03 ib_logfile2 -rw-r----- 1 root root  12582912 Oct 23 05:03 ibtmp1 drwxr-x--- 2 root root      4096 Oct 23 05:03 jobs drwxr-x--- 2 root root        48 Oct 23 05:03 ke drwxr-x--- 2 root root      4096 Oct 23 05:03 mysql drwxr-x--- 2 root root      8192 Oct 23 05:03 performance_schema drwxr-x--- 2 root root      8192 Oct 23 05:03 sys drwxr-x--- 2 root root       200 Oct 23 05:03 test drwxr-x--- 2 root root        65 Oct 23 05:03 test5 -rw-r----- 1 root root        21 Oct 23 05:03 xtrabackup_binlog_pos_innodb -rw-r----- 1 root root       448 Oct 23 05:03 xtrabackup_info -rw-r----- 1 root root         1 Oct 23 05:03 xtrabackup_master_key_id

能夠看到下面恢復的數據文件的屬主已經變成root,須要更改成mysql

[root@ken ~]# chown -R mysql.mysql /data/mysql/mysql3306/data

 

第八步:啓動mysql並查看mysql數據庫是否已經恢復 

[root@ken ~]# mysqld &                   <<啓動mysql數據庫 [1] 7179 [root@ken ~]# mysql -uroot -p <<登陸mysql Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.23-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, 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> show databases; <<查看數據庫 +--------------------+
| Database           |
+--------------------+
| information_schema |
| jobs               |
| ke                 |
| mysql              |                   <<mysql數據庫已經恢復
| performance_schema |
| sys                |
| test               |
| test5              |
+--------------------+
8 rows in set (0.07 sec)

 

演示:基於innobackupex作增量備份和恢復(增量備份)

 

第一步:首先作一次徹底備份

[root@ken ~]# innobackupex -uroot -pxx /ken  <<xx表示你的數據庫密碼

 

第二步:建立一張表

mysql> use jobs; Database changed mysql> create table ken1 as select * from teachers; <<建立一張ken1的表 Query OK, 6 rows affected (0.09 sec) Records: 6  Duplicates: 0  Warnings: 0

 

第三步:作一次增量備份

[root@ken ~]# innobackupex -uroot -pxx --incremental --incremental-basedir=/ken/2018-10-23_04-51-51/ /ken xtrabackup: recognized server arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit=65535 --server-id=1003306 --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit=2 --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group=3 --innodb_max_dirty_pages_pct=50 --innodb_file_per_table=1 --innodb_io_capacity=100 --innodb_flush_method=O_DIRECT xtrabackup: recognized client arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit=65535 --server-id=1003306 --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit=2 --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group=3 --innodb_max_dirty_pages_pct=50 --innodb_file_per_table=1 --innodb_io_capacity=100 --innodb_flush_method=O_DIRECT 181023 05:17:04 innobackupex: Starting the backup operation IMPORTANT: Please check that the backup run completes successfully. At the end of a successful backup run innobackupex prints "completed OK!". ... ... 181023 05:17:08 Executing UNLOCK TABLES 181023 05:17:08 All tables unlocked 181023 05:17:08 [00] Copying ib_buffer_pool to /ken/2018-10-23_05-17-04/ib_buffer_pool 181023 05:17:08 [00] ...done 181023 05:17:08 Backup created in directory '/ken/2018-10-23_05-17-04/' MySQL binlog position: filename 'mysql-bin.000005', position '794'
181023 05:17:08 [00] Writing /ken/2018-10-23_05-17-04/backup-my.cnf 181023 05:17:08 [00] ...done 181023 05:17:08 [00] Writing /ken/2018-10-23_05-17-04/xtrabackup_info 181023 05:17:08 [00] ...done xtrabackup: Transaction log of lsn (3373349) to (3373358) was copied. 181023 05:17:08 completed OK!

 

第四步:刪除剛纔建立的表(模擬故障)

mysql> use jobs; Database changed mysql> drop table ken1; Query OK, 0 rows affected (0.03 sec)

 

第五步:整理完整備份

[root@ken ~]# innobackupex --apply-log --redo-only /ken/2018-10-23_04-51-51/ xtrabackup: recognized server arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksum_algorithm=strict_crc32 --innodb_data_file_path=ibdata1:100M:autoextend --innodb_log_files_in_group=3 --innodb_log_file_size=104857600 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=./ --innodb_undo_tablespaces=0 --server-id=1003306 --redo-log-version=1 xtrabackup: recognized client arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksum_algorithm=strict_crc32 --innodb_data_file_path=ibdata1:100M:autoextend --innodb_log_files_in_group=3 --innodb_log_file_size=104857600 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=./ --innodb_undo_tablespaces=0 --server-id=1003306 --redo-log-version=1 
181023 05:20:49 innobackupex: Starting the apply-log operation IMPORTANT: Please check that the apply-log run completes successfully. At the end of a successful apply-log run innobackupex prints "completed OK!". ... ... xtrabackup: starting shutdown with innodb_fast_shutdown = 1 InnoDB: Starting shutdown... InnoDB: Shutdown completed; log sequence number 3366961 InnoDB: Number of pools: 1
181023 05:20:50 completed OK!

 

第六步:將第一個增量備份文件合併到徹底備份中

[root@ken ~]# innobackupex --apply-log --redo-only /ken/2018-10-23_04-51-51/ --incremental-dir=/ken/2018-10-23_05-17-04/ xtrabackup: recognized server arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksum_algorithm=strict_crc32 --innodb_data_file_path=ibdata1:100M:autoextend --innodb_log_files_in_group=3 --innodb_log_file_size=104857600 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=./ --innodb_undo_tablespaces=0 --server-id=1003306 --redo-log-version=1 xtrabackup: recognized client arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksum_algorithm=strict_crc32 --innodb_data_file_path=ibdata1:100M:autoextend --innodb_log_files_in_group=3 --innodb_log_file_size=104857600 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=./ --innodb_undo_tablespaces=0 --server-id=1003306 --redo-log-version=1 
181023 05:23:15 innobackupex: Starting the apply-log operation IMPORTANT: Please check that the apply-log run completes successfully. At the end of a successful apply-log run innobackupex prints "completed OK!". ... ... 181023 05:23:17 [01] ...done 181023 05:23:17 [01] Copying /ken/2018-10-23_05-17-04/test5/db.opt to ./test5/db.opt 181023 05:23:17 [01] ...done 181023 05:23:17 [01] Copying /ken/2018-10-23_05-17-04/test5/ken.frm to ./test5/ken.frm 181023 05:23:17 [01] ...done 181023 05:23:17 [01] Copying /ken/2018-10-23_05-17-04/test5/ken.MYI to ./test5/ken.MYI 181023 05:23:17 [01] ...done 181023 05:23:17 [01] Copying /ken/2018-10-23_05-17-04/test5/ken.MYD to ./test5/ken.MYD 181023 05:23:17 [01] ...done 181023 05:23:17 [00] Copying /ken/2018-10-23_05-17-04//xtrabackup_binlog_info to ./xtrabackup_binlog_info
181023 05:23:17 [00] ...done 181023 05:23:17 [00] Copying /ken/2018-10-23_05-17-04//xtrabackup_info to ./xtrabackup_info
181023 05:23:17 [00] ...done 181023 05:23:17 completed OK!

 

第七步:確認是否能夠進行恢復

[root@ken ~]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0      128                                  *:111                                              *:* LISTEN 0      128                                  *:22                                               *:* LISTEN 0      128                                 :::111                                             :::* LISTEN 0      128                                 :::22                                              :::* [root@ken ~]# rm -rf /data/mysql/mysql3306/data/*

 

第八步:數據恢復

[root@ken ~]# innobackupex --copy-back /ken/2018-10-23_04-51-51/ xtrabackup: recognized server arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit=65535 --server-id=1003306 --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit=2 --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group=3 --innodb_max_dirty_pages_pct=50 --innodb_file_per_table=1 --innodb_io_capacity=100 --innodb_flush_method=O_DIRECT xtrabackup: recognized client arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit=65535 --server-id=1003306 --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit=2 --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group=3 --innodb_max_dirty_pages_pct=50 --innodb_file_per_table=1 --innodb_io_capacity=100 --innodb_flush_method=O_DIRECT 181023 05:27:13 innobackupex: Starting the copy-back operation IMPORTANT: Please check that the copy-back run completes successfully. At the end of a successful copy-back run innobackupex prints "completed OK!". ... ... 181023 05:27:18 [01] Copying ./test5/db.opt to /data/mysql/mysql3306/data/test5/db.opt 181023 05:27:18 [01] ...done 181023 05:27:18 [01] Copying ./test5/ken.frm to /data/mysql/mysql3306/data/test5/ken.frm 181023 05:27:18 [01] ...done 181023 05:27:18 [01] Copying ./test5/ken.MYI to /data/mysql/mysql3306/data/test5/ken.MYI 181023 05:27:18 [01] ...done 181023 05:27:18 [01] Copying ./test5/ken.MYD to /data/mysql/mysql3306/data/test5/ken.MYD 181023 05:27:18 [01] ...done 181023 05:27:18 [01] Copying ./ib_buffer_pool to /data/mysql/mysql3306/data/ib_buffer_pool 181023 05:27:18 [01] ...done 181023 05:27:18 [01] Copying ./xtrabackup_binlog_pos_innodb to /data/mysql/mysql3306/data/xtrabackup_binlog_pos_innodb 181023 05:27:18 [01] ...done 181023 05:27:18 [01] Copying ./xtrabackup_master_key_id to /data/mysql/mysql3306/data/xtrabackup_master_key_id 181023 05:27:18 [01] ...done 181023 05:27:18 [01] Copying ./ibtmp1 to /data/mysql/mysql3306/data/ibtmp1 181023 05:27:18 [01] ...done 181023 05:27:18 [01] Copying ./xtrabackup_info to /data/mysql/mysql3306/data/xtrabackup_info 181023 05:27:18 [01] ...done 181023 05:27:19 completed OK!

 

第九步:數據權限修改

[root@ken ~]# chown -R mysql.mysql /data/mysql/mysql3306/data/

 

第十步:啓動mysql並查看刪除的表是否應恢復

[root@ken ~]# mysqld & [1] 7358 [root@ken ~]# mysql -uroot -pxx mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.23-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, 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> use jobs; Database changed mysql> show tables; +----------------+
| Tables_in_jobs |
+----------------+
| classes        |
| courses        |
| ken            |
| ken1           |            <<刪除的ken1表已經恢復
| ken4           |
| kenken         |
| kenken1        |
| scores         |
| students       |
相關文章
相關標籤/搜索