国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
xtrabackup備份與恢復(fù)實(shí)踐
說明

xtrabackup  --percona
特點(diǎn):
  • 開源,在線備份innodb表
  • 支持限速備份,避免對業(yè)務(wù)造成影響
  • 支持流備
  • 支持增量備份
  • 支持備份文件壓縮與加密
  • 支持并行備份與恢復(fù),速度快
地址:https://www.percona.com/downloads/XtraBackup
xtrabackup備份原理
  • 基于innodb的crash-recovery功能
  • 備份期間允許用戶讀寫,寫請求產(chǎn)生redo日志
  • 從磁盤上拷貝數(shù)據(jù)文件
  • 從innodb redo log  file實(shí)時(shí)拷貝走備份期間產(chǎn)生的所有redo日志
  • 恢復(fù)的時(shí)候 數(shù)據(jù)文件+redo日志 = 一致性數(shù)據(jù)
 
實(shí)用腳本innobackupex
  • 開源Perl腳本,封裝調(diào)用xtrabackup及一系列相關(guān)工具與OS操作,最終完成備份過程
  • 支持備份Innodb和其他引擎的表
  • 備份一致性保證
安裝問題

問題一:innobackupex發(fā)現(xiàn)mysql模塊沒有安裝
140312 13:30:40  innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup' as 'root'  (using password: YES).
innobackupex: Error: Failed to connect to MySQL server as DBD::mysql module is not installed at /usr/local/mysql/bin/innobackupex line 2956.
因?yàn)榄h(huán)境是使用二進(jìn)制文件安裝的mysql,在Ubuntu下沒有安裝mysql-server;
解決:安裝mysql-server
aiapple@ubuntu:~$ sudo apt-get install mysql-server
innobackupex使用

  1. 全量備份
  2. 增量備份
  3. 流方式備份
  4. 并行備份
  5. 限流備份
  6. 壓縮備份
  7. 常用參數(shù)介紹
1)全量備份:
aiapple@ubuntu:~$ innobackupex-1.5.1 --user=root --password=000000 --defaults-file=/tmp/mysqldata/my.cnf dbbackup/ innobackupex-1.5.1: Backup created in directory '/home/aiapple/dbbackup/2016-08-20_06-16-26'innobackupex-1.5.1: MySQL binlog position: filename 'mysql-bin.000001', position 1643160820 06:16:30  innobackupex-1.5.1: Connection to database server closed160820 06:16:30  innobackupex-1.5.1: completed OK!

  #備份成功;
  aiapple@ubuntu:~$ ls dbbackup/
  2016-08-20_06-16-26  

 

2)增量備份,需指定上一次備份目錄
注意:innobackupex 增量備份僅針對InnoDB這類支持事務(wù)的引擎,對于MyISAM等引擎,則仍然是全備。
增量備份:
aiapple@ubuntu:~$ innobackupex-1.5.1 --user=root --password=000000 --defaults-file=/tmp/mysqldata/my.cnf --incremental --incremental-dir dbbackup/2016-08-20_06-16-26/ dbbackup/ innobackupex-1.5.1: Backup created in directory '/home/aiapple/dbbackup/2016-08-20_06-24-08'innobackupex-1.5.1: MySQL binlog position: filename 'mysql-bin.000001', position 1749160820 06:24:13  innobackupex-1.5.1: Connection to database server closed160820 06:24:13  innobackupex-1.5.1: completed OK! #備份成功aiapple@ubuntu:~$ ls dbbackup/2016-08-20_06-16-26  2016-08-20_06-24-08

 

3)流式備份()
aiapple@ubuntu:~$ innobackupex-1.5.1 --user=root --password=000000 --defaults-file=/tmp/mysqldata/my.cnf --stream=xbstream dbbackup/ > dbbackup/stream.bak innobackupex-1.5.1: Backup created in directory '/home/aiapple/dbbackup'innobackupex-1.5.1: MySQL binlog position: filename 'mysql-bin.000001', position 1749160820 06:28:06  innobackupex-1.5.1: Connection to database server closed160820 06:28:06  innobackupex-1.5.1: completed OK! #備份成功aiapple@ubuntu:~$ ls dbbackup/2016-08-20_06-16-26  2016-08-20_06-24-08  stream.bak

 

4)并行備份--使用4個(gè)線程
aiapple@ubuntu:~$ innobackupex-1.5.1 --user=root --password=000000 --defaults-file=/tmp/mysqldata/my.cnf --parallel=4 dbbackup/ innobackupex-1.5.1: Backup created in directory '/home/aiapple/dbbackup/2016-08-20_06-36-34'innobackupex-1.5.1: MySQL binlog position: filename 'mysql-bin.000001', position 1749160820 06:36:38  innobackupex-1.5.1: Connection to database server closed160820 06:36:38  innobackupex-1.5.1: completed OK! #備份成功aiapple@ubuntu:~$ ls dbbackup/2016-08-20_06-16-26  2016-08-20_06-24-08  2016-08-20_06-36-34  stream.bak

 

