- 浏览: 1019878 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (529)
- 服务器 (8)
- jsp (1)
- java (6)
- AIX (1)
- solaris (3)
- linux学习 (53)
- javaScript (2)
- hibernate (1)
- 数据库 (74)
- sql语句 (8)
- oracle 学习 (75)
- oracle 案例 (42)
- oracle 管理 (42)
- Oracle RAC (27)
- oracle data guard (12)
- oracle 参数讲解 (14)
- Oracle 字符集 (8)
- oracle性能调优 (24)
- oracle备份与恢复 (12)
- oracle Tablespace (9)
- oracle性能诊断艺术 (1)
- oracle 11g学习 (5)
- oracle streams (1)
- oracle upgrade and downgrade (4)
- db2学习 (13)
- db2命令学习 (2)
- mysql (28)
- sql server (30)
- sql server 2008 (0)
- 工具 (10)
- 操作系统 (3)
- c++ (1)
- stock (1)
- 生活 (5)
- HADOOP (2)
最新评论
-
massjcy:
...
如何将ubuntu文件夹中文名改为英文 -
skypiea:
谢谢。。。
终于解决了。。。
Oracle 10.2.0.4(5)EM不能启动的解决方案(Patch 8350262) -
qwe_rt:
引用vi /etc/sysconfig/network 请问 ...
Linux操作系统下配置静态IP上网 -
liuqiang:
sudo killall -9 apache2
ps 和 kill 命令详解 -
dazuiba:
引用*绝杀 kill -9 PID 当使用此命令时,一定要通过 ...
ps 和 kill 命令详解
Xtrabackup是percona开发的产品,可以看做是InnoDB Hotbackup的免费替代品。
Percona XtraBackup is the world's only open-source, free MySQL hot backup software that performs non-blocking backups for InnoDB, XtraDB, and MyISAM databases0. It makes MySQL hot backups for all versions of Percona Server, MySQL, and MariaDB. It performs streaming, compressed, and incremental MySQL backups.
What are the features of Percona XtraBackup?
Here is a short list of XtraBackup features. See the documentation for more.
- Create hot InnoDB backups without pausing your database
- Make incremental backups of MySQL
- Stream compressed MySQL backups to another server
- Move tables between MySQL servers online
- Create new MySQL replication slaves easily
- Backup MySQL without adding load to the server
先看看如何安装Xtrabackup,下载最新的版本,最简单的安装方式无疑是使用RPM包,不过如果你想使用源代码方式安装的话,则会发现其安装方式有点古怪,这是因为它采用的在MySQL源代码上打补丁构建的方式。
wget http://www.percona.com/mysql/xtrabackup/xtrabackup-0.8.tar.gz
tar zxf xtrabackup-0.8.tar.gz
cd xtrabackup-0.8
./configure
make
进行到这里时,千万别惯性使然接着make install,那样就会接着安装MySQL了,正确方法是接着:
cd innobase/xtrabackup/
make
make install
如此一来,就会在你的/usr/bin目录里安装上两个有用的工具:xtrabackup,innobackupex-1.5.1:
xtrabackup可以在不加锁的情况下备份innodb数据表,不过此工具不能操作myisam。
innobackupex-1.5.1是一个脚本封装,能同时处理innodb和myisam,但在处理myisam时需要加一个读锁。
按如上的介绍,由于操作myisam时需要加读锁,这会堵塞线上服务的写操作,而innodb没有这样的限制,所以数据库中innodb表类型所占的比例越大,则越有利。实际应用中一般是直接使用innobackupex-1.5.1方法,它主要有三种操作方式,按手册中的介绍:
Usage:
innobackup [--sleep=MS] [--compress[=LEVEL]] [--include=REGEXP] [--user=NAME]
[--password=WORD] [--port=PORT] [--socket=SOCKET] [--no-timestamp]
[--ibbackup=IBBACKUP-BINARY] [--slave-info] [--stream=tar]
[--defaults-file=MY.CNF]
[--databases=LIST] [--remote-host=HOSTNAME] BACKUP-ROOT-DIR
innobackup --apply-log [--use-memory=MB] [--uncompress] [--defaults-file=MY.CNF]
[--ibbackup=IBBACKUP-BINARY] BACKUP-DIR
innobackup --copy-back [--defaults-file=MY.CNF] BACKUP-DIR
第一个命令行是热备份mysql数据库。
The first command line above makes a hot backup of a MySQL database.
By default it creates a backup directory (named by the current date
and time) in the given backup root directory. With the --no-timestamp
option it does not create a time-stamped backup directory, but it puts
the backup in the given directory (which must not exist). This
command makes a complete backup of all MyISAM and InnoDB tables and
indexes in all databases or in all of the databases specified with the
--databases option. The created backup contains .frm, .MRG, .MYD,
.MYI., .TRG, .TRN, .opt, and InnoDB data and log files. The MY.CNF
options file defines the location of the database. This command
connects to the MySQL server using mysql client program, and runs
ibbackup (InnoDB Hot Backup program) as a child process.
带有--apply-log选项的命令是准备在一个备份上启动mysql服务。
The command with --apply-log option prepares a backup for starting a MySQL
server on the backup. This command expands InnoDB data files as specified
in BACKUP-DIR/backup-my.cnf using BACKUP-DIR/ibbackup_logfile,
and creates new InnoDB log files as specified in BACKUP-DIR/backup-my.cnf.
The BACKUP-DIR should be a path name of a backup directory created by
innobackup. This command runs ibbackup as a child process, but it does not
connect to the database server.
带有--copy-back选项的命令从备份目录拷贝数据,索引,日志到my.cnf文件里规定的初始位置。
The command with --copy-back option copies data, index, and log files
from backup directory back to their original locations.
The MY.CNF options file defines the original location of the database.
The BACKUP-DIR is a path name of a backup directory created by innobackup.
Xtrabackup还可以用来moving InnoDB tables between servers,更多的内容可以参考官方文档及例子。
参考链接:Xtrabackup online backup for InnoDB/XTraDB(pdf)
下面是一个实际备份的例子,采用了gzip将备份流进行压缩,约20GB的数据库,压缩后大小为340MB,当然,压缩后的大小跟数据库中实际使用的空间是相关的。备份时间约6分44秒。
innobackupex是参考了InnoDB Hotbackup的innoback脚本修改而来的,主要是为了方便的同时备份InnoDB和MyISAM引擎的表,并且加入了一些使用的选项。如–slave-info可以记录备份恢复后,作为slave需要的一些信息,根据这些信息,可以很方便的利用备份来重做slave。
注意,从备份后的tar包解包的时候,需要使用-i参数。最新发布的是0.7版,猛击这里下载
MySQL DBA们,你是如何做备份的呢?欢迎到这里探讨。
$innobackupex-1.5.1 --user=root --stream=tar /bak/ --slave-info | gzip > /bak/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.67, for redhat-linux-gnu (x86_64) using EditLine wrapper innobackupex: Using mysql server version 5.0.67-log innobackupex: Created backup directory /bak 090625 15:23:00 innobackupex: Starting mysql with options: --unbuffered --user=root 090625 15:23:00 innobackupex: Connected to database with mysql child process (pid=3431) 090625 15:23:04 innobackupex: Connection to database server closed 090625 15:23:04 innobackupex: Starting ibbackup with command: xtrabackup --backup --suspend-at-end --log-stream --target-dir=./ innobackupex: Waiting for ibbackup (pid=3565) to suspend innobackupex: Suspend file '/opt/mysqldata/xtrabackup_suspended' xtrabackup: suspend-at-end is enabled. xtrabackup: uses posix_fadvise(). xtrabackup: cd to /opt/mysqldata xtrabackup: Target instance is assumed as followings. xtrabackup: innodb_data_home_dir = /opt/mysqldata xtrabackup: innodb_data_file_path = ibdata1:10G;ibdata2:10G xtrabackup: innodb_log_group_home_dir = ./ xtrabackup: innodb_log_files_in_group = 4 xtrabackup: innodb_log_file_size = 104857600 xtrabackup: use O_DIRECT xtrabackup: Stream mode. >> log scanned up to (0 3053406941) 090625 15:23:06 innobackupex: Continuing after ibbackup has suspended innobackupex: Starting to backup InnoDB tables and indexes innobackupex: from original InnoDB data directory '/opt/mysqldata' innobackupex: Backing up as tar stream 'ibdata1' >> log scanned up to (0 3053416714) ...这里省略若干行 >> log scanned up to (0 3054123851) tar: ibdata1: file changed as we read it innobackupex: Backing up as tar stream 'ibdata2' >> log scanned up to (0 3054142116) ...这里省略若干行 >> log scanned up to (0 3054618483) innobackupex: Backing up file '/opt/mysqldata/test/sp.ibd' innobackupex: Backing up file '/opt/mysqldata/test/tmp_dy.ibd' innobackupex: Backing up files '/opt/mysqldata/testdb/*.ibd' (206 files) >> log scanned up to (0 3054638401) >> log scanned up to (0 3054668860) tar: testdb/group_group_thread_0027.ibd: file changed as we read it >> log scanned up to (0 3054695015) >> log scanned up to (0 3054928216) tar: testdb/group_thread_reply_0007.ibd: file changed as we read it >> log scanned up to (0 3054952588) >> log scanned up to (0 3055005439) tar: testdb/group_user_0001.ibd: file changed as we read it >> log scanned up to (0 3055028610) >> log scanned up to (0 3055044650) tar: testdb/group_user_0006.ibd: file changed as we read it >> log scanned up to (0 3055060461) innobackupex: Backing up file '/opt/mysqldata/testdb/comments.ibd' innobackupex: Backing up file '/opt/mysqldata/testdb/testdb.ibd' innobackupex: Backing up file '/opt/mysqldata/testdb/testdb_content.ibd' innobackupex: Backing up file '/opt/mysqldata/testdb/testdb_ids.ibd' 090625 15:29:17 innobackupex: Starting mysql with options: --unbuffered --user=root 090625 15:29:17 innobackupex: Connected to database with mysql child process (pid=5458) >> log scanned up to (0 3055072495) 090625 15:29:21 innobackupex: Starting to lock all tables... >> log scanned up to (0 3055087148) >> log scanned up to (0 3055119993) 090625 15:29:39 innobackupex: All tables locked and flushed to disk 090625 15:29:39 innobackupex: Starting to backup .frm, .MRG, .MYD, .MYI, innobackupex: .TRG, .TRN, and .opt files in innobackupex: subdirectories of '/opt/mysqldata' innobackupex: Backing up file '/opt/mysqldata/test/sp.frm' innobackupex: Backing up file '/opt/mysqldata/test/tmp_dy.frm' innobackupex: Backing up files '/opt/mysqldata/testdb/*.{frm,MYD,MYI,MRG,TRG,TRN,opt}' (207 files) innobackupex: Backing up file '/opt/mysqldata/testdb/comments.frm' innobackupex: Backing up file '/opt/mysqldata/testdb/testdb.frm' innobackupex: Backing up file '/opt/mysqldata/testdb/testdb_content.frm' innobackupex: Backing up file '/opt/mysqldata/testdb/testdb_ids.frm' innobackupex: Backing up file '/opt/mysqldata/testdb/db.opt' innobackupex: Backing up files '/opt/mysqldata/mysql/*.{frm,MYD,MYI,MRG,TRG,TRN,opt}' (52 files) 090625 15:29:40 innobackupex: Finished backing up .frm, .MRG, .MYD, .MYI, .TRG, .TRN, and .opt files innobackupex: Resuming ibbackup xtrabackup: The latest check point (for incremental): '0:3054881736' >> log scanned up to (0 3055120013) xtrabackup: Transaction log of lsn (0 3053102766) to (0 3055120013) was copied. 090625 15:29:44 innobackupex: All tables unlocked 090625 15:29:44 innobackupex: Connection to database server closed innobackupex: Backup created in directory '/bak/' innobackupex: MySQL binlog position: filename '', position innobackupex: MySQL slave binlog position: master host '127.0.0.1', filename 'mysql-bin.000006', position 227207755 090625 15:29:44 innobackupex: innobackup completed OK! innobackupex: You must use -i (--ignore-zeros) option for extraction of the tar stream.
其它资源:
Impossible – possible, moving InnoDB tables between servers
Copying InnoDB tables between servers
XtraBackup: Open Source Alternative for Innodb Hot Backup call for ideas
发表评论
-
Permission denied: exec of '/usr/local/nagios/sbin/status.cgi' failed
2012-07-16 18:26 3996nagios登陆正常,但是访问所有的服务出错,检查nagios ... -
SwingBench配置
2012-07-16 13:37 2136SwingBench是一个Oracle压力 ... -
QPS、PV和需要部署机器数量计算公式(转)
2012-06-18 13:41 1452QPS、PV和需要部署机器数量计算公式(转) 术 ... -
QPS、PV和需要部署机器数量计算公式(转)
2012-06-18 13:41 0QPS、PV和需要部署机器数量计算公式(转) 术 ... -
Oracle SQL 调优健康检查脚本
2012-05-15 17:25 1144我们关注数据库系统的性能,进行数据库调优的主要工作就是进行SQ ... -
puppet运维自动化之puppet基础知识介绍
2012-05-09 16:54 1400【puppet 基础导读】 pup ... -
nagios安装注意点
2012-01-17 00:22 4130装了最新版nagios(3.3.1),在装得过程遇到如下问题: ... -
通过开源工具orabm计算TPS值来测试服务器CPU性能
2011-06-02 02:11 1857测试平台: RHEL4.8 x8_64 + Oracle ... -
Maatkit--Mysql的高级管理工具集
2011-03-24 16:01 5518Maatkit是Mysql的一个高级管理工具集。 官方网站:h ... -
性能测试工具sysbench简介
2011-03-24 01:06 1257sysbench是一款开源的多线程性能测试工具,可以执行CPU ...
相关推荐
监控MySQL的状态是DBA日常工作的部分,这涉及了如何使用MySQL自带的性能_schema,以及第三方工具如Percona Toolkit、pt-query-digest等。当遇到性能问题或异常时,如何进行故障排查和诊断。 八、高级特性 MySQL的...
理解SELECT语句的复杂性,如JOIN操作、子查询、聚合函数和分组,是DBA必备技能。此外,掌握事务处理(BEGIN、COMMIT、ROLLBACK)和索引的使用也是提高性能的关键。 3. **用户管理与权限管理**: MySQL提供了丰富的...
总的来说,Xtrabackup是MySQL DBA在进行数据安全备份时的重要选择,能够提供高效且灵活的备份策略,确保在不影响服务的前提下实现数据的可靠保护。了解和熟练使用Xtrabackup是MySQL管理者的必备技能,特别是在处理...
同时,了解如何在数据丢失或系统故障时快速恢复,是DBA必备的技能。 四、高可用性与复制 MySQL提供了多种实现高可用性的方案,如主从复制、主主复制、半同步复制等。DBA需要熟悉这些复制模式的设置与监控,以及在...
- **备份工具**:使用mysqldump、xtrabackup等工具进行备份操作。 - **恢复流程**:数据丢失后的快速恢复步骤。 #### 七、运维工程师与MySQL DBA 角色定位 - **角色差异**:运维工程师与数据库管理员(DBA)的工作...
5. **备份与恢复**:数据安全至关重要,如何进行全量备份、增量备份,以及如何在灾难情况下快速恢复数据,是DBA必备的技能。了解mysqldump、XtraBackup等工具的使用是必要的。 6. **高可用性**:MySQL的复制技术,...
总的来说,MySQL 5.1 官方简体中文版参考手册是开发者、DBA和系统管理员必备的学习资料,它能帮助读者全面理解MySQL的特性和用法,从而更高效地利用这一强大的数据库系统。通过深入阅读和实践,你可以掌握数据库设计...
《High Performance MySQL》是一本深度探讨MySQL性能优化...总之,《High Performance MySQL》是深入理解MySQL性能优化和运维的一本必备参考书,无论你是初学者还是资深DBA,都能从中获益良多,提升你的MySQL实战技能。
监控和调优工具是保持MySQL高效运行的必备武器。书中会介绍如何使用各种工具,如MySQL Enterprise Monitor、Percona Toolkit等,来监控数据库性能并进行问题诊断。同时,还会讲解备份和恢复策略,包括热备份、冷备份...
通常结合binlog实现,例如基于InnoDB存储引擎的XtraBackup工具(如innobackupex)。 4. **存储引擎锁**:MySQL支持多种存储引擎,如InnoDB、MyISAM等,它们有不同的锁机制。InnoDB支持行级锁定,提高并发性能;而...
这本MySQL 8.0中文参考手册是开发人员、DBA和运维人员的必备工具,它详细阐述了MySQL的所有方面,无论你是初学者还是经验丰富的用户,都能从中受益。通过深入阅读和实践,你可以更好地掌握MySQL 8.0的功能和最佳实践...
理解不同的备份类型,如增量备份和全量备份,以及如何使用mysqldump和xtrabackup等工具是必要的。 最后,了解如何利用MySQL与大数据平台(如Hadoop、Spark)集成,以及如何在云环境中部署和管理MySQL,如在AWS的RDS...
学习如何使用mysqldump进行逻辑备份,以及如何利用xtrabackup等工具进行物理备份,是每个DBA必备的技能。同时,了解如何在灾难发生后恢复数据,是防止数据丢失的关键。 最后,随着大数据量的增长,分区和分片技术...