最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁 - 科技 - 知識百科 - 正文

MySQL備份的幾種方式的討論,重點關(guān)注在線熱備

來源:懂視網(wǎng) 責(zé)編:小采 時間:2020-11-09 15:49:35
文檔

MySQL備份的幾種方式的討論,重點關(guān)注在線熱備

MySQL備份的幾種方式的討論,重點關(guān)注在線熱備:MySQL的備份方式,目前我想到的有五種,有可能還有 1,mysqldump方式,加上具體參數(shù)名(單庫,多庫,觸發(fā)器,存儲過程,表結(jié)構(gòu),字符集,single-transaction,等等) 2,mysqlhotcopy 只能備份myisam數(shù)據(jù)表備份,速度相當(dāng)快,因為是文件拷貝,可能瞬間被鎖表
推薦度:
導(dǎo)讀MySQL備份的幾種方式的討論,重點關(guān)注在線熱備:MySQL的備份方式,目前我想到的有五種,有可能還有 1,mysqldump方式,加上具體參數(shù)名(單庫,多庫,觸發(fā)器,存儲過程,表結(jié)構(gòu),字符集,single-transaction,等等) 2,mysqlhotcopy 只能備份myisam數(shù)據(jù)表備份,速度相當(dāng)快,因為是文件拷貝,可能瞬間被鎖表

MySQL的備份方式,目前我想到的有五種,有可能還有 1,mysqldump方式,加上具體參數(shù)名(單庫,多庫,觸發(fā)器,存儲過程,表結(jié)構(gòu),字符集,single-transaction,等等) 2,mysqlhotcopy 只能備份myisam數(shù)據(jù)表備份,速度相當(dāng)快,因為是文件拷貝,可能瞬間被鎖表

MySQL的備份方式,目前我想到的有五種,有可能還有
1,mysqldump方式,加上具體參數(shù)名(單庫,多庫,觸發(fā)器,存儲過程,表結(jié)構(gòu),字符集,–single-transaction,等等)
2,mysqlhotcopy 只能備份myisam數(shù)據(jù)表備份,速度相當(dāng)快,因為是文件拷貝,可能瞬間被鎖表,任何的數(shù)據(jù)操作,比如插入和更新都會掛起。
3,LVM的快照功能進行數(shù)據(jù)庫分區(qū)的備份,這種方法是利用的邏輯卷的鏡像功能,對整個分區(qū)進行在線備份,這種備份數(shù)據(jù)量大,而且備份性能低下,因為每次備份都是整個鏡像,不能針對數(shù)據(jù)做備份。桶裝備份
4,開啟二進制同步日志功能,主從復(fù)制,從機器做備份功能。
5,在線的熱備份,采用開源的 Xtrabackup 備份工具對innodb 數(shù)據(jù)表進行在線備份,測試階段。

下面是備份的xtrabackup的測試例子。

[@root.localhost.nova ~]# /usr/bin/innobackupex-1.5.1 –user=root –defaults-file=/home/mysql/my.cnf –socket=/home/mysql/mysql.sock –database=serverinfo –slave-info –stream=tar /root/ |gzip > /root/bak_mysql.tar.gz

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy.
All Rights Reserved.

This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackup
prints “innobackup completed OK!”.

innobackupex: Using mysql Ver 14.12 Distrib 5.0.83, for pc-linux-gnu (i686) using readline 5.1
innobackupex: Using mysql server version 5.0.83-community-log

innobackupex: Created backup directory /root
090823 17:37:51 innobackupex: Starting mysql with options: –unbuffered –user=root –socket=/home/mysql/mysql.sock
090823 17:37:51 innobackupex: Connected to database with mysql child process (pid=28803)
090823 17:37:55 innobackupex: Connection to database server closed

