准备2台虚拟机一主一从 mysql安装版本Mysql8.0.21, percona-xtrabackup-80-8.0.14-1.el7.x86_64.rpm
主192.168.24.131 master
从192.168.24.133 slave
Percona XtraBackup 8.0.14, 安装与测试
下载地址命令
wget https://downloads.percona.com/downloads/Percona-XtraBackup-LATEST/Percona-XtraBackup-8.0.14/binary/redhat/7/x86_64/percona-xtrabackup-80-8.0.14-1.el7.x86_64.rpm
yum localinstall percona-xtrabackup-80-8.0.14-1.el7.x86_64.rpm
[root@localhost file]# xtrabackup
开始进行备份操作,进入 主库 中
xtrabackup --defaults-file=/etc/my.cnf --user=root --password=root --port=3306 --backup --target-dir=/home/master_slave
主库备份完成
向从库传输数据
进入从库节目
已经传输过来了。看下从的数据库,没操做之前的样子
关闭从库mysql
[root@localhost home]# service mysql status
SUCCESS! MySQL running (25415)
[root@localhost home]# service mysql stop
Shutting down MySQL........ SUCCESS!
[root@localhost home]# mv /usr/local/mysql/data /usr/local/mysql/data2
[root@localhost home]# xtrabackup --defaults-file=/etc/my.cnf --copy-back --target-dir=/home/master_slave
[root@localhost home]# cd /usr/local/mysql/
[root@localhost mysql]# chown -R mysql:mysql /usr/local/mysql/data
重启从库mysql
[root@localhost mysql]# service mysql start
Starting MySQL.Logging to '/usr/local/mysql/data/data.err'.
................ SUCCESS!
[root@localhost mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.21 MySQL Community Server - GPLCopyright (c) 2000, 2020, 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 |
+--------------------+
| goods |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
备份完成!!!!!!