5)限流備份--讀寫速度限制10M
aiapple@ubuntu:~$ innobackupex-1.5.1 --user=root --password=000000 --defaults-file=/tmp/mysqldata/my.cnf --throttle=10 dbbackup/ innobackupex-1.5.1: Backup created in directory '/home/aiapple/dbbackup/2016-08-20_06-38-26'innobackupex-1.5.1: MySQL binlog position: filename 'mysql-bin.000001', position 1749160820 06:38:31  innobackupex-1.5.1: Connection to database server closed160820 06:38:31  innobackupex-1.5.1: completed OK! #備份成功aiapple@ubuntu:~$ ls dbbackup/2016-08-20_06-16-26  2016-08-20_06-36-34  stream.bak2016-08-20_06-24-08  2016-08-20_06-38-26

 

6)壓縮備份--可以指定壓縮備份線程
aiapple@ubuntu:~$ innobackupex-1.5.1 --user=root --password=000000 --defaults-file=/tmp/mysqldata/my.cnf --compress --compress-thread 4 dbbackup/ innobackupex-1.5.1: Backup created in directory '/home/aiapple/dbbackup/2016-08-20_06-40-26'innobackupex-1.5.1: MySQL binlog position: filename 'mysql-bin.000001', position 1749160820 06:40:30  innobackupex-1.5.1: Connection to database server closed160820 06:40:30  innobackupex-1.5.1: completed OK! #備份成功aiapple@ubuntu:~$ ls dbbackup/2016-08-20_06-16-26  2016-08-20_06-36-34  2016-08-20_06-40-262016-08-20_06-24-08  2016-08-20_06-38-26  stream.bak

 

7)常用參數(shù)
innobackupex --help | less
恢復(fù)

1.全量備份與恢復(fù):
1)全量備份
mysql> show tables;+--------------+| Tables_in_tt |+--------------+| course       || t1           |+--------------+3 rows in set (0.00 sec) aiapple@ubuntu:~$ innobackupex --user=root --password=000000 --defaults-file=/tmp/mysqldata/my.cnf dbbackup/ #備份成功;aiapple@ubuntu:~$ ls dbbackup/2016-08-20_06-16-26
2)刪除表
mysql> drop table t1;Query OK, 0 rows affected (0.02 sec) mysql> show tables;+--------------+| Tables_in_tt |+--------------+| course       |+--------------+1 row in set (0.00 sec)
3)通過全量備份恢復(fù)
#只需通過apply-log指定備份文件
aiapple@ubuntu:~$ innobackupex --apply-log dbbackup/2016-08-20_06-16-26 InnoDB: Starting shutdown...InnoDB: Shutdown completed; log sequence number 1638934160820 06:46:20  innobackupex: completed OK!
#回滾redo log文件;
aiapple@ubuntu:~/dbbackup/2016-08-20_06-16-26$ lsbackup-my.cnf  mysql               xtrabackup_binlog_infoibdata1        performance_schema  xtrabackup_checkpointsib_logfile0    tt                  xtrabackup_logfileib_logfile1    xtrabackup_binary

 

4)復(fù)制恢復(fù)文件到數(shù)據(jù)目錄
#注意:數(shù)據(jù)目錄要求是空,最好先備份,再清空;
aiapple@ubuntu:~/dbbackup$ innobackupex  --defaults-file=/tmp/mysqldata/my.cnf --user=root --password=000000 --copy-back 2016-08-20_06-16-26/ innobackupex-1.5.1: Copying '/home/aiapple/dbbackup/2016-08-20_06-16-26/ib_logfile1' to '/tmp/mysqldata/node1/ib_logfile1'innobackupex-1.5.1: Finished copying back files.160820 07:11:09  innobackupex-1.5.1: completed OK!
5)查看
mysql> show tables;+--------------+| Tables_in_tt |+--------------+| course       || t1           |+--------------+2 rows in set (0.00 sec)

 

2.增量備份與恢復(fù)
#需指定上次備份目錄
1)增加表zengliang;
mysql> show tables;+--------------+| Tables_in_tt |+--------------+| course       || t1           |+--------------+2 rows in set (0.00 sec) mysql> create table zengliang(a int ,b int);Query OK, 0 rows affected (0.06 sec)

 

2)增量備份
#注意--incremental-dir后面跟基礎(chǔ)備份目錄,之后再跟增量備份目錄,
#與應(yīng)用增量備份日志相反
aiapple@ubuntu:~$ innobackupex --user=root --password=000000 --defaults-file=/tmp/mysqldata/my.cnf --incremental --incremental-dir dbbackup/2016-08-20_06-16-26/ dbbackup/ innobackupex-1.5.1: MySQL binlog position: filename 'mysql-bin.000001', position 1749160820 06:24:13  innobackupex-1.5.1: Connection to database server closed160820 06:24:13  innobackupex-1.5.1: completed OK!
#備份成功
aiapple@ubuntu:~$ ls dbbackup/2016-08-20_06-16-26  2016-08-20_06-24-08

 