090823 17:37:55 innobackupex: Starting ibbackup with command: xtrabackup –defaults-file=/home/mysql/my.cnf –backup –suspend-at-end –log-stream –target-dir=./
innobackupex: Waiting for ibbackup (pid=28809) to suspend
innobackupex: Suspend file ‘/home/mysql/xtrabackup_suspended’

xtrabackup: suspend-at-end is enabled.
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /home/mysql
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 = 4194304
xtrabackup: Stream mode.
>> log scanned up to (0 85364)

090823 17:37:57 innobackupex: Continuing after ibbackup has suspended

innobackupex: Starting to backup InnoDB tables and indexes
innobackupex: from original InnoDB data directory ‘/home/mysql’
innobackupex: Backing up as tar stream ‘ibdata1′
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_djgameserver.ibd’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_djgameserverlog.ibd’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_repairhistory.ibd’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_serverinfo.ibd’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_serverinfolog.ibd’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_tlgameserver.ibd’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_tlgameserverlog.ibd’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_user.ibd’
090823 17:37:58 innobackupex: Starting mysql with options: –unbuffered –user=root –socket=/home/mysql/mysql.sock
090823 17:37:58 innobackupex: Connected to database with mysql child process (pid=28834)
>> log scanned up to (0 85364)
090823 17:38:02 innobackupex: Starting to lock all tables…
>> log scanned up to (0 85364)
>> log scanned up to (0 88314)
>> log scanned up to (0 88415)
090823 17:38:20 innobackupex: All tables locked and flushed to disk

090823 17:38:20 innobackupex: Starting to backup .frm, .MRG, .MYD, .MYI,
innobackupex: .TRG, .TRN, and .opt files in
innobackupex: subdirectories of ‘/home/mysql’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_djgameserver.frm’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_djgameserverlog.frm’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_repairhistory.frm’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_serverinfo.frm’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_serverinfolog.frm’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_tlgameserver.frm’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_tlgameserverlog.frm’
innobackupex: Backing up file ‘/home/mysql/serverinfo/simsys_user.frm’
innobackupex: Backing up file ‘/home/mysql/serverinfo/db.opt’
090823 17:38:20 innobackupex: Finished backing up .frm, .MRG, .MYD, .MYI, .TRG, .TRN, and .opt files

innobackupex: Resuming ibbackup

xtrabackup: The latest check point (for incremental): ‘0:88415′
>> log scanned up to (0 88415)
xtrabackup: Transaction log of lsn (0 85364) to (0 88415) was copied.
090823 17:38:24 innobackupex: All tables unlocked
090823 17:38:24 innobackupex: Connection to database server closed

innobackupex: Backup created in directory ‘/root’
innobackupex: MySQL binlog position: filename ”, position
innobackupex: MySQL slave binlog position: master host ”, filename ”, position
090823 17:38:24 innobackupex: innobackup completed OK!
innobackupex: You must use -i (–ignore-zeros) option for extraction of the tar stream.
[@root.localhost.nova ~]#
[@root.localhost.nova ~]# ls -ltr
total 11752
drwxr-xr-x 2 oracle ftp 4096 Apr 20 15:43 linux
-rw-r–r– 1 root root 17969 Apr 20 15:43 linux.tgz
-rw-r–r– 1 root root 4698 Jun 5 16:08 install.sh
-rw-r–r– 1 root root 3565 Jun 18 11:21 HP-set.sh
-rw-r–r– 1 root root 98676 Jul 27 13:33 install.log.syslog
-rw-r–r– 1 root root 68464 Jul 27 13:33 install.log
-rw-r–r– 1 root root 1299 Jul 27 13:33 anaconda-ks.cfg
-rw-rw—- 1 mysql mysql 10485760 Aug 14 10:57 ibdata1
-rw-r–r– 1 root root 1230176 Aug 23 17:12 xtrabackup-0.7-1.rhel4.x86_64.rpm
-rw-r–r– 1 root root 44998 Aug 23 17:38 bak_mysql.tar.gz
[@root.localhost.nova ~]#

