搜索
首页数据库mysql教程MySQL Study之--MySQL innodb引擎备份工具XtraBackup之一(Install)_MySQL

MySQL Study之--MySQL innodb引擎备份工具XtraBackup之一(Install)

Xtrabackup是一个对InnoDB做数据备份的工具,支持在线热备份(备份时不影响数据读写),是商业备份工具InnoDB Hotbackup的一个很好的替代品。

 

Xtrabackup有两个主要的工具:xtrabackup、innobackupex

 

(1)xtrabackup只能备份InnoDB和XtraDB两种数据表,而不能备份MyISAM数据表

 

(2)innobackupex-1.5.1则封装了xtrabackup,是一个脚本封装,所以能同时备份处理innodb和myisam,但在处理myisam时需要加一个读锁

 

安装XtraBackup,首先要安装MySQL

 

1、查看MySQL版本

[root@rh64 ~]# service mysql start

Starting MySQL (Percona Server)...[  OK  ]

[root@rh64 ~]# mysql -u root -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.25-73.1 Percona Server (GPL), Release 73.1, Revision 07b797f

Copyright (c) 2009-2015 Percona LLC and/or its affiliates

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

 

2、安装配置

 

在/etc/my.cnf文件要配置数据所存储的目录

[root@rh64 XtraBackup]# cat /etc/my.cnf |grep datadir

datadir=/var/lib/mysql

 

3、下载安装

MySQL Study之--MySQL innodb引擎备份工具XtraBackup之一(Install)_MySQL

安装:

[root@rh64 XtraBackup]# ls -l

total 26808

-rw-r----- 1 mysql mysql  5664452 Oct 27 10:27 percona-xtrabackup-2.3.2-1.el6.x86_64.rpm

-rw-r----- 1 mysql mysql 20807976 Oct 27 10:27 percona-xtrabackup-debuginfo-2.3.2-1.el6.x86_64.rpm

-rw-r----- 1 mysql mysql   971264 Oct 27 10:27 percona-xtrabackup-test-2.3.2-1.el6.x86_64.rpm

 

[root@rh64 XtraBackup]# rpm -ivh percona-xtrabackup-2.3.2-1.el6.x86_64.rpm

warning: percona-xtrabackup-2.3.2-1.el6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY

error: Failed dependencies:

        libev.so.4()(64bit) is needed by percona-xtrabackup-2.3.2-1.el6.x86_64

 

----安装出错,要求需有libev.so库支持

 

下载libev安装包:

[root@rh64 libev-4.15]# tar zxvf libev-4.15.tar.gz 

 

安装libev:

[root@rh64 libev-4.15]# ./configure

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for a thread-safe mkdir -p... /bin/mkdir -p

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking whether to enable maintainer-specific portions of Makefiles... no

checking for gcc... gcc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables... 

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

checking for style of include used by make... GNU

checking dependency style of gcc... gcc3

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking how to print strings... printf

checking for a sed that does not truncate output... /bin/sed

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

checking for fgrep... /bin/grep -F

checking for ld used by gcc... /usr/bin/ld

checking if the linker (/usr/bin/ld) is GNU ld... yes

checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B

checking the name lister (/usr/bin/nm -B) interface... BSD nm

checking whether ln -s works... yes

checking the maximum length of command line arguments... 1966080

checking whether the shell understands some XSI constructs... yes

checking whether the shell understands "+="... yes

checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop

checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop

checking for /usr/bin/ld option to reload object files... -r

checking for objdump... objdump

checking how to recognize dependent libraries... pass_all

checking for dlltool... no

checking how to associate runtime and link libraries... printf %s\n

checking for ar... ar

checking for archiver @FILE support... @

......

 

[root@rh64 libev-4.15]# make

make  all-am

