日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Xtrabackup的“流”及“备份压缩”功能

發布時間:2024/4/17 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Xtrabackup的“流”及“备份压缩”功能 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Xtrabackup對備份的數據文件支持“流”功能,即可以將備份的數據通過STDOUT傳輸給tar程序進行歸檔,而不是默認的直接保存至某備份目錄中。要使用此功能,僅需要使用--stream選項即可。如:


# innobackupex --stream=tar ?/backup | gzip > /backup/`date +%F_%H-%M-%S`.tar.gz


[root@localhost opt]# innobackupex --stream=tar --user=backup --password=pancou /hotbackup/full/|gzip > /opt/full`date +%F_%H-%M-%S`.tar.gz

... ...

170428 13:40:24 Executing UNLOCK TABLES

170428 13:40:24 All tables unlocked

170428 13:40:24 Backup created in directory '/hotbackup/full/'

MySQL binlog position: filename 'mysql-bin.000001', position '313', GTID of the last change ''

170428 13:40:24 [00] Streaming backup-my.cnf

170428 13:40:24 [00] ? ? ? ?...done

170428 13:40:24 [00] Streaming xtrabackup_info

170428 13:40:24 [00] ? ? ? ?...done

xtrabackup: Transaction log of lsn (21898933) to (21898933) was copied.

170428 13:40:24 completed OK!


甚至也可以使用類似如下命令將數據備份至其它服務器:

# innobackupex --stream=tar ?/backup | ssh user@www.magedu.com ?"cat - ?> /backups/`date +%F_%H-%M-%S`.tar"?


---------------------------------使用xbstream流備份:


[root@localhost ~]# innobackupex --stream=xbstream --user=backup --password=pancou /hotbackup/full/ > /tmp/full_`date +%F_%H-%M-%S`.xbs

170510 12:08:14 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!".

.... ? ? ? ?......


170510 12:08:18 Executing UNLOCK TABLES

170510 12:08:18 All tables unlocked

170510 12:08:18 Backup created in directory '/hotbackup/full/'

MySQL binlog position: filename 'mysql-bin.000005', position '339748', GTID of the last change '0-2-960'

170510 12:08:18 [00] Streaming backup-my.cnf

170510 12:08:18 [00] ? ? ? ?...done

170510 12:08:18 [00] Streaming xtrabackup_info

170510 12:08:18 [00] ? ? ? ?...done

xtrabackup: Transaction log of lsn (23216778) to (23216778) was copied.

170510 12:08:18 completed OK!


[root@localhost ~]# ls /tmp/

backup ?full_2017-05-10_12-08-14.xbs ?hsperfdata_nexus ?keyring-KtDQQF ?keyring-u5nHlu ?mysql ?percona-version-check ?sakila.sql


還原流歸檔


[root@localhost ~]# xbstream -xv -C /tmp/backup/ </tmp/full_2017-05-10_12-08-14.xbs?

ibdata1

pancou/rpel_table.ibd

mysql/innodb_table_stats.ibd

mysql/gtid_slave_pos.ibd

....?


[root@localhost ~]# ls /tmp/backup/

backup-my.cnf ?mysql ? percona ? ? ? ? ? ? sakila ?testdb ? ? ? ? ? ? ? ? ?xtrabackup_checkpoints ?xtrabackup_logfile

ibdata1 ? ? ? ?pancou ?performance_schema ?test ? ?xtrabackup_binlog_info ?xtrabackup_info


------------------------------------------使用流壓縮:


[root@localhost ~]# innobackupex --stream=xbstream --compress --user=backup --password=pancou /hotbackup/full/ > /tmp/full_`date +%F_%H-%M-%S`.xbs


170510 12:16:51 Executing UNLOCK TABLES

170510 12:16:51 All tables unlocked

170510 12:16:51 Backup created in directory '/hotbackup/full/'

MySQL binlog position: filename 'mysql-bin.000005', position '339748', GTID of the last change '0-2-960'

170510 12:16:51 [00] Compressing and streaming backup-my.cnf

170510 12:16:51 [00] ? ? ? ?...done

170510 12:16:51 [00] Compressing and streaming xtrabackup_info

170510 12:16:51 [00] ? ? ? ?...done

xtrabackup: Transaction log of lsn (23216778) to (23216778) was copied.

170510 12:16:51 completed OK!


[root@localhost ~]# ll -h /tmp/

total 110M

drwxr-xr-x 9 root ? root ? ? 4.0K May 10 12:09 backup

-rw-r--r-- 1 root ? root ? ? 102M May 10 12:08 full_2017-05-10_12-08-14.xbs

-rw-r--r-- 1 root ? root ? ? 4.8M May 10 12:16 full_2017-05-10_12-16-48.xbs


--------------------------------------------------解壓縮


[root@localhost ~]# xbstream -xv -C /tmp/backup/ < /tmp/full_2017-05-10_12-16-48.xbs?

[root@localhost ~]# ls /tmp/backup/

backup-my.cnf.qp ?mysql ? percona ? ? ? ? ? ? sakila ?testdb ? ? ? ? ? ? ? ? ? ? xtrabackup_checkpoints ?xtrabackup_logfile.qp

ibdata1.qp ? ? ? ?pancou ?performance_schema ?test ? ?xtrabackup_binlog_info.qp ?xtrabackup_info.qp


-----------------------------------------------遠程主機流壓縮備份

同時,innobackupex備份的數據文件也可以存儲至遠程主機,這可以使用--remote-host選項來實現:

# innobackupex --remote-host=root@www.magedu.com ?/path/IN/REMOTE/HOST/to/backup


[root@localhost ~]# innobackupex --stream=xbstream --compress --user=backup --password=pancou /hotbackup/full/ |ssh -o StrictHostKeyChecking=no root@192.168.1.53 "cat - > /tmp/full_`date +%F_%H-%M-%S`.xbs"


此外,在執行本地備份時,還可以使用--parallel選項對多個文件進行并行復制。此選項用于指定在復制時啟動的線程數目。當然,在實際進行備份時要利用此功能的便利性,也需要啟用innodb_file_per_table選項或共享的表空間通過innodb_data_file_path選項存儲在多個ibdata文件中。對某一數據庫的多個文件的復制無法利用到此功能。其簡單使用方法如下:

# innobackupex --parallel ?/path/to/backup


轉載于:https://blog.51cto.com/lijianmin2008/1924058

總結

以上是生活随笔為你收集整理的Xtrabackup的“流”及“备份压缩”功能的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。