码迷,mamicode.com
首页 > 其他好文 > 详细

Xtrabackup安装与使用

时间:2020-01-15 22:48:27      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:command   cal   check   node   and   bin   解决   art   nta   

安装

[root@node3 ~]# tar xf percona-xtrabackup-2.4.7-Linux-x86_64.tar.gz
[root@node3 ~]# cd percona-xtrabackup-2.4.7-Linux-x86_64
[root@node3 percona-xtrabackup-2.4.7-Linux-x86_64]# mkdir /usr/local/xtrabackup
[root@node3 percona-xtrabackup-2.4.7-Linux-x86_64]# mv * /usr/local/xtrabackup/
[root@node3 percona-xtrabackup-2.4.7-Linux-x86_64]#  ln -s /usr/local/xtrabackup/bin/* /usr/bin/

全量备份`

[root@localhost backup]# innobackupex --defaults-file=/etc/my.cnf --socket=/var/lib/mysql/mysql.sock --user=root --password="123456" --backup /root/backup
200115 21:22:08 innobackupex: Starting the backup operation

IMPORTANT: Please check that the backup run completes successfully.
           At the end of a successful backup run innobackupex
           prints "completed OK!".

Can‘t locate Data/Dumper.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at - line 688.
报错

解决办法

[root@localhost backup]# yum install perl(Data::Dumper)
[root@localhost backup]# yum -y install perl-Digest-MD5
[root@localhost backup]# cd 2020-01-15_21-29-53/
[root@localhost 2020-01-15_21-29-53]# ls -l
总用量 12336
drwxr-x---. 2 root root       48 1月  15 21:29 a
-rw-r-----. 1 root root      424 1月  15 21:29 backup-my.cnf
-rw-r-----. 1 root root      354 1月  15 21:29 ib_buffer_pool
-rw-r-----. 1 root root 12582912 1月  15 21:29 ibdata1
drwxr-x---. 2 root root     4096 1月  15 21:29 mysql
drwxr-x---. 2 root root     8192 1月  15 21:29 performance_schema
drwxr-x---. 2 root root     8192 1月  15 21:29 sys
-rw-r-----. 1 root root      113 1月  15 21:29 xtrabackup_checkpoints
-rw-r-----. 1 root root      493 1月  15 21:29 xtrabackup_info
-rw-r-----. 1 root root     2560 1月  15 21:29 xtrabackup_logfile
[root@localhost 2020-01-15_21-29-53]# cat xtrabackup_info 
uuid = 1fad2cc0-379b-11ea-afa7-000c29f66717
name = 
tool_name = innobackupex
tool_command = --defaults-file=/etc/my.cnf --socket=/var/lib/mysql/mysql.sock --user=root --password=... --backup /root/backup
tool_version = 2.4.7
ibbackup_version = 2.4.7
server_version = 5.7.29
start_time = 2020-01-15 21:29:54
end_time = 2020-01-15 21:29:57
lock_time = 0
binlog_pos = 
innodb_from_lsn = 0
innodb_to_lsn = 2635117
partial = N
incremental = N
format = file
compact = N
compressed = N
encrypted = N
这里面就是相关的备份文件,同样也可以看到我们创建的库的名称
[root@localhost 2020-01-15_21-29-53]# innobackupex --apply-log /root/backup/2020-01-15_21-29-53/
使用此参数使用相关数据性文件保持一致性状态
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| a                  |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.14 sec)

mysql> use a;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-------------+
| Tables_in_a |
+-------------+
| a1          |
+-------------+
1 row in set (0.00 sec)

mysql> select * from a1;
+-------+------+
| name  | age  |
+-------+------+
| lishi |   19 |
+-------+------+
1 row in set (0.00 sec)
mysql> drop table a1;
Query OK, 0 rows affected (0.34 sec)
mysql> select * from a1;
ERROR 1146 (42S02): Table a.a1 doesnt exist
[root@localhost ~]# systemctl stop mysqld
[root@localhost ~]# cd /var/lib/mysql
[root@localhost mysql]#  rm -rf *
[root@localhost mysql]# innobackupex --defaults-file=/etc/my.cnf --copy-back /root/backup/2020-01-15_21-29-53/
[root@localhost mysql]# chown -R mysql:mysql ./*
[root@localhost mysql]# systemctl start mysqld
[root@localhost mysql]# mysql -uroot -p123456
mysql> use a;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-------------+
| Tables_in_a |
+-------------+
| a1          |
+-------------+
1 row in set (0.00 sec)

mysql> select * from a1;
+-------+------+
| name  | age  |
+-------+------+
| lishi |   19 |
+-------+------+
1 row in set (0.00 sec)

Xtrabackup安装与使用

标签:command   cal   check   node   and   bin   解决   art   nta   

原文地址:https://www.cnblogs.com/liujunjun/p/12198918.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!