make[1]: Entering directory `/home/mysql/libev-4.15'

/bin/sh ./libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.     -g -O3 -MT ev.lo -MD -MP -MF .deps/ev.Tpo -c -o ev.lo ev.c

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O3 -MT ev.lo -MD -MP -MF .deps/ev.Tpo -c ev.c  -fPIC -DPIC -o .libs/ev.o

ev.c:1531: warning: 'ev_default_loop_ptr' initialized and declared 'extern'

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O3 -MT ev.lo -MD -MP -MF .deps/ev.Tpo -c ev.c -o ev.o >/dev/null 2>&1

mv -f .deps/ev.Tpo .deps/ev.Plo

/bin/sh ./libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.     -g -O3 -MT event.lo -MD -MP -MF .deps/event.Tpo -c -o event.lo event.c

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O3 -MT event.lo -MD -MP -MF .deps/event.Tpo -c event.c  -fPIC -DPIC -o .libs/event.o

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -O3 -MT event.lo -MD -MP -MF .deps/event.Tpo -c event.c -o event.o >/dev/null 2>&1

mv -f .deps/event.Tpo .deps/event.Plo

/bin/sh ./libtool --tag=CC   --mode=link gcc  -g -O3 -version-info 4:0:0  -o libev.la -rpath /usr/local/lib ev.lo event.lo  -lm 

libtool: link: gcc -shared  -fPIC -DPIC  .libs/ev.o .libs/event.o   -lm  -O3   -Wl,-soname -Wl,libev.so.4 -o .libs/libev.so.4.0.0

libtool: link: (cd ".libs" && rm -f "libev.so.4" && ln -s "libev.so.4.0.0" "libev.so.4")

libtool: link: (cd ".libs" && rm -f "libev.so" && ln -s "libev.so.4.0.0" "libev.so")

libtool: link: ar cru .libs/libev.a  ev.o event.o

libtool: link: ranlib .libs/libev.a

libtool: link: ( cd ".libs" && rm -f "libev.la" && ln -s "../libev.la" "libev.la" )

make[1]: Leaving directory `/home/mysql/libev-4.15'

 

[root@rh64 libev-4.15]# make install

make[1]: Entering directory `/home/mysql/libev-4.15'

 /bin/mkdir -p '/usr/local/lib'

 /bin/sh ./libtool   --mode=install /usr/bin/install -c   libev.la '/usr/local/lib'

libtool: install: /usr/bin/install -c .libs/libev.so.4.0.0 /usr/local/lib/libev.so.4.0.0

libtool: install: (cd /usr/local/lib && { ln -s -f libev.so.4.0.0 libev.so.4 || { rm -f libev.so.4 && ln -s libev.so.4.0.0 libev.so.4; }; })

libtool: install: (cd /usr/local/lib && { ln -s -f libev.so.4.0.0 libev.so || { rm -f libev.so && ln -s libev.so.4.0.0 libev.so; }; })

libtool: install: /usr/bin/install -c .libs/libev.lai /usr/local/lib/libev.la

libtool: install: /usr/bin/install -c .libs/libev.a /usr/local/lib/libev.a

libtool: install: chmod 644 /usr/local/lib/libev.a

libtool: install: ranlib /usr/local/lib/libev.a

libtool: finish: PATH="/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/local/lib

----------------------------------------------------------------------

Libraries have been installed in:

   /usr/local/lib

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR'

flag during linking and do at least one of the following:

   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable

     during execution

   - add LIBDIR to the `LD_RUN_PATH' environment variable

     during linking

   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag

   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

----------------------------------------------------------------------

 /bin/mkdir -p '/usr/local/include'

 /usr/bin/install -c -m 644 ev.h ev++.h event.h '/usr/local/include'

 /bin/mkdir -p '/usr/local/share/man/man3'

 /usr/bin/install -c -m 644 ev.3 '/usr/local/share/man/man3'

