innobackupex 简单使用笔记
生活随笔
收集整理的這篇文章主要介紹了
innobackupex 简单使用笔记
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
innobackupex 選項介紹 --backup 備份 --apply-log?? 應(yīng)用日志 --move-back? --copy-back 恢復(fù) --export 只導(dǎo)出單個表。前提是使用innodb_file_per_table decompress? decrypt? 解壓,解密 --incremental-basedir 增量備份的基路徑 --incremental-lsn 指定增量備份的lsn。就可以不用指定增量備份的基路徑。 --incremental-dir 增量備份到哪 --safe-slave-backup 在從節(jié)點(diǎn)備份,指定該參數(shù)停止SQL線程,等到show status 總的 Slave_open_temp_tables為0開始備份。如果Slave_open_temp_tables不為0。將不斷啟動停止SQL線程知道Slave_open_temp_tables為0。如果超過了--safe-slave-backup-timeout 指定時間,Slave_open_temp_tables 還不為0,備份失敗。 --rsync 使用rsync實(shí)用程序優(yōu)化本地文件傳輸。不能--stream一同使用 --parallel 并行線程 --no-timestamp 不生成時間戳目錄 --compress 壓縮為qp格式 --compress-threads 壓縮的線程 --rebuild-indexes --rebuild-threads --decompress 解壓縮,需要 qpress --incremental-history-name?? PERCONA_SCHEMA.xtrabackup_history --stream 指定輸出格式,目前支持tar和xbstream --tmpdir 指定文件的臨時存儲位置,默認(rèn)為my.cnf里面配置的臨時位置。 --use-memory? 使用的內(nèi)存,僅僅用于--apply-log --redo-log-version --redo-only 在增量備份恢復(fù)時,跳過rollback。只做redo。 --tables-file --include=REGEXP 對xtrabackup參數(shù)--tables的封裝,也支持ibbackup。備份包含的庫表,例如:--include="test.*",意思是要備份test庫中所有的表。如果需要全備份,則省略這個參數(shù);如果需要備份test庫下的2個表:test1和test2,則寫成:--include="test.test1|test.test2"。也可以使用通配符,如:--include="test.test*"。 --databases=LIST? 例如 --databases='lizhi_online test'?? 也可以指定某個表--databases='test.t1' 。 列出需要備份的databases,如果沒有指定該參數(shù),所有包含MyISAM和InnoDB表的database都會被備份; --compress? xtrabckup自身帶的壓縮和--stream 互斥。?在壓縮方面? gzip壓縮率最大,但是壓縮時間久。--compress (即qpress)壓縮率較小,但是壓縮快,可以指定多線程。建議使用?xtrabackup自身帶的--compress壓縮。 --slave-info? 重要參數(shù)。只有開啟了GTID才可用,如果在從庫進(jìn)行備份,會生成一個備份文件xtrabackup_slave_info? 記錄了?SET GLOBAL gtid_purged='xxx' ;CHANGE MASTER TO MASTER_AUTO_POSITION=1 。這樣可以方便的接到主庫上。 備份(用stream模式備份) innobackupex? ?--defaults-file=$defaults??--host=${host} --user=${user} --password="${password}" --port=${port}???--parallel=6??--compress --compress-threads=6 --slave-info??--stream=xbstream??$backup_dir???>$backup_file??2>$backup_log 例如: /usr/local/xtrabackup/bin/innobackupex? --defaults-file=/usr/local/mysql/my_online.cnf --socket=/data_db1/mysql_online/data/mysql.sock? --databases='lizhi_online test' --user root --password '123456'? --stream=tar /tmp/xtrabackupdir/ |gzip? >/tmp/xtrabackupdir/online_mysql2.tar.gz 恢復(fù)全部備份 /usr/local/xtrabackup/bin/innobackupex? --apply-log? /dir innobackupex?? --defaults-file=/usr/local/mysql/my_Podcast.cnf????? --copy-back? /dir & 或者使用--move-back innobackupex?? --defaults-file=/usr/local/mysql/my_Podcast.cnf? ? ?--move-back ?/dir & 恢復(fù)全部備份中的指定表 innobackupex??--apply-log --export??/backupdir? (可以通過--include?僅export某個表,其他表會被忽略。報錯數(shù)據(jù)正常 ) 復(fù)制目錄下生成的 .exp .cfg .ibd?文件到目標(biāo)實(shí)例做恢復(fù) 目標(biāo)實(shí)例: create table push_msg alter table push_msg discard tablespace; 復(fù)制cfg exp ibd文件?到對應(yīng)數(shù)據(jù)目錄下? (如: ls |grep push_content|grep -E 'cfg$|ibd$|exp$'|while read line ;do mv??$line dir ;done? ) alter table push_content import tablespace; 恢復(fù)完畢后?change重定向主庫 change master to master_host='xxx', master_port=xxx, master_user='xxx', master_password='xxx', master_log_file='xxx', master_log_pos=xxx; 相關(guān)命令 解壓?xbstream備份的介質(zhì) xbstream? -x <?xxxx.xbstream -C ./ 解壓有帶--compress壓縮的每個備份文件 for fil in `ls ./*/*qp`;do dirname=`dirname $fil`;echo $fil;qpress -d $fil $dirname;done; 解壓完刪除.qp文件 for fil in `ls ./*/*qp`;do dirname=`dirname $fil`;echo $fil;qpress -d $fil $dirname;if [ $? -eq 0 ];then rm -rf $fil;fi;done; xtrabackup BUG 如果創(chuàng)建表使用數(shù)據(jù)目錄之外的目錄。會在數(shù)據(jù)目錄下生成isl文件存儲ibd目錄的全地址。但恢復(fù) --copy-back?或者move-back不一定能夠把對應(yīng)的ibd移動到相關(guān)目錄。 根據(jù)isl鏈接移動文件到目標(biāo)目錄: ls |grep???isl$|while read line; do echo $line;strings $line|awk -F/ '{print $NF}' |awk '{system("mv???"$0"? /dir ")}';done
轉(zhuǎn)載于:https://www.cnblogs.com/vansky/p/8268556.html
總結(jié)
以上是生活随笔為你收集整理的innobackupex 简单使用笔记的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 安装VMware出现无效驱动器
- 下一篇: 详解BindingResult