[@root.localhost.nova tmp]# ls -lR
.:
total 10336
-rw-r–r– 1 root root 259 Aug 23 17:37 backup-my.cnf
-rw-r–r– 1 root root 44998 Aug 23 17:43 bak_mysql.tar.gz
-rw-rw—- 1 mysql mysql 10485760 Aug 23 17:28 ibdata1
-rw-r–r– 1 root root 0 Aug 23 17:37 mysql-stderr
-rw-r–r– 1 root root 506 Aug 23 17:38 mysql-stdout
drwxr-xr-x 2 root root 380 Aug 23 17:43 serverinfo
-rw-r–r– 1 root root 1 Aug 23 17:38 xtrabackup_binlog_info
-rw-r–r– 1 root root 60 Aug 23 17:38 xtrabackup_checkpoints
-rw-r–r– 1 root root 5632 Aug 23 17:38 xtrabackup_logfile
-rw-r–r– 1 root root 53 Aug 23 17:38 xtrabackup_slave_info

./serverinfo:
total 1020
-rw-rw—- 1 mysql mysql 61 Aug 12 19:59 db.opt
-rw-rw—- 1 mysql mysql 34626 Aug 12 20:00 simsys_djgameserver.frm
-rw-rw—- 1 mysql mysql 98304 Aug 12 20:00 simsys_djgameserver.ibd
-rw-rw—- 1 mysql mysql 8760 Aug 12 20:00 simsys_djgameserverlog.frm
-rw-rw—- 1 mysql mysql 98304 Aug 12 20:00 simsys_djgameserverlog.ibd
-rw-rw—- 1 mysql mysql 12944 Aug 12 20:00 simsys_repairhistory.frm
-rw-rw—- 1 mysql mysql 98304 Aug 12 20:00 simsys_repairhistory.ibd
-rw-rw—- 1 mysql mysql 26072 Aug 12 20:00 simsys_serverinfo.frm
-rw-rw—- 1 mysql mysql 98304 Aug 12 20:00 simsys_serverinfo.ibd
-rw-rw—- 1 mysql mysql 8760 Aug 12 20:00 simsys_serverinfolog.frm
-rw-rw—- 1 mysql mysql 98304 Aug 12 20:00 simsys_serverinfolog.ibd
-rw-rw—- 1 mysql mysql 56550 Aug 12 20:00 simsys_tlgameserver.frm
-rw-rw—- 1 mysql mysql 98304 Aug 12 20:00 simsys_tlgameserver.ibd
-rw-rw—- 1 mysql mysql 8760 Aug 12 20:00 simsys_tlgameserverlog.frm
-rw-rw—- 1 mysql mysql 98304 Aug 12 20:00 simsys_tlgameserverlog.ibd
-rw-rw—- 1 mysql mysql 8646 Aug 12 20:00 simsys_user.frm
-rw-rw—- 1 mysql mysql 98304 Aug 14 10:57 simsys_user.ibd

備份出來的文件是:bak_mysql.tar.gz,解壓方法:tar zxvfi bak_mysql.tar.gz

恢復(fù)時候就采用復(fù)制文件,覆蓋,然后mysqldump方式導(dǎo)入導(dǎo)出。

http://www.imdba.cn/2009/08/31/mysqlbakup-eg/

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

MySQL備份的幾種方式的討論,重點關(guān)注在線熱備

MySQL備份的幾種方式的討論,重點關(guān)注在線熱備:MySQL的備份方式,目前我想到的有五種,有可能還有 1,mysqldump方式,加上具體參數(shù)名(單庫,多庫,觸發(fā)器,存儲過程,表結(jié)構(gòu),字符集,single-transaction,等等) 2,mysqlhotcopy 只能備份myisam數(shù)據(jù)表備份,速度相當(dāng)快,因為是文件拷貝,可能瞬間被鎖表
推薦度:
標(biāo)簽: 備份 在線 關(guān)注
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top