make[1]: Leaving directory `/home/mysql/libev-4.15'

 

查看libev安装信息:

[root@rh64 libev-4.15]# find / -name 'libev.so*'

/home/mysql/libev-4.15/.libs/libev.so.4.0.0

/home/mysql/libev-4.15/.libs/libev.so

/home/mysql/libev-4.15/.libs/libev.so.4

/usr/local/lib/libev.so.4.0.0

/usr/local/lib/libev.so.4

/usr/local/lib/libev.so

 

配置lib访问环境:

[root@rh64 XtraBackup]# cat /etc/profile

export LIBDIR=/usr/local/lib

export LD_LIBRARY_PATH=/usr/local/lib

export LD_RUN_PATH=/usr/local/lib

"/etc/profile" 82L, 1898C written

 

再次安装:

[root@rh64 XtraBackup]# rpm -ivh percona-xtrabackup-2.3.2-1.el6.x86_64.rpm

warning: percona-xtrabackup-2.3.2-1.el6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY

error: Failed dependencies:

        libev.so.4()(64bit) is needed by percona-xtrabackup-2.3.2-1.el6.x86_64

 

---仍然失败!!!可能是libev的版本不对,应该下载libev(64)

 

 

下载libev(64)并安装:

http://rpmfind.net/linux/rpm2html/search.php?query=libev.so.4()(64bit)

 

[root@rh64 mysql]# rpm -ivh libev-4.04-2.el6.x86_64.rpm 

warning: libev-4.04-2.el6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 66534c2b: NOKEY

Preparing...                ########################################### [100%]

   1:libev                  ########################################### [100%]

 

[root@rh64 mysql]# rpm -qa |grep libev

libevent-1.4.13-4.el6.x86_64

libevent-1.4.13-4.el6.i686

libev-4.04-2.el6.x86_64

[root@rh64 mysql]# rpm -ql libev

/usr/lib64/libev.so.4

/usr/lib64/libev.so.4.0.0

/usr/share/doc/libev-4.04

/usr/share/doc/libev-4.04/Changes

/usr/share/doc/libev-4.04/LICENSE

/usr/share/doc/libev-4.04/README

 

安装xtrabackup:

 

[root@rh64 XtraBackup]# ls

percona-xtrabackup-2.3.2-1.el6.x86_64.rpm            percona-xtrabackup-test-2.3.2-1.el6.x86_64.rpm

percona-xtrabackup-debuginfo-2.3.2-1.el6.x86_64.rpm

 

[root@rh64 XtraBackup]# rpm -ivh *

warning: percona-xtrabackup-2.3.2-1.el6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY

Preparing...                ########################################### [100%]

   1:percona-xtrabackup     ########################################### [ 33%]

   2:percona-xtrabackup-test########################################### [ 67%]

   3:percona-xtrabackup-debu########################################### [100%]

 

  ----安装成功!!!

   

[root@rh64 XtraBackup]# man innobackupex

INNOBACKUPEX(1)               Percona XtraBackup               INNOBACKUPEX(1)

NAME

       innobackupex - innobackupex Documentation

 

       The  innobackupex  tool is a Perl script that acts as a wrapper for the xtrabackup C program. It

       is a patched version of the innobackup Perl script that Oracle distributes with the  InnoDB  Hot

       Backup tool. It enables more functionality by integrating xtrabackup and other functions such as

       file copying and streaming, and adds some convenience. It lets you perform point-in-time backups

       of  InnoDB  /  XtraDB tables together with the schema definitions, MyISAM tables, and other por-

       tions of the server.

       This manual section explains how to use innobackupex in detail.

PREREQUISITES

   Connection and Privileges Needed

       Percona XtraBackup needs to be able to connect to the database server and perform operations  on

       the  server  and  the  datadir when creating a backup, when preparing in some scenarios and when

       restoring it. In order to do so, there are privileges and permission requirements on its  execu-

       tion that must be fulfilled.

       Privileges  refers  to  the  operations  that  a  system user is permitted to do in the database

       server. They are set at the database server and only apply to users in the database server.

       Permissions are those which permits a user to perform operations on the  system,  like  reading,

       writing  or  executing  on a certain directory or start/stop a system service. They are set at a

       system level and only apply to system users.

       Whether xtrabackup or innobackupex is used, there are two actors involved: the user invoking the

       program  -  a  system  user - and the user performing action in the database server - a database

       user. Note that these are different users in different places, even tough they may have the same

       username.

       All the invocations of innobackupex and xtrabackup in this documentation assumes that the system

       user has the appropriate permissions and you are providing the relevant options  for  connecting

       the database server - besides the options for the action to be performed - and the database user

       has adequate privileges.

   Connecting to the server

       The database user used to connect to the server and its password are specified by the --user and

       --password option,

           $ innobackupex --user=DBUSER --password=SECRET /path/to/backup/dir/

           $ innobackupex --user=LUKE  --password=US3TH3F0RC3 --stream=tar ./ | bzip2 -

           $ xtrabackup --user=DVADER --password=14MY0URF4TH3R --backup --target-dir=/data/bkps/

 

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
您什么时候应该使用复合索引与多个单列索引?您什么时候应该使用复合索引与多个单列索引?Apr 11, 2025 am 12:06 AM

在数据库优化中,应根据查询需求选择索引策略:1.当查询涉及多个列且条件顺序固定时,使用复合索引;2.当查询涉及多个列但条件顺序不固定时,使用多个单列索引。复合索引适用于优化多列查询,单列索引则适合单列查询。

如何识别和优化MySQL中的慢速查询? (慢查询日志,performance_schema)如何识别和优化MySQL中的慢速查询? (慢查询日志,performance_schema)Apr 10, 2025 am 09:36 AM

要优化MySQL慢查询,需使用slowquerylog和performance_schema:1.启用slowquerylog并设置阈值,记录慢查询;2.利用performance_schema分析查询执行细节,找出性能瓶颈并优化。

MySQL和SQL:开发人员的基本技能MySQL和SQL:开发人员的基本技能Apr 10, 2025 am 09:30 AM

MySQL和SQL是开发者必备技能。1.MySQL是开源的关系型数据库管理系统,SQL是用于管理和操作数据库的标准语言。2.MySQL通过高效的数据存储和检索功能支持多种存储引擎,SQL通过简单语句完成复杂数据操作。3.使用示例包括基本查询和高级查询,如按条件过滤和排序。4.常见错误包括语法错误和性能问题,可通过检查SQL语句和使用EXPLAIN命令优化。5.性能优化技巧包括使用索引、避免全表扫描、优化JOIN操作和提升代码可读性。

描述MySQL异步主奴隶复制过程。描述MySQL异步主奴隶复制过程。Apr 10, 2025 am 09:30 AM

MySQL异步主从复制通过binlog实现数据同步,提升读性能和高可用性。1)主服务器记录变更到binlog;2)从服务器通过I/O线程读取binlog;3)从服务器的SQL线程应用binlog同步数据。

mysql:简单的概念,用于轻松学习mysql:简单的概念,用于轻松学习Apr 10, 2025 am 09:29 AM

MySQL是一个开源的关系型数据库管理系统。1)创建数据库和表:使用CREATEDATABASE和CREATETABLE命令。2)基本操作:INSERT、UPDATE、DELETE和SELECT。3)高级操作:JOIN、子查询和事务处理。4)调试技巧:检查语法、数据类型和权限。5)优化建议:使用索引、避免SELECT*和使用事务。

MySQL:数据库的用户友好介绍MySQL:数据库的用户友好介绍Apr 10, 2025 am 09:27 AM

MySQL的安装和基本操作包括:1.下载并安装MySQL,设置根用户密码;2.使用SQL命令创建数据库和表,如CREATEDATABASE和CREATETABLE;3.执行CRUD操作,使用INSERT,SELECT,UPDATE,DELETE命令;4.创建索引和存储过程以优化性能和实现复杂逻辑。通过这些步骤,你可以从零开始构建和管理MySQL数据库。

InnoDB缓冲池如何工作,为什么对性能至关重要?InnoDB缓冲池如何工作,为什么对性能至关重要?Apr 09, 2025 am 12:12 AM

InnoDBBufferPool通过将数据和索引页加载到内存中来提升MySQL数据库的性能。1)数据页加载到BufferPool中,减少磁盘I/O。2)脏页被标记并定期刷新到磁盘。3)LRU算法管理数据页淘汰。4)预读机制提前加载可能需要的数据页。

MySQL:初学者的数据管理易用性MySQL:初学者的数据管理易用性Apr 09, 2025 am 12:07 AM

MySQL适合初学者使用,因为它安装简单、功能强大且易于管理数据。1.安装和配置简单,适用于多种操作系统。2.支持基本操作如创建数据库和表、插入、查询、更新和删除数据。3.提供高级功能如JOIN操作和子查询。4.可以通过索引、查询优化和分表分区来提升性能。5.支持备份、恢复和安全措施,确保数据的安全和一致性。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
3 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

安全考试浏览器

安全考试浏览器

Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )专业的PHP集成开发工具