percona-xtrabackup快速安装及其简单使用

cd /opt/
环境:centos6.x yum -y install perl-DBI
yum -y install perl-DBD-MySQL
yum -y install perl-IO-Socket-SSL.noarch
yum -y install perl-Time-HiRes  
yum -y install perl-TermReadKey
yum -y install perl-ExtUtils-MakeMaker
[root@db130 opt]# rpm -aq | grep libgcrypt
libgcrypt-devel-1.4.-.el6_8.x86_64
libgcrypt-1.4.-.el6_8.x86_64
# 下载对应的版本
wget https://www.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.12/binary/tarball/percona-xtrabackup-2.4.12-Linux-x86_64.libgcrypt145.tar.gz
tar -zxf percona-xtrabackup-2.4.-Linux-x86_64.libgcrypt145.tar.gz
mv percona-xtrabackup-2.4.-Linux-x86_64 percona-xtrabackup-2.4.
ln -s /opt/percona-xtrabackup-2.4.12/bin/* /usr/bin/
# 快速尝试恢复操作
# 备份的文件是:/root/tmp/data_test-03-28.tar.bz2
# 进行恢复前,请先找个环境,或者在本地直接恢复时,先停止数据库。
并且清空数据目录: /data/mysql/percona_server/data  # 我这里是这个目录
[root@db130 tmp]# rm -rf /data/mysql/percona_server/data/* tar -jxf data_test-03-28.tar.bz2
[root@db130 tmp]# ll
total 2097328
-rw-r----- 1 mysql mysql        489 Mar 28 00:01 backup-my.cnf
-rw-r----- 1 mysql mysql 2147483648 Mar 28 00:00 ibdata
-rw-r--r-- 1 mysql mysql      82769 Mar 28 00:01 innobackup.log
-rw-r--r-- 1 mysql mysql       3000 Mar 28 00:01 my.cnf
drwxr-x--- 2 mysql mysql       4096 Mar 28 00:01 mysql
drwxr-x--- 2 mysql mysql       4096 Mar 28 00:01 performance_schema
drwxr-x--- 2 mysql mysql      16384 Mar 28 00:01 db_test
-rw-r----- 1 mysql mysql        223 Mar 28 00:01 xtrabackup_binlog_info
-rw-r----- 1 mysql mysql        121 Mar 28 00:01 xtrabackup_checkpoints
-rw-r----- 1 mysql mysql        877 Mar 28 00:01 xtrabackup_info
-rw-r----- 1 mysql mysql      37888 Mar 28 00:01 xtrabackup_logfile
-rw-r----- 1 mysql mysql         79 Mar 28 00:01 xtrabackup_slave_info [root@db130 opt]# innobackupex --apply-log --use-memory=1G /root/tmp/
xtrabackup: recognized server arguments: --innodb_checksum_algorithm=innodb --innodb_log_checksum_algorithm=innodb --innodb_data_file_path=ibdata:2G:autoextend --innodb_log_files_in_group=3 --innodb_log_file_size=536870912 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=. --innodb_undo_tablespaces=0 --server-id=1535086937 --redo-log-version=0
xtrabackup: recognized client arguments: --innodb_checksum_algorithm=innodb --innodb_log_checksum_algorithm=innodb --innodb_data_file_path=ibdata:2G:autoextend --innodb_log_files_in_group=3 --innodb_log_file_size=536870912 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=. --innodb_undo_tablespaces=0 --server-id=1535086937 --redo-log-version=0
190328 17:56:49 innobackupex: Starting the apply-log operation IMPORTANT: Please check that the apply-log run completes successfully.
           At the end of a successful apply-log run innobackupex
           prints "completed OK!". innobackupex version 2.4.12 based on MySQL server 5.7.19 Linux (x86_64) (revision id: 170eb8c)
xtrabackup: cd to /root/tmp/
xtrabackup: This target seems to be not prepared yet.
InnoDB: Number of pools: 1
xtrabackup: xtrabackup_logfile detected: size=8388608, start_lsn=(31806247544)
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata:2G:autoextend
xtrabackup:   innodb_log_group_home_dir = .
xtrabackup:   innodb_log_files_in_group = 1
xtrabackup:   innodb_log_file_size = 8388608
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata:2G:autoextend
xtrabackup:   innodb_log_group_home_dir = .
xtrabackup:   innodb_log_files_in_group = 1
xtrabackup:   innodb_log_file_size = 8388608
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using 1073741824 bytes for buffer pool (set by --use-memory parameter)
InnoDB: PUNCH HOLE support available
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Uses event mutexes
InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
InnoDB: Compressed tables use zlib 1.2.3
InnoDB: Number of pools: 1
InnoDB: Using CPU crc32 instructions
InnoDB: Initializing buffer pool, total size = 1G, instances = 1, chunk size = 128M
InnoDB: Completed initialization of buffer pool
InnoDB: page_cleaner coordinator priority: -20
InnoDB: Highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 31806247544
InnoDB: Doing recovery: scanned up to log sequence number 31806283251 (0%)
InnoDB: Database was not shutdown normally!
InnoDB: Starting crash recovery.
InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
InnoDB: xtrabackup: Last MySQL binlog file position 908352864, file name mysql-bin.000018
InnoDB: Creating shared tablespace for temporary tables
InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
InnoDB: File './ibtmp1' size is now 12 MB.
InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active.
InnoDB: 32 non-redo rollback segment(s) are active.
InnoDB: Waiting for purge to start
InnoDB: 5.7.19 started; log sequence number 31806283251
InnoDB: xtrabackup: Last MySQL binlog file position 908352864, file name mysql-bin.000018 xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 31806284939
InnoDB: Number of pools: 1
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata:2G:autoextend
xtrabackup:   innodb_log_group_home_dir = .
xtrabackup:   innodb_log_files_in_group = 3
xtrabackup:   innodb_log_file_size = 536870912
InnoDB: PUNCH HOLE support available
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Uses event mutexes
InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
InnoDB: Compressed tables use zlib 1.2.3
InnoDB: Number of pools: 1
InnoDB: Using CPU crc32 instructions
InnoDB: Initializing buffer pool, total size = 1G, instances = 1, chunk size = 128M
InnoDB: Completed initialization of buffer pool
InnoDB: page_cleaner coordinator priority: -20
InnoDB: Setting log file ./ib_logfile101 size to 512 MB
InnoDB: Progress in MB:
 100 200 300 400 500
InnoDB: Setting log file ./ib_logfile1 size to 512 MB
InnoDB: Progress in MB:
 100 200 300 400 500
InnoDB: Setting log file ./ib_logfile2 size to 512 MB
InnoDB: Progress in MB:
 100 200 300 400 500
InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
InnoDB: New log files created, LSN=31806284939
InnoDB: Highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 31806285324
InnoDB: Doing recovery: scanned up to log sequence number 31806285333 (0%)
InnoDB: Database was not shutdown normally!
InnoDB: Starting crash recovery.
InnoDB: xtrabackup: Last MySQL binlog file position 908352864, file name mysql-bin.000018
InnoDB: Removed temporary tablespace data file: "ibtmp1"
InnoDB: Creating shared tablespace for temporary tables
InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
InnoDB: File './ibtmp1' size is now 12 MB.
InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active.
InnoDB: 32 non-redo rollback segment(s) are active.
InnoDB: Waiting for purge to start
InnoDB: page_cleaner: 1000ms intended loop took 17842ms. The settings might not be optimal. (flushed=0 and evicted=0, during the time.)
InnoDB: 5.7.19 started; log sequence number 31806285333
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 31806287020
190328 17:57:13 completed OK!
[root@db130 opt]#
  [root@db130 tmp]# cp -raf * /data/mysql/percona_server/data/
[root@db130 tmp]# chown -R mysql.mysql /data/mysql/percona_server/data/*
[root@db130 tmp]# su - mysql
[mysql@db130 ~]$ cd /data/mysql/percona_server/data/
[mysql@db130 data]$ rm -rf backup-my.cnf my.cnf innobackup.log xtrabackup_*
[mysql@db130 data]$ ll
total 3682340
-rw-r----- 1 mysql mysql 2147483648 Mar 28 18:05 ibdata
-rw-r----- 1 mysql mysql  536870912 Mar 28 18:05 ib_logfile0
-rw-r----- 1 mysql mysql  536870912 Mar 28 17:57 ib_logfile1
-rw-r----- 1 mysql mysql  536870912 Mar 28 17:57 ib_logfile2
-rw-r----- 1 mysql mysql   12582912 Mar 28 18:05 ibtmp1
drwxr-x--- 2 mysql mysql       4096 Mar 28 00:01 mysql
drwxr-x--- 2 mysql mysql       4096 Mar 28 00:01 performance_schema
drwxr-x--- 2 mysql mysql      20480 Mar 28 00:01 db_test
[mysql@db130 data]$ # 启动数据库
查看日志:
tail -f /data/mysql/percona_server/logs/mysql-error.log
2019-03-28 18:13:20 0 [Note] /data/mysql/percona_server/bin/mysqld (mysqld 5.6.41-84.1-log) starting as process 18085 ...
2019-03-28 18:13:20 18085 [Note] Plugin 'FEDERATED' is disabled.
2019-03-28 18:13:20 18085 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-03-28 18:13:20 18085 [Note] InnoDB: The InnoDB memory heap is disabled
2019-03-28 18:13:20 18085 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-03-28 18:13:20 18085 [Note] InnoDB: Memory barrier is not used
2019-03-28 18:13:20 18085 [Note] InnoDB: Compressed tables use zlib 1.2.3
2019-03-28 18:13:20 18085 [Note] InnoDB: Using CPU crc32 instructions
2019-03-28 18:13:20 18085 [Note] InnoDB: Initializing buffer pool, size = 10.0G
2019-03-28 18:13:25 18085 [Note] InnoDB: Completed initialization of buffer pool
2019-03-28 18:13:28 18085 [Note] InnoDB: Highest supported file format is Barracuda.
2019-03-28 18:13:30 18085 [Note] InnoDB: 128 rollback segment(s) are active.
2019-03-28 18:13:30 18085 [Note] InnoDB: Waiting for purge to start
2019-03-28 18:13:30 18085 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.41-84.1 started; log sequence number 31806291260
2019-03-28 18:13:31 18085 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 231afb9b-5142-11e9-b4ba-000c29774efe.
2019-03-28 18:13:31 18085 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
2019-03-28 18:13:31 18085 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
2019-03-28 18:13:31 18085 [Note] Server socket created on IP: '0.0.0.0'.
2019-03-28 18:13:34 18085 [ERROR] Failed to open the relay log '/data/mysql/percona_server/relay_log/relay-bin.000049' (relay_log_pos 197442274).
2019-03-28 18:13:34 18085 [ERROR] Could not find target log file mentioned in relay log info in the index file '/data/mysql/percona_server/relay_log/relay-bin.index' during relay log initialization.
2019-03-28 18:13:34 18085 [ERROR] Failed to initialize the master info structure
2019-03-28 18:13:34 18085 [Note] Check error log for additional messages. You will not be able to start replication until the issue is resolved and the server restarted.
2019-03-28 18:13:36 18085 [Note] Event Scheduler: Loaded 0 events
2019-03-28 18:13:36 18085 [Note] /data/mysql/percona_server/bin/mysqld: ready for connections.
Version: '5.6.41-84.1-log'  socket: '/data/mysql/percona_server/run/mysql.sock'  port: 3306  Source distribution 此时可以登录。
mysql> stop slave ;
Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> reset slave all;
Query OK, 0 rows affected (0.05 sec) mysql> show databases;
+---------------------+
| Database            |
+---------------------+
| information_schema  |
| mysql               |
| performance_schema  |
| db_test |
+---------------------+
4 rows in set (0.00 sec)
mysql> select user,host from mysql.user;
+---------------+-----------+
| user          | host      |
+---------------+-----------+
| user1         | %         |
| root          | 127.0.0.1 |
| root          | localhost |
+---------------+-----------+
10 rows in set (0.00 sec) mysql> exit
[root@db130 tmp]# cat xtrabackup_slave_info
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000019', MASTER_LOG_POS=197442064;
mysqlbinlog --start-position=197442064 [root@db130 tmp]# mysqlbinlog --start-position=197442064 mysql-bin.000019 >19.binlog
mysqlbinlog: unknown variable 'default-character-set=utf8mb4'
[root@db130 tmp]#
[root@db130 tmp]# mysqlbinlog --no-defaults --start-position=197442064  mysql-bin.000019 >19.binlog  
# 导入差异化数据
[mysql@db130 ~]$ mysql.login < /data/mysql/19.binlog &
[1] 18273
[mysql@db130 ~]$ Warning: Using a password on the command line interface can be insecure. 至此,一个全备份恢复完毕。
本人在测试环境中遇到的一个小坑:因为本地虚拟机的内存小,导致恢复数据时,数据库实例挂掉了。关闭虚拟机,调高内存,就可以解决掉。

percona-xtrabackup快速安装及其简单使用的更多相关文章

  1. docker 及 docker-compose 的快速安装和简单使用

    本篇将使用 DaoCloud 源在 Ubuntu 上简单快速安装 docker 及 docker-compose 并添加了通过 Dockerfile 及 docker-compose.yml 使用 n ...

  2. Alibaba Java诊断工具Arthas之快速安装和简单使用

    Alibaba Java诊断工具Arthas简单介绍 : 当你遇到以下类似问题而束手无策时,Arthas可以帮助你解决: 1.这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception ...

  3. CentOS 6.5下Percona Xtrabackup的安装错误解决方案

    1.下载最新版的Xtracbackup 2.安装 yum install perl-DBIyum install perl-DBD-MySQLyum install perl-Time-HiResyu ...

  4. Percona XtraBackup 安装介绍篇

    XtraBackup介绍 XtraBackup是Percona公司的开源项目,用以实现类似Innodb官方的热备份工具InnoDB Hot Backup的功能,它支持在线热备份(备份时不影响数据读写) ...

  5. Percona xtrabackup

    关于percona xtrabackup     percona xtrabackup是世界上唯一开源的.免费的MySQL热备份软件,可以为InnoDB存储引擎和XtraDB存储引擎进行不间断的备份, ...

  6. Percona XtraBackup 核心文档

    1. 介绍 1.1 MySQL 备份工具特性对比 Features Percona XtraBackup MySQL Enterprise backup License GPL Proprietary ...

  7. Docker Compose + Traefik v2 快速安装, 自动申请SSL证书 http转https 初次尝试

    前言 昨晚闲得无聊睡不着觉,拿起服务器尝试部署了一下Docker + Traefik v2.1.6 ,以下是一些配置的总结,初次接触,大佬勿喷. 我的系统环境是 Ubuntu 18.04.3 LTS ...

  8. CocoaPods 的简单快速安装方法

    CocoaPods 的简单快速安装方法(Setting up CocoaPods master repo 卡着不动,是因为淘宝镜像已经不能用了. 一.git clone方法安装cocoapods 镜像 ...

  9. Percona XtraBackup 8.0, 安装与测试

    Percona XtraBackup 8.0 是Percona XtraBackup新推出了一个针对MySQL8.0的版本,主要是MySQL8.0在Redo 和 数据库字典方面有了新的改进. Xtra ...

随机推荐

  1. SVN的使用说明

    SVN管理版本是比较好的东西,但是我的SVN图标老是不出来,有时候莫名其妙就没有了,所以记录一下处理办法: 1.右键->TortoiseSVN->Settings->Icon Ove ...

  2. 48.Odoo产品分析 (五) – 定制板块(3) – 修改文件和报告(1)

    查看Odoo产品分析系列--目录 不管ERP系统中的内置报表有多完善,大多数的公司仍然需要对文档和报表进行一些自定义的修改.  这一章节将介绍如何对报表的页眉和页脚做自定义修改:odoo框架如何组织报 ...

  3. Ajax - Apache安装配置

    apache安装配置 1.安装wamp2.配置根路径3.默认的网站根路径是安装目录的www子目录,如果不想使用默认目录,可以自己配置.配置方式如下: --找到文件wamp\bin\apache\Apa ...

  4. 利用AccessibilityService自动获取微信号(Android)

    前言: 最近遇到一个需求,要求写一个小插件,能够自动在微信的页面弹出一个窗口,展示用户的相关信息(与我们公司有关的信息,方便运营快速了解用户信息). 当时我第一反应是不可能,如果能够在别的app中获取 ...

  5. 使用免费 mongodb数据库 + 免费node.js服务器搭建小程序接口

    由于微信的小程序只支持不带端口的域名接口,不支持IP地址和接口,所以我们需要映射到80端口并绑定备案过的域名才能被微信小程序访问到.简单点就是接口需要 https 协议才行,找了许久的免费的数据库与n ...

  6. 深入浅出KNN算法(二) sklearn KNN实践

    姊妹篇: 深入浅出KNN算法(一) 原理介绍 上次介绍了KNN的基本原理,以及KNN的几个窍门,这次就来用sklearn实践一下KNN算法. 一.Skelarn KNN参数概述 要使用sklearnK ...

  7. 移动端click延迟和tap事件

    一.click等事件在移动端的延迟 click事件在移动端和pc端均可以触发,但是在移动端有延迟现象. 1.背景 由于早期移动设备浏览网页时内容较小,为了增强用户体验,苹果公司专门为移动设备设计了双击 ...

  8. c++字节对齐编译器指令#pragma

    第一种 #pragma pack(push, 1) // 先把当前对齐设置压栈,再设置为1字节对齐 struct S { char a; ]; }; #pragma pack(pop) // 恢复先前 ...

  9. php 7.1 新特性解析

    php 7.1 新特性解析 返回值和传入参数可以指定为 null <?php function testReturn(): ?string { return 'elePHPant'; } var ...

  10. ASP.NET Core 2.1 : 十五.图解路由(2.1 or earler)

    本文通过一张图来看一下路由的配置以及请求处理的机制.(ASP.NET Core 系列目录) 一.概述 路由主要有两个主要功能: 将请求的URL与已定义的路由进行匹配,找到该URL对应的处理程序并传入该 ...