xtrabackup2.4

xtrabackup2.4只能备份5.*版本

[root@k8s-131 src]# mysql -V
mysql  Ver 14.14 Distrib 5.7.35, for linux-glibc2.12 (x86_64) using  EditLine wrapper
[root@k8s-131 src]# ll
total 658516
-rw-r--r--. 1 7161 31415 666328842 Jun  7  2021 mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
-rw-r--r--. 1 root root    7987620 Apr  2 13:39 percona-xtrabackup-24-2.4.25-1.el7.x86_64.rpm
[root@k8s-131 src]#
[root@k8s-131 src]#
[root@k8s-131 src]# yum -y install p
Display all 1140 possibilities? (y or n)^C
[root@k8s-131 src]# ll
total 658516
-rw-r--r--. 1 7161 31415 666328842 Jun  7  2021 mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
-rw-r--r--. 1 root root    7987620 Apr  2 13:39 percona-xtrabackup-24-2.4.25-1.el7.x86_64.rpm
[root@k8s-131 src]# yum -y install percona-xtrabackup-24-2.4.25-1.el7.x86_64.rpm
Loaded plugins: fastestmirror
Examining percona-xtrabackup-24-2.4.25-1.el7.x86_64.rpm: percona-xtrabackup-24-2.4.25-1.el7.x86_64
Marking percona-xtrabackup-24-2.4.25-1.el7.x86_64.rpm to be installed
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
--> Running transaction check
---> Package percona-xtrabackup-24.x86_64 0:2.4.25-1.el7 will be installed
--> Processing Dependency: perl(DBD::mysql) for package: percona-xtrabackup-24-2.4.25-1.el7.x86_64
Determining fastest mirrors
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
base                                                                                                                                               | 3.6 kB  00:00:00
docker-ce-stable                                                                                                                                   | 3.5 kB  00:00:00
extras                                                                                                                                             | 2.9 kB  00:00:00
updates                                                                                                                                            | 2.9 kB  00:00:00
(1/3): extras/7/x86_64/primary_db                                                                                                                  | 254 kB  00:00:00
(2/3): updates/7/x86_64/primary_db                                                                                                                 |  26 MB  00:00:01
(3/3): docker-ce-stable/7/x86_64/primary_db                                                                                                        | 140 kB  00:00:03
--> Processing Dependency: perl(Digest::MD5) for package: percona-xtrabackup-24-2.4.25-1.el7.x86_64
--> Processing Dependency: rsync for package: percona-xtrabackup-24-2.4.25-1.el7.x86_64
--> Processing Dependency: libev.so.4()(64bit) for package: percona-xtrabackup-24-2.4.25-1.el7.x86_64
--> Running transaction check
---> Package libev.x86_64 0:4.15-7.el7 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.023-6.el7 will be installed
--> Processing Dependency: perl(DBI::Const::GetInfoType) for package: perl-DBD-MySQL-4.023-6.el7.x86_64
--> Processing Dependency: perl(DBI) for package: perl-DBD-MySQL-4.023-6.el7.x86_64
---> Package perl-Digest-MD5.x86_64 0:2.52-3.el7 will be installed
--> Processing Dependency: perl(Digest::base) >= 1.00 for package: perl-Digest-MD5-2.52-3.el7.x86_64
---> Package rsync.x86_64 0:3.1.2-12.el7_9 will be installed
--> Running transaction check
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: perl-DBI-1.627-4.el7.x86_64
---> Package perl-Digest.noarch 0:1.17-245.el7 will be installed
--> Running transaction check
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================================
 Package                                   Arch                     Version                            Repository                                                    Size
==========================================================================================================================================================================
Installing:
 percona-xtrabackup-24                     x86_64                   2.4.25-1.el7                       /percona-xtrabackup-24-2.4.25-1.el7.x86_64                    31 M
Installing for dependencies:
 libev                                     x86_64                   4.15-7.el7                         extras                                                        44 k
 perl-Compress-Raw-Bzip2                   x86_64                   2.061-3.el7                        base                                                          32 k
 perl-Compress-Raw-Zlib                    x86_64                   1:2.061-4.el7                      base                                                          57 k
 perl-DBD-MySQL                            x86_64                   4.023-6.el7                        base                                                         140 k
 perl-DBI                                  x86_64                   1.627-4.el7                        base                                                         802 k
 perl-Data-Dumper                          x86_64                   2.145-3.el7                        base                                                          47 k
 perl-Digest                               noarch                   1.17-245.el7                       base                                                          23 k
 perl-Digest-MD5                           x86_64                   2.52-3.el7                         base                                                          30 k
 perl-IO-Compress                          noarch                   2.061-2.el7                        base                                                         260 k
 perl-Net-Daemon                           noarch                   0.48-5.el7                         base                                                          51 k
 perl-PlRPC                                noarch                   0.2020-14.el7                      base                                                          36 k
 rsync                                     x86_64                   3.1.2-12.el7_9                     updates                                                      408 k