3)應(yīng)用日志恢復(fù)數(shù)據(jù)
--apply-log    回滾日志
--redo-only    回滾合并(多個(gè)增量的時(shí)候,增量也需要用到,直到最后一個(gè)增量不用)
     a)恢復(fù)完全備份數(shù)據(jù)
 aiapple@ubuntu:~/dbbackup$ innobackupex --apply-log --redo-only 2016-08-20_06-16-26
     b)應(yīng)用增量備份日志
     #注意此時(shí)--incremental-dir后面跟的是增量備份的目錄,之后再跟基礎(chǔ)備份的目錄;
     #與增量備份相反
     #注意:由于權(quán)限問題,使用innobackupex,應(yīng)該使用root賬戶,不然這條不會(huì)通過;
   
  aiapple@ubuntu:~/dbbackup$ innobackupex --apply-log --incremental-dir=(增量備份目錄) (基礎(chǔ)備份目錄)
#不知何原因總是不太容易成功;
4)復(fù)制恢復(fù)文件到數(shù)據(jù)目錄
#注意:數(shù)據(jù)目錄要求是空,最好先備份,再清空;
aiapple@ubuntu:~/dbbackup$ innobackupex  --defaults-file=/tmp/mysqldata/my.cnf --user=root --password=000000 --copy-back 2016-08-20_06-16-26/ innobackupex-1.5.1: Copying '/home/aiapple/dbbackup/2016-08-20_06-16-26/ib_logfile1' to '/tmp/mysqldata/node1/ib_logfile1'innobackupex-1.5.1: Finished copying back files. 160820 07:11:09  innobackupex-1.5.1: completed OK!

 

3.還原壓縮
解壓--innobackupex --decompress /dbbackup/(備份目錄)
應(yīng)用日志--innobackupex --apply-log /dbbackup/(壓縮后目錄)
4)還原流備
mkdir stream
xbstream -C stream -x < stream.bak
并行恢復(fù)--innobackupex --parallel=4 --apply-log --use-memory=200MB /dbbackup/stream
--use-memory:加快恢復(fù)速度;
 
binlog恢復(fù)

在備份恢復(fù)之后,使用binlog恢復(fù)沒有備份的數(shù)據(jù);
1)查看備份時(shí)binlog點(diǎn);
aiapple@ubuntu:~/dbbackup/mysql3309$ cat xtrabackup_binlog_infomysql-bin.000002    1467  
2)使用mysqlbinlog分析二進(jìn)制日志
aiapple@ubuntu:/tmp/mysqldata/node1$ mysqlbinlog -vv mysql-bin.000002 | less# at 1958#160820  9:10:29 server id 1  end_log_pos 2078 CRC32 0x683bcdc6     Query    thread_id=2    exec_time=0    error_code=0SET TIMESTAMP=1471698629/*!*/;insert into t6 values(111,222),(333,444),(555,666)/*!*/;# at 2078#160820  9:10:29 server id 1  end_log_pos 2109 CRC32 0xf264071a     Xid = 104COMMIT/*!*/;# at 2109#160820  9:11:51 server id 1  end_log_pos 2184 CRC32 0x3f63ae99     Query    thread_id=2    exec_time=0    error_code=0SET TIMESTAMP=1471698711/*!*/;BEGIN/*!*/;# at 2184#160820  9:11:51 server id 1  end_log_pos 2298 CRC32 0x5c3b7667     Query    thread_id=2    exec_time=0    error_code=0SET TIMESTAMP=1471698711/*!*/;insert into t6 values(11,22),(33,44),(55,66)/*!*/;# at 2298#160820  9:11:51 server id 1  end_log_pos 2329 CRC32 0x4ea5c481     Xid = 114COMMIT/*!*/;
可以看到結(jié)束節(jié)點(diǎn)在2298
3)使用mysqlbinlog+管道+mysql sock登陸
aiapple@ubuntu:/tmp/mysqldata/node1$ mysqlbinlog -vv --start-position=1467   --stop-position=2298 mysql-bin.000002 | mysql -uroot -p --socket=/home/aiapple/dbbackup/mysql3309/mysql.sock

 

也可以按照時(shí)間恢復(fù):
aiapple@ubuntu:/tmp/mysqldata/node1$ mysqlbinlog -vv --start-datetime='2016-08-20 9:03:58'   --stop-datetime='2016-08-20 9:11:51' mysql-bin.000002 | cat

 

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
【MySql】innobackupex 增量備份和恢復(fù)
Mysql備份工具xtraback全量和增量測試
15、xtrabackup 全量備份
Mysql備份神器,比自帶的速度快多了
mysql備份的三種方式詳解
使用二進(jìn)制熱備份創(chuàng)建MySQL主從復(fù)制
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服