热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

MySQLStudy之--MySQLinnodb引擎备份工具XtraBackup之一(Install)_MySQL

MySQLStudy之--MySQLinnodb引擎备份工具XtraBackup之一(Install)Xtrabackup是一个对InnoDB做数据备份的工具,支持在线热备份(备份时不影响数据读写),是商业备份工具InnoDBHotbackup的一个很好的替
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、下载安装

安装:

[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/

推荐阅读
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文介绍了在Mac上搭建php环境后无法使用localhost连接mysql的问题,并通过将localhost替换为127.0.0.1或本机IP解决了该问题。文章解释了localhost和127.0.0.1的区别,指出了使用socket方式连接导致连接失败的原因。此外,还提供了相关链接供读者深入了解。 ... [详细]
  • CEPH LIO iSCSI Gateway及其使用参考文档
    本文介绍了CEPH LIO iSCSI Gateway以及使用该网关的参考文档,包括Ceph Block Device、CEPH ISCSI GATEWAY、USING AN ISCSI GATEWAY等。同时提供了多个参考链接,详细介绍了CEPH LIO iSCSI Gateway的配置和使用方法。 ... [详细]
  • 本文介绍了在Ubuntu下制作deb安装包及离线安装包的方法,通过备份/var/cache/apt/archives文件夹中的安装包,并建立包列表及依赖信息文件,添加本地源,更新源列表,可以在没有网络的情况下更新系统。同时提供了命令示例和资源下载链接。 ... [详细]
  • 本文内容为asp.net微信公众平台开发的目录汇总,包括数据库设计、多层架构框架搭建和入口实现、微信消息封装及反射赋值、关注事件、用户记录、回复文本消息、图文消息、服务搭建(接入)、自定义菜单等。同时提供了示例代码和相关的后台管理功能。内容涵盖了多个方面,适合综合运用。 ... [详细]
  • Nginx使用AWStats日志分析的步骤及注意事项
    本文介绍了在Centos7操作系统上使用Nginx和AWStats进行日志分析的步骤和注意事项。通过AWStats可以统计网站的访问量、IP地址、操作系统、浏览器等信息,并提供精确到每月、每日、每小时的数据。在部署AWStats之前需要确认服务器上已经安装了Perl环境,并进行DNS解析。 ... [详细]
  • GetWindowLong函数
    今天在看一个代码里头写了GetWindowLong(hwnd,0),我当时就有点费解,靠,上网搜索函数原型说明,死活找不到第 ... [详细]
  • 基于layUI的图片上传前预览功能的2种实现方式
    本文介绍了基于layUI的图片上传前预览功能的两种实现方式:一种是使用blob+FileReader,另一种是使用layUI自带的参数。通过选择文件后点击文件名,在页面中间弹窗内预览图片。其中,layUI自带的参数实现了图片预览功能。该功能依赖于layUI的上传模块,并使用了blob和FileReader来读取本地文件并获取图像的base64编码。点击文件名时会执行See()函数。摘要长度为169字。 ... [详细]
  • HDU 2372 El Dorado(DP)的最长上升子序列长度求解方法
    本文介绍了解决HDU 2372 El Dorado问题的一种动态规划方法,通过循环k的方式求解最长上升子序列的长度。具体实现过程包括初始化dp数组、读取数列、计算最长上升子序列长度等步骤。 ... [详细]
  • 本文讨论了Alink回归预测的不完善问题,指出目前主要针对Python做案例,对其他语言支持不足。同时介绍了pom.xml文件的基本结构和使用方法,以及Maven的相关知识。最后,对Alink回归预测的未来发展提出了期待。 ... [详细]
  • Windows下配置PHP5.6的方法及注意事项
    本文介绍了在Windows系统下配置PHP5.6的步骤及注意事项,包括下载PHP5.6、解压并配置IIS、添加模块映射、测试等。同时提供了一些常见问题的解决方法,如下载缺失的msvcr110.dll文件等。通过本文的指导,读者可以轻松地在Windows系统下配置PHP5.6,并解决一些常见的配置问题。 ... [详细]
  • 本文详细介绍了Linux中进程控制块PCBtask_struct结构体的结构和作用,包括进程状态、进程号、待处理信号、进程地址空间、调度标志、锁深度、基本时间片、调度策略以及内存管理信息等方面的内容。阅读本文可以更加深入地了解Linux进程管理的原理和机制。 ... [详细]
  • 《数据结构》学习笔记3——串匹配算法性能评估
    本文主要讨论串匹配算法的性能评估,包括模式匹配、字符种类数量、算法复杂度等内容。通过借助C++中的头文件和库,可以实现对串的匹配操作。其中蛮力算法的复杂度为O(m*n),通过随机取出长度为m的子串作为模式P,在文本T中进行匹配,统计平均复杂度。对于成功和失败的匹配分别进行测试,分析其平均复杂度。详情请参考相关学习资源。 ... [详细]
  • CentOS 7部署KVM虚拟化环境之一架构介绍
    本文介绍了CentOS 7部署KVM虚拟化环境的架构,详细解释了虚拟化技术的概念和原理,包括全虚拟化和半虚拟化。同时介绍了虚拟机的概念和虚拟化软件的作用。 ... [详细]
  • IT方面的论坛太多了,有综合,有专业,有行业,在各个论坛里混了几年,体会颇深,以前是论坛哪里人多 ... [详细]
author-avatar
幸福的xinwangnanfei_736
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有