Transaction Summary
==========================================================================================================================================================================
Install  1 Package (+12 Dependent packages)

Total size: 33 M
Total download size: 1.9 M
Installed size: 36 M
Downloading packages:
perl-DBI-1.627-4.el7.x86_64.rp FAILED                                                                                                   ]  0.0 B/s |    0 B  --:--:-- ETA
http://mirrors.bupt.edu.cn/centos/7.9.2009/os/x86_64/Packages/perl-DBI-1.627-4.el7.x86_64.rpm: [Errno 14] HTTP Error 403 - Forbidden    ]  0.0 B/s |    0 B  --:--:-- ETA
Trying other mirror.
To address this issue please refer to the below wiki article

https://wiki.centos.org/yum-errors

If above article doesn't help to resolve this issue please use https://bugs.centos.org/.

(1/12): libev-4.15-7.el7.x86_64.rpm                                                                                                                |  44 kB  00:00:00
(2/12): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm                                                                                             |  32 kB  00:00:00
(3/12): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                                                                                              |  57 kB  00:00:00
(4/12): perl-Digest-MD5-2.52-3.el7.x86_64.rpm                                                                                                      |  30 kB  00:00:00
(5/12): perl-Net-Daemon-0.48-5.el7.noarch.rpm                                                                                                      |  51 kB  00:00:00
(6/12): perl-PlRPC-0.2020-14.el7.noarch.rpm                                                                                                        |  36 kB  00:00:00
(7/12): perl-IO-Compress-2.061-2.el7.noarch.rpm                                                                                                    | 260 kB  00:00:00
(8/12): rsync-3.1.2-12.el7_9.x86_64.rpm                                                                                                            | 408 kB  00:00:00
(9/12): perl-DBI-1.627-4.el7.x86_64.rpm                                                                                                            | 802 kB  00:00:00
(10/12): perl-DBD-MySQL-4.023-6.el7.x86_64.rpm                                                                                                     | 140 kB  00:00:01
(11/12): perl-Data-Dumper-2.145-3.el7.x86_64.rpm                                                                                                   |  47 kB  00:00:01
(12/12): perl-Digest-1.17-245.el7.noarch.rpm                                                                                                       |  23 kB  00:00:01
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                     954 kB/s | 1.9 MB  00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                            1/13
  Installing : perl-Digest-1.17-245.el7.noarch                                                                                                                       2/13
  Installing : perl-Digest-MD5-2.52-3.el7.x86_64                                                                                                                     3/13
  Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                           4/13
  Installing : perl-IO-Compress-2.061-2.el7.noarch                                                                                                                   5/13
  Installing : libev-4.15-7.el7.x86_64                                                                                                                               6/13
  Installing : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                                   7/13
  Installing : rsync-3.1.2-12.el7_9.x86_64                                                                                                                           8/13
  Installing : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                                     9/13
  Installing : perl-PlRPC-0.2020-14.el7.noarch                                                                                                                      10/13
  Installing : perl-DBI-1.627-4.el7.x86_64                                                                                                                          11/13
  Installing : perl-DBD-MySQL-4.023-6.el7.x86_64                                                                                                                    12/13
  Installing : percona-xtrabackup-24-2.4.25-1.el7.x86_64                                                                                                            13/13
  Verifying  : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                                     1/13
  Verifying  : rsync-3.1.2-12.el7_9.x86_64                                                                                                                           2/13
  Verifying  : percona-xtrabackup-24-2.4.25-1.el7.x86_64                                                                                                             3/13
  Verifying  : perl-Digest-MD5-2.52-3.el7.x86_64                                                                                                                     4/13
  Verifying  : perl-DBD-MySQL-4.023-6.el7.x86_64                                                                                                                     5/13
  Verifying  : perl-IO-Compress-2.061-2.el7.noarch                                                                                                                   6/13
  Verifying  : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                                   7/13
  Verifying  : libev-4.15-7.el7.x86_64                                                                                                                               8/13
  Verifying  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                           9/13
  Verifying  : perl-Digest-1.17-245.el7.noarch                                                                                                                      10/13
  Verifying  : perl-DBI-1.627-4.el7.x86_64                                                                                                                          11/13
  Verifying  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                           12/13
  Verifying  : perl-PlRPC-0.2020-14.el7.noarch                                                                                                                      13/13

Installed:
  percona-xtrabackup-24.x86_64 0:2.4.25-1.el7

