恢复的机器必须有my.cnf设置文件,再设置文件中设置好datadir目录即数据问目录,数据目录也必须为空,若不为空则会报错。
测试在本机恢复
vi my_3307.cnf
[client]
socket=/data/mysql/3307/data/mysql.sock
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql/3307/data
user=mysql
port=3307
socket=/data/mysql/3307/data/mysql.sock
log_error=/data/mysql/3307/data/mysqld.err
log_timestamps=system
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/data/mysql/3307/data/mysqld.err
pid-file=/data/mysql/3307/data/mysqld.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
恢复命令
xtrabackup --defaults-file=/etc/my_3307.cnf --copy-back --parallel=10 --target-dir=/data/backup/full
[client]
socket=/data/mysql/3307/data/mysql.sock
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql/3307/data
user=mysql
port=3307
socket=/data/mysql/3307/data/mysql.sock
log_error=/data/mysql/3307/data/mysqld.err
log_timestamps=system
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/data/mysql/3307/data/mysqld.err
pid-file=/data/mysql/3307/data/mysqld.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
(5)恢复命令