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/

산성 속성에는 원자력, 일관성, 분리 및 내구성이 포함되며 데이터베이스 설계의 초석입니다. 1. 원자력은 거래가 완전히 성공적이거나 완전히 실패하도록합니다. 2. 일관성은 거래 전후에 데이터베이스가 일관성을 유지하도록합니다. 3. 격리는 거래가 서로를 방해하지 않도록합니다. 4. 지속성은 거래 제출 후 데이터가 영구적으로 저장되도록합니다.

MySQL은 데이터베이스 관리 시스템 (DBMS) 일뿐 만 아니라 프로그래밍 언어와 밀접한 관련이 있습니다. 1) DBMS로서 MySQL은 데이터를 저장, 구성 및 검색하는 데 사용되며 인덱스 최적화는 쿼리 성능을 향상시킬 수 있습니다. 2) SQL과 같은 ORM 도구를 사용하여 Python에 내장 된 SQL과 프로그래밍 언어를 결합하면 작업을 단순화 할 수 있습니다. 3) 성능 최적화에는 인덱싱, 쿼리, 캐싱, 라이브러리 및 테이블 부서 및 거래 관리가 포함됩니다.

MySQL은 SQL 명령을 사용하여 데이터를 관리합니다. 1. 기본 명령에는 선택, 삽입, 업데이트 및 삭제가 포함됩니다. 2. 고급 사용에는 조인, 하위 쿼리 및 집계 함수가 포함됩니다. 3. 일반적인 오류에는 구문, 논리 및 성능 문제가 포함됩니다. 4. 최적화 팁에는 인덱스 사용, 선택*을 피하고 한계 사용이 포함됩니다.

MySQL은 데이터 저장 및 관리에 적합한 효율적인 관계형 데이터베이스 관리 시스템입니다. 장점에는 고성능 쿼리, 유연한 트랜잭션 처리 및 풍부한 데이터 유형이 포함됩니다. 실제 애플리케이션에서 MySQL은 종종 전자 상거래 플랫폼, 소셜 네트워크 및 컨텐츠 관리 시스템에서 사용되지만 성능 최적화, 데이터 보안 및 확장성에주의를 기울여야합니다.

SQL과 MySQL의 관계는 표준 언어와 특정 구현의 관계입니다. 1.SQL은 관계형 데이터베이스를 관리하고 운영하는 데 사용되는 표준 언어로, 데이터 추가, 삭제, 수정 및 쿼리를 허용합니다. 2.MySQL은 SQL을 운영 언어로 사용하고 효율적인 데이터 저장 및 관리를 제공하는 특정 데이터베이스 관리 시스템입니다.

InnoDB는 Redologs 및 Undologs를 사용하여 데이터 일관성과 신뢰성을 보장합니다. 1. Redologs는 사고 복구 및 거래 지속성을 보장하기 위해 데이터 페이지 수정을 기록합니다. 2. 결점은 원래 데이터 값을 기록하고 트랜잭션 롤백 및 MVCC를 지원합니다.

설명 명령에 대한 주요 메트릭에는 유형, 키, 행 및 추가가 포함됩니다. 1) 유형은 쿼리의 액세스 유형을 반영합니다. 값이 높을수록 Const와 같은 효율이 높아집니다. 2) 키는 사용 된 인덱스를 표시하고 NULL은 인덱스가 없음을 나타냅니다. 3) 행은 스캔 한 행의 수를 추정하여 쿼리 성능에 영향을 미칩니다. 4) Extra는 최적화해야한다는 Filesort 프롬프트 사용과 같은 추가 정보를 제공합니다.

Temporary를 사용하면 MySQL 쿼리에 임시 테이블을 생성해야 할 필요성이 있으며, 이는 별개의, 그룹 비 또는 비 인덱스 열을 사용하여 순서대로 발견됩니다. 인덱스 발생을 피하고 쿼리를 다시 작성하고 쿼리 성능을 향상시킬 수 있습니다. 구체적으로, 설명 출력에 사용되는 경우, MySQL은 쿼리를 처리하기 위해 임시 테이블을 만들어야 함을 의미합니다. 이것은 일반적으로 다음과 같은 경우에 발생합니다. 1) 별개 또는 그룹을 사용할 때 중복 제거 또는 그룹화; 2) OrderBy가 비 인덱스 열이 포함되어있을 때 정렬하십시오. 3) 복잡한 하위 쿼리 또는 조인 작업을 사용하십시오. 최적화 방법은 다음과 같습니다. 1) Orderby 및 GroupB


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경