Dependency Installed:
  libev.x86_64 0:4.15-7.el7              perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7  perl-DBD-MySQL.x86_64 0:4.023-6.el7
  perl-DBI.x86_64 0:1.627-4.el7          perl-Data-Dumper.x86_64 0:2.145-3.el7         perl-Digest.noarch 0:1.17-245.el7            perl-Digest-MD5.x86_64 0:2.52-3.el7
  perl-IO-Compress.noarch 0:2.061-2.el7  perl-Net-Daemon.noarch 0:0.48-5.el7           perl-PlRPC.noarch 0:0.2020-14.el7            rsync.x86_64 0:3.1.2-12.el7_9

Complete!
[root@k8s-131 src]# xtrabackup  -v
xtrabackup: recognized server arguments: --datadir=/usr/local/mysql/data
xtrabackup version 2.4.25 based on MySQL server 5.7.35 Linux (x86_64) (revision id: 90fe9d0)
[root@k8s-131 src]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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> SHOW VARIABLES LIKE 'default_storage_engine';
+------------------------+--------+
| Variable_name          | Value  |
+------------------------+--------+
| default_storage_engine | InnoDB |
+------------------------+--------+
1 row in set (0.01 sec)

mysql>

 生成测试数据

创建用来备份数据的用户 

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

mysql> create user "back"@"%" identified by "123456";
Query OK, 0 rows affected (0.01 sec)

mysql> grant all on *.* to "back"@"%";
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql>

 

[root@k8s-131 src]# xtrabackup --backup --target-dir=/back/full --user=back --password=123456 --host=192.168.25.131 --port=3306
xtrabackup: recognized server arguments: --datadir=/usr/local/mysql/data
xtrabackup: recognized client arguments: --port=3306 --socket=/var/lib/mysql/mysql.sock --backup=1 --target-dir=/back/full --user=back --password=* --host=192.168.25.131 --port=3306
240402 14:02:24  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;host=192.168.25.131;port=3306;mysql_socket=/var/lib/mysql/mysql.sock' as 'back'  (using password: YES).
240402 14:02:24  version_check Connected to MySQL server
240402 14:02:24  version_check Executing a version check against the server...
240402 14:02:24  version_check Done.
240402 14:02:24 Connecting to MySQL server host: 192.168.25.131, user: back, password: set, port: 3306, socket: /var/lib/mysql/mysql.sock
Using server version 5.7.35
xtrabackup version 2.4.25 based on MySQL server 5.7.35 Linux (x86_64) (revision id: 90fe9d0)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /usr/local/mysql/data
xtrabackup: open files limit requested 0, set to 1024
xtrabackup: using the following InnoDB configuration:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = ./
xtrabackup:   innodb_log_files_in_group = 2
xtrabackup:   innodb_log_file_size = 50331648
InnoDB: Number of pools: 1
240402 14:02:24 >> log scanned up to (2755856)
xtrabackup: Generating a list of tablespaces

....
....
....

....



240402 14:02:25 [01]        ...done
240402 14:02:25 [01] Copying ./test/id.frm to /back/full/test/id.frm
240402 14:02:25 [01]        ...done
240402 14:02:25 Finished backing up non-InnoDB tables and files
240402 14:02:25 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '2755847'
xtrabackup: Stopping log copying thread.
.240402 14:02:25 >> log scanned up to (2755856)

240402 14:02:25 Executing UNLOCK TABLES
240402 14:02:25 All tables unlocked
240402 14:02:25 [00] Copying ib_buffer_pool to /back/full/ib_buffer_pool
240402 14:02:25 [00]        ...done
240402 14:02:25 Backup created in directory '/back/full/'
240402 14:02:25 [00] Writing /back/full/backup-my.cnf
240402 14:02:25 [00]        ...done
240402 14:02:25 [00] Writing /back/full/xtrabackup_info
240402 14:02:25 [00]        ...done
xtrabackup: Transaction log of lsn (2755847) to (2755856) was copied.
240402 14:02:26 completed OK!

全量备份后,我新增几条数据测试一下 

 

停止数据库 

 [root@k8s-131 mysql]# systemctl stop mysql

删除data数据库目录
[root@k8s-131 mysql]# mv data/ databack

新建data数据库目录

[root@k8s-131 mysql]# mkdir /usr/local/mysql/data/

记得授权
[root@k8s-131 mysql]# chown -R mysql:mysql /usr/local/mysql/data


[root@k8s-131 mysql]# xtrabackup --prepare --apply-log-only --target-dir=/back/full/


[root@k8s-131 mysql]# xtrabackup --prepare --target-dir=/back/full/

# 复制备份数据到新的数据目录
xtrabackup --copy-back --target-dir=/back/full/

 


# 设置新的数据目录的权限
chown -R mysql:mysql /usr/local/mysql/data/*

# 启动 MySQL 服务器
systemctl start mysql

 

 

 查看就是全量备份的数据

完成了

 

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值