xtarbackup全量备份

xtarbackup全量备份

1.软件获取

http://www.percona.com/software/percona-xtrabackup/downloads

2.安装

[root@db src]# ll percona-xtrabackup-24-2.4.8-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 7722148 9月  12 14:00 percona-xtrabackup-24-2.4.8-1.el7.x86_64.rpm
[root@db src]# yum  install percona-xtrabackup-24-2.4.8-1.el7.x86_64.rpm  -y #主要还是要解决依赖

3.初始化备份

 innobackupex  --user=root  --password=hanhy@qwe123   /backup/

4.将备份中数据变更同步增加到备份中,确保数据的一致性

[root@db ~]#  innobackupex  --apply-log   /backup/2017-09-12_16-45-43/

5.模拟数据丢失(关闭数据库)

[root@db ~]# service mysqld stop
Shutting down MySQL.. SUCCESS!

6.到数据目录(一定是测试的机器)

[root@db ~]# cd /mydata/mysql/data/
[root@db data]# rm   -rf  *   

7.恢复全备

[root@db data]# innobackupex --copy-back    /backup/2017-09-12_16-45-43/

8.到数据目录下

[root@db data]# chown  -R  mysql.mysql  .

9.启动数据库

[root@db data]# service mysqld  start
Starting MySQL... SUCCESS! 

10.进入数据库查看

[root@db data]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.34-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> show  databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hanhy              |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.03 sec)

mysql> 

 

posted @ 2017-09-12 14:39  Cassandrahan  阅读(214)  评论(0)    收藏  举报